symfony-3.4.6/000077500000000000000000000000001324732107100132305ustar00rootroot00000000000000symfony-3.4.6/.composer/000077500000000000000000000000001324732107100151355ustar00rootroot00000000000000symfony-3.4.6/.composer/config.json000066400000000000000000000001331324732107100172720ustar00rootroot00000000000000{ "config": { "preferred-install": { "*": "dist" } } } symfony-3.4.6/.editorconfig000066400000000000000000000002031324732107100157000ustar00rootroot00000000000000; top-most EditorConfig file root = true ; Unix-style newlines [*] end_of_line = LF [*.php] indent_style = space indent_size = 4 symfony-3.4.6/.github/000077500000000000000000000000001324732107100145705ustar00rootroot00000000000000symfony-3.4.6/.github/ISSUE_TEMPLATE.md000066400000000000000000000006071324732107100173000ustar00rootroot00000000000000| Q | A | ---------------- | ----- | Bug report? | yes/no | Feature request? | yes/no | BC Break report? | yes/no | RFC? | yes/no | Symfony version | x.y.z symfony-3.4.6/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000020301324732107100203640ustar00rootroot00000000000000| Q | A | ------------- | --- | Branch? | master for features / 2.7 up to 4.0 for bug fixes | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | no | Deprecations? | yes/no | Tests pass? | yes | Fixed tickets | #... | License | MIT | Doc PR | symfony/symfony-docs#... symfony-3.4.6/.github/build-packages.php000066400000000000000000000056051324732107100201620ustar00rootroot00000000000000 $_SERVER['argc']) { echo "Usage: branch dir1 dir2 ... dirN\n"; exit(1); } chdir(dirname(__DIR__)); $dirs = $_SERVER['argv']; array_shift($dirs); $mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs)))); $packages = array(); $flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; foreach ($dirs as $k => $dir) { if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) { if ($exitStatus) { exit($exitStatus); } unset($dirs[$k]); continue; } echo "$dir\n"; $json = ltrim(file_get_contents($dir.'/composer.json')); if (null === $package = json_decode($json)) { passthru("composer validate $dir/composer.json"); exit(1); } $package->repositories = array(array( 'type' => 'composer', 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', )); if (false === strpos($json, "\n \"repositories\": [\n")) { $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); file_put_contents($dir.'/composer.json', $json); } passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) { echo "Missing \"dev-master\" branch-alias in composer.json extra.\n"; exit(1); } $package->version = str_replace('-dev', '.x-dev', $package->extra->{'branch-alias'}->{'dev-master'}); $package->dist['type'] = 'tar'; $package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar"; $packages[$package->name][$package->version] = $package; $versions = file_get_contents('https://packagist.org/p/'.$package->name.'.json'); $versions = json_decode($versions)->packages->{$package->name}; if ($package->version === str_replace('-dev', '.x-dev', $versions->{'dev-master'}->extra->{'branch-alias'}->{'dev-master'})) { unset($versions->{'dev-master'}); } foreach ($versions as $v => $package) { $packages[$package->name] += array($v => $package); } } file_put_contents('packages.json', json_encode(compact('packages'), $flags)); if ($dirs) { $json = ltrim(file_get_contents('composer.json')); if (null === $package = json_decode($json)) { passthru("composer validate $dir/composer.json"); exit(1); } $package->repositories = array(array( 'type' => 'composer', 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', )); if (false === strpos($json, "\n \"repositories\": [\n")) { $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); file_put_contents('composer.json', $json); } } symfony-3.4.6/.gitignore000066400000000000000000000001431324732107100152160ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml .php_cs.cache composer.phar package.tar /packages.json /.phpunit symfony-3.4.6/.php_cs.dist000066400000000000000000000041631324732107100154530ustar00rootroot00000000000000setRules(array( '@Symfony' => true, '@Symfony:risky' => true, '@PHPUnit48Migration:risky' => true, 'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice 'array_syntax' => array('syntax' => 'long'), 'protected_to_private' => false, )) ->setRiskyAllowed(true) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__.'/src') ->append(array(__FILE__)) ->exclude(array( // directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code 'Symfony/Component/DependencyInjection/Tests/Fixtures', 'Symfony/Component/Routing/Tests/Fixtures/dumper', // fixture templates 'Symfony/Component/Templating/Tests/Fixtures/templates', 'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom', // generated fixtures 'Symfony/Component/VarDumper/Tests/Fixtures', // resource templates 'Symfony/Bundle/FrameworkBundle/Resources/views/Form', )) // file content autogenerated by `var_export` ->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php') // test template ->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php') // explicit heredoc test ->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php') // explicit trigger_error tests ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt') ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt') ->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php') ) ; symfony-3.4.6/.travis.yml000066400000000000000000000211571324732107100153470ustar00rootroot00000000000000language: php dist: trusty sudo: false git: depth: 1 addons: apt_packages: - parallel - language-pack-fr-base - ldap-utils - slapd env: global: - MIN_PHP=5.5.9 - SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/versions/5.6/bin/php matrix: include: - php: hhvm-3.18 sudo: required group: edge - php: 5.5 - php: 5.6 - php: 7.0 - php: 7.1 env: deps=high - php: 7.2 env: deps=low fast_finish: true cache: directories: - .phpunit - php-$MIN_PHP - ~/php-ext services: - memcached - mongodb - redis-server before_install: - | # General configuration stty cols 120 mkdir /tmp/slapd slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 & PHP=$TRAVIS_PHP_VERSION [ -d ~/.composer ] || mkdir ~/.composer cp .composer/* ~/.composer/ export PHPUNIT=$(readlink -f ./phpunit) export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data" export COMPOSER_UP='composer update --no-progress --no-suggest --ansi' nanoseconds() { local cmd="date" local format="+%s%N" local os=$(uname) if hash gdate > /dev/null 2>&1; then cmd="gdate" elif [[ "$os" = Darwin ]]; then format="+%s000000000" fi $cmd -u $format } export -f nanoseconds # tfold is a helper to create folded reports tfold () { local title=$1 local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g') shift local id=$(printf %08x $(( RANDOM * RANDOM ))) local start=$(nanoseconds) echo -e "travis_fold:start:$fold" echo -e "travis_time:start:$id" echo -e "\\e[1;34m$title\\e[0m" bash -xc "$*" 2>&1 local ok=$? local end=$(nanoseconds) echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))" (exit $ok) && echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" || echo -e "\\e[41mKO\\e[0m $title\\n" (exit $ok) } export -f tfold # php.ini configuration if [[ $PHP = hhvm* ]]; then INI=/etc/hhvm/php.ini else INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini phpenv config-rm xdebug.ini || echo "xdebug not available" fi echo date.timezone = Europe/Paris >> $INI echo memory_limit = -1 >> $INI echo session.gc_probability = 0 >> $INI echo opcache.enable_cli = 1 >> $INI echo hhvm.jit = 0 >> $INI echo apc.enable_cli = 1 >> $INI echo extension = redis.so >> $INI echo extension = memcached.so >> $INI [[ $PHP = 5.* ]] && echo extension = memcache.so >> $INI if [[ $PHP = 5.* ]]; then echo extension = mongo.so >> $INI fi # tpecl is a helper to compile and cache php extensions tpecl () { local ext_name=$1 local ext_so=$2 local INI=$3 local ext_dir=$(php -r "echo ini_get('extension_dir');") local ext_cache=~/php-ext/$(basename $ext_dir)/$ext_name if [[ -e $ext_cache/$ext_so ]]; then echo extension = $ext_cache/$ext_so >> $INI else mkdir -p $ext_cache echo yes | pecl install -f $ext_name && cp $ext_dir/$ext_so $ext_cache fi } export -f tpecl # Matrix lines for intermediate PHP versions are skipped for pull requests if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip skip=1 else COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n') fi - | # Install sigchild-enabled PHP to test the Process component on the lowest PHP matrix line if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj && (cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2) fi - | # Install extra PHP extensions if [[ ! $skip && $PHP = 5.* ]]; then ([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") tfold ext.apcu tpecl apcu-4.0.11 apcu.so $INI elif [[ ! $skip && $PHP = 7.* ]]; then # install libsodium sudo add-apt-repository ppa:ondrej/php -y sudo apt-get update -q sudo apt-get install libsodium-dev -y tfold ext.apcu tpecl apcu-5.1.6 apcu.so $INI tfold ext.libsodium tpecl libsodium sodium.so $INI tfold ext.mongodb tpecl mongodb-1.4.0RC1 mongodb.so $INI fi - | # Load fixtures if [[ ! $skip ]]; then ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif && ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif fi install: - | # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components if [[ ! $deps ]]; then php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit elif [[ ! $skip ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak && cp composer.json composer.json.orig && echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json && php .github/build-packages.php HEAD^ $COMPONENTS && mv composer.json composer.json.phpunit && mv composer.json.orig composer.json fi - | # For the master branch, when deps=high, the version before master is checked out and tested with the locally patched components if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//) && git fetch origin $SYMFONY_VERSION && git checkout -m FETCH_HEAD && COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n') elif [[ ! $skip ]]; then SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*') fi - | # Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]] && LEGACY=,legacy export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi if [[ ! $skip && $PHP = 7.* ]]; then ([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb) fi - if [[ ! $skip ]]; then $COMPOSER_UP; fi - if [[ ! $skip ]]; then ./phpunit install; fi - | # phpinfo if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi - | run_tests () { set -e if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m" elif [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" elif [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'" elif [[ $PHP = hhvm* ]]; then $PHPUNIT --exclude-group no-hhvm,benchmark,intl-data else echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}" tfold tty-group $PHPUNIT --group tty if [[ $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} bash -c "tfold src/Symfony/Component/Process.sigchild{} SYMFONY_DEPRECATIONS_HELPER=weak ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/" fi fi } script: - (run_tests) symfony-3.4.6/CHANGELOG-3.0.md000066400000000000000000001276531324732107100153550ustar00rootroot00000000000000CHANGELOG for 3.0.x =================== This changelog references the relevant changes (bug and security fixes) done in 3.0 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.0.0...v3.0.1 * 3.0.9 (2016-07-30) * bug #19470 undefined offset fix (#19406) (ReenExe) * bug #19300 [HttpKernel] Use flock() for HttpCache's lock files (mpdude) * bug #19428 [Process] Fix write access check for pipes on Windows (nicolas-grekas) * bug #19439 [DependencyInjection] Fixed deprecated default message template with XML (jeremyFreeAgent) * bug #19397 [HttpFoundation] HttpCache refresh stale responses containing an ETag (maennchen) * bug #19426 [Form] Fix the money form type render with Bootstrap3 (Th3Mouk) * bug #19422 [DomCrawler] Inherit the namespace cache in subcrawlers (stof) * bug #19425 [BrowserKit] Uppercase the "GET" method in redirects (jakzal) * bug #19384 Fix PHP 7.1 related failures (nicolas-grekas) * bug #19379 [VarDumper] Fix for PHP 7.1 (nicolas-grekas) * bug #19342 Added class existence check if is_subclass_of() fails in compiler passes (SCIF) * bug #19369 Fix the DBAL session handler version check for Postgresql (stof) * bug #19368 [VarDumper] Fix dumping jsons casted as arrays (nicolas-grekas) * bug #19334 [Security] Fix the retrieval of the last username when using forwarding (stof) * bug #19321 [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods (dunglas) * bug #19317 [BrowserKit] Update Client::getAbsoluteUri() for query string only URIs (georaldc) * bug #19298 [ClassLoader] Fix declared classes being computed when not needed (nicolas-grekas) * bug #19316 [Validator] Added additional MasterCard range to the CardSchemeValidator (Dennis Væversted) * bug #19290 [HttpKernel] fixed internal subrequests having an if-modified-since-header (MalteWunsch) * bug #19307 [Security] Fix deprecated usage of DigestAuthenticationEntryPoint::getKey() in DigestAuthenticationListener (Maxime STEINHAUSSER) * bug #19309 [DoctrineBridge] added missing error code for constraint. (Koc) * bug #19306 [Form] fixed bug - name in ButtonBuilder (cheprasov) * bug #19292 [varDumper] Fix missing usage of ExceptionCaster::$traceArgs (nicolas-grekas) * bug #19288 [VarDumper] Fix indentation trimming in ExceptionCaster (nicolas-grekas) * bug #19267 [Validator] UuidValidator must accept a Uuid constraint. (hhamon) * bug #19186 Fix for #19183 to add support for new PHP MongoDB extension in sessions. (omanizer) * bug #19253 [Console] Fix block() padding formatting after #19189 (chalasr) * bug #19218 [Security][Guard] check if session exist before using it (pasdeloup) * 3.0.8 (2016-06-30) * bug #19217 [HttpKernel] Inline ValidateRequestListener logic into HttpKernel (nicolas-grekas) * bug #18688 [HttpFoundation] Warning when request has both Forwarded and X-Forwarded-For (magnusnordlander) * bug #19173 [Console] Decouple SymfonyStyle from TableCell (ro0NL) * bug #19189 [Console] Fix formatting of SymfonyStyle::comment() (chalasr) * bug #19211 [Form] fix post max size translation type extension for >= 2.8 (Tobion) * bug #17822 [WIP] [Form] fix `empty_data` option in expanded `ChoiceType` (HeahDude) * bug #19134 Distinguish between first and subsequent progress bar displays (rquadling) * bug #19061 [FORM] fix post_max_size_message translation (alt. 2) (David Badura) * bug #19100 [Console] Fixed SymfonyQuestionHelper multi-choice with defaults (sstok) * bug #18924 [DoctrineBridge] Don't use object IDs in DoctrineChoiceLoader when passing a value closure (webmozart) * bug #19138 [DomCrawler] No more exception on field name with strange format (guiled, fabpot) * bug #18935 [Form] Consider a violation even if the form is not submitted (egeloen) * bug #19127 [Form] Add exception to FormRenderer about non-unique block names (enumag) * bug #19118 [Process] Fix pipes cleaning on Windows (nicolas-grekas) * bug #19128 Avoid phpunit 5.4 warnings on getMock (2.7+) (iltar) * bug #19114 [HttpKernel] Dont close the reponse stream in debug (nicolas-grekas) * bug #19101 [Session] fix PDO transaction aborted under PostgreSQL (Tobion) * bug #18501 [HttpFoundation] changed MERGE queries (hjkl) * bug #19062 [HttpFoundation] Fix UPSERT for PgSql >= 9.5 (nicolas-grekas) * bug #18548 [Form] minor fixes in DateTime transformers (HeahDude) * bug #18732 [PropertyAccess][DX] Enhance exception that say that some methods are missing if they don't (nykopol) * bug #19048 [HttpFoundation] Use UPSERT for sessions stored in PgSql >= 9.5 (nicolas-grekas) * bug #19038 Fix feature detection for IE (Alsciende) * bug #18915 [DependencyInjection] force enabling the external XML entity loaders (xabbuh) * bug #19020 [Form] Fixed collapsed choice attributes (HeahDude) * bug #19028 [Yaml] properly count skipped comment lines (xabbuh) * bug #19009 [WebProfilerBundle] Fix invalid CSS style (romainneutron) * bug #17733 [Yaml] Fix wrong line number when comments are inserted in the middle of a block. (paradajozsef) * bug #18911 Fixed singular of committee (peterrehm) * bug #18971 Do not inject web debug toolbar on attachments (peterrehm) * 3.0.7 (2016-06-06) * bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh) * bug #18893 [DependencyInjection] Skip deep reference check for 'service_container' (RobertMe) * bug #18812 Catch \Throwable (fprochazka) * bug #18821 [Form] Removed UTC specification with timestamp (francisbesset) * bug #18861 Fix for #18843 (inso) * bug #18889 [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments (chalasr) * bug #18907 [Routing] Fix the annotation loader taking a class constant as a beginning of a class name (jakzal, nicolas-grekas) * bug #18879 [Console] SymfonyStyle: Align multi-line/very-long-line blocks (chalasr) * bug #18864 [Console][DX] Fixed ambiguous error message when using a duplicate option shortcut (peterrehm) * bug #18883 Fix js comment in profiler (linnaea) * bug #18844 [Yaml] fix exception contexts (xabbuh) * bug #18840 [Yaml] properly handle unindented collections (xabbuh) * bug #18765 Catch \Throwable (fprochazka) * bug #18813 Catch \Throwable (fprochazka) * bug #18839 People - person singularization (Keeo) * bug #18828 [Yaml] chomp newlines only at the end of YAML documents (xabbuh) * bug #18814 Fixed server status command when port has been omitted (peterrehm) * bug #18759 [Validator] Support for DateTimeImmutable (krzysiekpiasecki) * bug #18799 Use levenshtein level for better Bundle matching (j0k3r) * bug #18413 [WebProfilerBundle] Fix CORS ajax security issues (romainneutron) * bug #18774 [console][table] adjust width of colspanned cell. (aitboudad) * bug #18507 [BUG] Delete class 'control-group' in bootstrap 3 (Philippe Degeeter) * bug #18747 [Form] Modified iterator_to_array's 2nd parameter to false in ViolationMapper (issei-m) * bug #18635 [Console] Prevent fatal error when calling Command::getHelper without helperSet (chalasr) * bug #18686 [console][table] adjust width of colspanned cell. (aitboudad) * bug #18761 [Form] Modified iterator_to_array's 2nd parameter to false in ViolationMapper (issei-m) * bug #18745 [MonologBridge] Uninstallable together with symfony/http-kernel in 3.0.6 (ymc-dabe) * bug #18737 [Debug] Fix fatal error handlers on PHP 7 (nicolas-grekas) * 3.0.6 (2016-05-10) * security #18736 Fixed issue with blank password with Ldap (csarrazi) * security #18733 limited the maximum length of a submitted username (fabpot) * bug #18730 [FrameworkBundle] prevent calling get() for service_container service (xabbuh) * bug #18705 added a conflict between Monolog bridge 2.8 and HTTP Kernel 3.0+ (fabpot) * bug #18709 [DependencyInjection] top-level anonymous services must be public (xabbuh) * bug #18388 [EventDispatcher] check for method to exist (xabbuh) * bug #18699 [DependencyInjection] Use the priority of service decoration on service with parent (hason) * bug #18692 add @Event annotation for KernelEvents (Haehnchen) * bug #18246 [DependencyInjection] fix ambiguous services schema (backbone87) * 3.0.5 (2016-05-03) * bug #18180 [Form] fixed BC break with pre selection of choices with `ChoiceType` and its children (HeahDude) * bug #18645 [Console] Fix wrong exceptions being thrown (JhonnyL) * bug #18562 [WebProfilerBunde] Give an absolute url in case the request occured from another domain (romainneutron) * bug #18600 [DI] Fix AutowirePass fatal error with classes that have non-existing parents (hason, nicolas-grekas) * bug #18556 [FrameworkBundle] Better output for user in ContainerDebugCommand (JhonnyL) * bug #18603 [PropertyAccess] ->getValue() should be read-only (nicolas-grekas) * bug #18593 [VarDumper] Fix dumping type hints for non-existing parent classes (nicolas-grekas) * bug #18596 [DI] Fix internal caching in AutowirePass (nicolas-grekas) * bug #18581 [Console] [TableHelper] make it work with SymfonyStyle. (aitboudad) * bug #18280 [Routing] add query param if value is different from default (Tobion) * bug #18540 Replace iconv_*() uses by mb_*(), add mbstring polyfill when required (nicolas-grekas) * bug #18496 [Console] use ANSI escape sequences in ProgressBar overwrite method (alekitto) * bug #18490 [LDAP] Free the search result after a search to free memory (hiddewie) * bug #18491 [DependencyInjection] anonymous services are always private (xabbuh) * bug #18515 [Filesystem] Better error handling in remove() (nicolas-grekas) * bug #18081 [Form] FormValidator removed code related to removed `cascade_validation` option (peterrehm) * bug #18360 [PropertyInfo] Extract nullable and collection key type for Doctrine associations (teohhanhui) * bug #18449 [PropertyAccess] Fix regression (nicolas-grekas) * bug #18429 [Console] Correct time formatting. (camporter) * bug #18457 [WebProfilerBundle] Fixed error from unset twig variable (simonsargeant) * bug #18467 [DependencyInjection] Resolve aliases before removing abstract services + add tests (nicolas-grekas) * bug #18469 Force profiler toolbar svg display (pyrech) * bug #18460 [DomCrawler] Fix select option with empty value (Matt Wells) * bug #18425 [Security] Fixed SwitchUserListener when exiting an impersonation with AnonymousToken (lyrixx) * bug #18317 [Form] fix "prototype" not required when parent form is not required (HeahDude) * bug #18439 [Logging] Add support for Firefox (43+) in ChromePhpHandler (arjenm) * bug #18385 Detect CLI color support for Windows 10 build 10586 (mlocati) * bug #18426 [EventDispatcher] Try first if the event is Stopped (lyrixx) * bug #18407 Fixed the "hover" state of the profiler sidebar menu (javiereguiluz) * bug #18399 [Intl] Fix int32 min boundary check (nicolas-grekas) * bug #18394 [FrameworkBundle] Return the invokable service if its name is the class name (dunglas) * bug #18347 Fixed the styles of the Symfony icon in the web debug toolbar (javiereguiluz) * bug #18265 Optimize ReplaceAliasByActualDefinitionPass (ajb-in) * bug #18349 [Process] Fix stream_select priority when writing to stdin (nicolas-grekas) * bug #18358 [Form] NumberToLocalizedStringTransformer should return floats when possible (nicolas-grekas) * bug #17926 [DependencyInjection] Enable alias for service_container (hason) * 3.0.4 (2016-03-30) * bug #18352 [Debug] Fix case sensitivity checks (nicolas-grekas) * bug #18336 [Debug] Fix handling of php7 throwables (nicolas-grekas) * bug #18354 [FrameworkBundle][TwigBridge] fix high deps tests (xabbuh) * bug #18312 [ClassLoader] Fix storing not-found classes in APC cache (nicolas-grekas) * bug #18298 [Validator] do not treat payload as callback (xabbuh) * bug #18275 [Form] Fix BC break introduced in #14403 (HeahDude) * bug #18271 [FileSystem] Google app engine filesystem (swordbeta) * bug #18255 [HttpFoundation] Fix support of custom mime types with parameters (Ener-Getick) * bug #18272 [Bridge\PhpUnit] Workaround old phpunit bug, no colors in weak mode, add tests (nicolas-grekas) * bug #18259 [PropertyAccess] Backport fixes from 2.7 (nicolas-grekas) * bug #18261 [PropertyAccess] Fix isPropertyWritable not using the reflection cache (nicolas-grekas) * bug #18224 [PropertyAccess] Remove most ref mismatches to improve perf (nicolas-grekas) * bug #18237 [WebProfilerBundle] Added table-layout property to AJAX toolbar css (kevintweber) * bug #18209 [PropertyInfo] Support Doctrine custom mapping type in DoctrineExtractor (teohhanhui) * bug #18210 [PropertyAccess] Throw an UnexpectedTypeException when the type do not match (dunglas, nicolas-grekas) * bug #18216 [Intl] Fix invalid numeric literal on PHP 7 (nicolas-grekas) * bug #18147 [Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols (natechicago) * bug #18023 [Process] getIncrementalOutput should work without calling getOutput (romainneutron) * bug #18175 [Translation] Add support for fuzzy tags in PoFileLoader (nud) * bug #18179 [Form] Fix NumberToLocalizedStringTransformer::reverseTransform with big integers (ovrflo, nicolas-grekas) * bug #18164 [HttpKernel] set s-maxage only if all responses are cacheable (xabbuh) * bug #18150 [Process] Wait a bit less on Windows (nicolas-grekas) * bug #18130 [Debug] Replaced logic for detecting filesystem case sensitivity (Dan Blows) * bug #18137 Autowiring the concrete class too - consistent with behavior of other services (weaverryan) * bug #18087 [WebProfiler] Sidebar button padding (rvanlaak) * bug #18080 [HttpFoundation] Set the Content-Range header if the requested Range is unsatisfied (jakzal) * bug #18084 [HttpFoundation] Avoid warnings when checking malicious IPs (jakzal) * bug #18066 [Process] Fix pipes handling (nicolas-grekas) * bug #18078 [Console] Fix an autocompletion question helper issue with non-sequentially indexed choices (jakzal) * bug #18048 [HttpKernel] Fix mem usage when stripping the prod container (nicolas-grekas) * bug #18065 [Finder] Partially revert #17134 to fix a regression (jakzal) * bug #18018 [HttpFoundation] exception when registering bags for started sessions (xabbuh) * bug #18054 [Filesystem] Fix false positive in ->remove() (nicolas-grekas) * bug #18049 [Validator] Fix the locale validator so it treats a locale alias as a valid locale (jakzal) * bug #18019 [Intl] Update ICU to version 55 (jakzal) * bug #18015 [Process] Fix memory issue when using large input streams (romainneutron) * bug #16656 [HttpFoundation] automatically generate safe fallback filename (xabbuh) * bug #15794 [Console] default to stderr in the console helpers (alcohol) * bug #17984 Allow to normalize \Traversable when serializing xml (Ener-Getick) * bug #17434 Improved the error message when a template is not found (rvanginneken, javiereguiluz) * bug #17687 Improved the error message when using "@" in a decorated service (javiereguiluz) * bug #17744 Improve error reporting in router panel of web profiler (javiereguiluz) * bug #17894 [FrameworkBundle] Fix a regression in handling absolute template paths (jakzal) * bug #17990 [DoctrineBridge][Form] Fix performance regression in EntityType (kimlai) * bug #17595 [HttpKernel] Remove _path from query parameters when fragment is a subrequest (cmenning) * bug #17986 [DomCrawler] Dont use LIBXML_PARSEHUGE by default (nicolas-grekas) * bug #17668 add 'guid' to list of exception to filter out (garak) * bug #17615 Ensure backend slashes for symlinks on Windows systems (cpsitgmbh) * bug #17626 Try to delete broken symlinks (IchHabRecht) * bug #17978 [Yaml] ensure dump indentation to be greather than zero (xabbuh) * bug #16886 [Form] [ChoiceType] Prefer placeholder to empty_value (boite) * bug #17976 [WebProfilerBundle] fix debug toolbar rendering by removing inadvertently added links (craue) * bug #17971 Variadic controller params (NiR-, fabpot) * bug #17876 [DependencyInjection] Fixing autowiring bug when some args are set (weaverryan) * bug #17568 Improved Bootstrap form theme for hidden fields (javiereguiluz) * bug #17561 [WebProfilerBundle] Fix design issue in profiler when having errors in forms (Pierstoval) * bug #17925 [Bridge] The WebProcessor now forwards the client IP (magnetik) * 3.0.3 (2016-02-28) * bug #17919 #17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features (Ocramius) * bug #17947 Fix - #17676 (backport #17919 to 2.3) (Ocramius) * bug #17942 Fix bug when using an private aliased factory service (WouterJ) * bug #17798 [Form] Fix BC break by allowing 'choice_label' option to be 'false' in ChoiceType (HeahDude) * bug #17542 ChoiceFormField of type "select" could be "disabled" (bouland) * bug #17602 [HttpFoundation] Fix BinaryFileResponse incorrect behavior with if-range header (bburnichon) * bug #17760 [Form] fix choice value "false" in ChoiceType (HeahDude) * bug #17914 [Console] Fix escaping of trailing backslashes (nicolas-grekas) * bug #17074 Fix constraint validator alias being required (Triiistan) * bug #17866 [DependencyInjection] replace alias in factories (xabbuh) * bug #17867 [DependencyInjection] replace alias in factory services (xabbuh) * bug #17865 [FrameworkBundle] disable the assets helper when assets are disabled (xabbuh) * bug #17860 Fixed the antialiasing of the toolbar text (javiereguiluz) * bug #17569 [FrameworkBundle] read commands from bundles when accessing list (havvg) * bug #16987 [FileSystem] Windows fix (flip111) * bug #17787 [Form] Fix choice placeholder edge cases (Tobion) * bug #17835 [Yaml] fix default timezone to be UTC (xabbuh) * bug #17823 [DependencyInjection] fix dumped YAML string (xabbuh) * bug #17818 [Console] InvalidArgumentException is thrown under wrong condition (robinkanters) * bug #17819 [HttpKernel] Prevent a fatal error when DebugHandlersListener is used with a kernel with no terminateWithException() method (jakzal) * bug #17814 [DependencyInjection] fix dumped YAML snytax (xabbuh) * bug #17099 [Form] Fixed violation mapping if multiple forms are using the same (or part of the same) property path (alekitto) * bug #17694 [DoctrineBridge] [Form] fix choice_value in EntityType (HeahDude) * bug #17790 [Config] Fix EnumNodeDefinition to allow building enum nodes with one element (ogizanagi) * bug #17729 [Yaml] properly parse lists in object maps (xabbuh) * bug #17719 [DependencyInjection] fixed exceptions thrown by get method of ContainerBuilder (lukaszmakuch) * bug #17742 [DependencyInjection] Fix #16461 Container::set() replace aliases (mnapoli) * bug #17745 Added more exceptions to singularify method (javiereguiluz) * bug #17691 Fixed (string) catchable fatal error for PHP Incomplete Class instances (yceruto) * bug #17766 Fixed (string) catchable fatal error for PHP Incomplete Class instances (yceruto) * bug #17757 [HttpFoundation] BinaryFileResponse sendContent return as parent. (2.3) (SpacePossum) * bug #17748 [DomCrawler] Remove the overridden getHash() method to prevent problems when cloning the crawler (jakzal) * bug #17725 [WebProfilerBundle] Add width attribute on SVG - Fix toolbar profiler on microsoft edge (AlexandrePavy) * bug #17703 [FrameworkBundle] Support autowiring for TranslationInterface (dunglas) * bug #17613 [WebProfiler] Fixed logo and menu profiler for Microsoft Edge (WhiteEagle88) * bug #17702 [TwigBridge] forward compatibility with Yaml 3.1 (xabbuh) * bug #17673 [Routing] add files used in FileResource objects (xabbuh) * bug #17672 [DependencyInjection][Routing] add files used in FileResource objects (xabbuh) * bug #17669 [Console] remove readline support (xabbuh) * bug #17600 Fixed the Bootstrap form theme for inlined checkbox/radio (javiereguiluz) * 3.0.2 (2016-02-03) * bug #17658 [FrameworkBundle] fix assets and templating tests (xabbuh) * bug #17596 [Translation] Add resources from fallback locale to parent catalogue (c960657) * bug #17605 [FrameworkBundle] remove default null value for asset version (xabbuh) * bug #17606 [DependencyInjection] pass triggerDeprecationError arg to parent class (xabbuh) * bug #16956 [DependencyInjection] XmlFileLoader: enforce tags to have a name (xabbuh) * bug #16265 [BrowserKit] Corrected HTTP_HOST logic (Naktibalda) * bug #17559 [SecurityBundle] Fix HTTP Digest auth not being passed user checker (SamFleming) * bug #17554 [DependencyInjection] resolve aliases in factories (xabbuh) * bug #17555 [DependencyInjection] resolve aliases in factory services (xabbuh) * bug #17511 [Form] ArrayChoiceList can now deal with a null in choices (issei-m) * bug #17430 [Serializer] Ensure that groups are strings (dunglas) * bug #16795 [FrameworkBundle][Validator] Fix apc cache service & config (ogizanagi) * bug #15272 [FrameworkBundle] Fix template location for PHP templates (jakzal) * bug #11232 [Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports (Tischoi) * bug #17526 Escape the delimiter in Glob::toRegex (javiereguiluz) * bug #17527 fixed undefined variable (fabpot) * bug #15706 [framework-bundle] Added support for the `0.0.0.0/0` trusted proxy (zerkms) * bug #16274 [HttpKernel] Lookup the response even if the lock was released after two second wait (jakzal) * bug #16954 [TranslationUpdateCommand] fixed undefined resultMessage var. (aitboudad) * bug #17355 [DoctrineBridge][Validator] >= 2.3 Pass association instead of ID as argument (xavismeh) * bug #17330 Limit the max height/width of icons in the profiler menu (javiereguiluz) * bug #17454 Allow absolute URLs to be displayed in the debug toolbar (javiereguiluz) * bug #16736 [Request] Ignore invalid IP addresses sent by proxies (GromNaN) * bug #17459 [EventDispatcher] TraceableEventDispatcher resets event listener priorities (c960657) * bug #17486 [FrameworkBundle] Throw for missing container extensions (kix) * bug #16961 Overriding profiler position in CSS breaks JS positioning (aschempp) * bug #16873 Able to load big xml files with DomCrawler (zorn-v) * bug #16897 [Form] Fix constraints could be null if not set (DZunke) * bug #16912 [Translation][Writer] avoid calling setBackup if the dumper is not FileDumper (aitboudad) * bug #17505 sort bundles in config:dump-reference command (xabbuh) * bug #17506 [FrameworkBundle] enable assets when templates are enabled (xabbuh) * bug #17514 [Asset] Add defaultNull to version configuration (ewgRa) * bug #16511 [Asset] Ability to set empty version strategy in packages (ewgRa) * bug #17457 Display Ajax requests from newest to oldest in the toolbar (javiereguiluz) * bug #17503 [Asset] CLI: use request context to generate absolute URLs (xabbuh) * bug #17478 [HttpFoundation] Do not overwrite the Authorization header if it is already set (jakzal) * bug #17461 [Yaml] tag for dumped PHP objects must be a local one (xabbuh) * bug #16822 [FrameworkBundle][Validator] Fix apc cache service deprecation (ogizanagi) * bug #17463 [Form] make tests compatible with Symfony 2.8 and 3.0 (xabbuh) * bug #17456 [DX] Remove default match from AbstractConfigCommand::findExtension (kix) * bug #17455 Fixed form types in profiler (javiereguiluz) * bug #17424 [Process] Update in 2.7 for stream-based output storage (romainneutron) * bug #17417 Fixed the form profiler when using long form types (javiereguiluz) * bug #17423 [Process] Use stream based storage to avoid memory issues (romainneutron) * bug #17041 [FrameworkBundle] Added the assets helper again (dosten) * bug #17406 [Form] ChoiceType: Fix a notice when 'choices' normalizer is replaced (paradajozsef) * bug #17433 [FrameworkBundle] Don't log twice with the error handler (nicolas-grekas) * bug #17418 Fixed Bootstrap form theme form "reset" buttons (javiereguiluz) * bug #17416 [PropertyInfo] PhpDocExtractor: Fix a notice when the property doesn'… (dunglas) * bug #17404 fix merge 2.3 into 2.7 for SecureRandom dependency (Tobion) * bug #17373 [SecurityBundle] fix SecureRandom service constructor args (Tobion) * bug #17397 Remove remaining calls to non-existing method (paradajozsef) * bug #17382 [TwigBridge] Use label_format option for checkbox and radio labels (enumag) * bug #17380 [TwigBridge] Use label_format option for checkbox and radio labels (enumag) * bug #17377 Fix performance (PHP5) and memory (PHP7) issues when using token_get_all (nicolas-grekas, peteward) * bug #17389 [Routing] Fixed correct class name in thrown exception (fixes #17388) (robinvdvleuten) * bug #17358 [ClassLoader] Use symfony/polyfill-apcu (nicolas-grekas) * bug #17370 [HttpFoundation][Cookie] Cookie DateTimeInterface fix (wildewouter) * security #17359 do not ship with a custom rng implementation (xabbuh, fabpot) * bug #17253 [Console] HHVM read input stream bug (mbutkereit) * bug #17314 Fix max width for multibyte keys in choice question (mheki) * bug #17326 [Console] Display console application name even when no version set (polc) * bug #17328 [Serializer] Allow to use proxies in object_to_populate (dunglas) * bug #17202 [FrameworkBundle] Don't log twice with the error handler (nicolas-grekas) * bug #17347 Workaround https://bugs.php.net/63206 (nicolas-grekas) * bug #17340 [HttpFoundation] Fixed Request HTTP_USER_AGENT on 3.X versions (davelima) * bug #17199 [Serializer] Allow context to contain not serializable data (dunglas, nicolas-grekas) * bug #17334 [WebProfiler] Fixed sf-minitoolbar height (yceruto) * bug #17140 [Serializer] Remove normalizer cache in Serializer class (jvasseur) * bug #17320 [Debug] Fixed erroneous deprecation notice for extended Interfaces (peterrehm) * bug #17307 [FrameworkBundle] Fix paths with % in it (like urlencoded) (scaytrase) * bug #17078 [Bridge] [Doctrine] [Validator] Added support \IteratorAggregate for UniqueEntityValidator (Disparity) * bug #17298 [FrameworkBundle] Use proper class to fetch $versionStrategy property (dosten) * bug #17287 [HttpKernel] Forcing string comparison on query parameters sort in UriSigner (Tim van Densen) * bug #17279 [FrameworkBundle] Add case in Kernel directory guess for PHPUnit (tgalopin) * bug #17278 [FrameworkBundle] Add case in Kernel directory guess for PHPUnit (tgalopin) * bug #17063 bug #14246 [Filesystem] dumpFile() negates default file permissions (Hidde Boomsma) * bug #17283 [WebProfilerBundle] Remove loading status from AJAX toolbar after error (kucharovic) * bug #17275 [PhpUnitBridge] Re-enable the garbage collector (nicolas-grekas) * bug #17276 [Process] Fix potential race condition (nicolas-grekas) * bug #17261 [FrameworkBundle] Allow to autowire service_container (dunglas) * bug #17183 [FrameworkBundle] Set the kernel.name properly after a cache warmup (jakzal) * bug #17197 [Yaml] cast arrays to objects after parsing has finished (xabbuh) * bug #17247 Fix toolbar display when nvd3 is loaded on page (Seldaek) * bug #17159 [Yaml] recognize when a block scalar is left (xabbuh) * bug #17195 bug #14246 [Filesystem] dumpFile() non atomic (Hidde Boomsma) * feature #16747 [Form] Improved performance of ChoiceType and its subtypes (webmozart) * bug #17179 [WebProfiler] Removed an object as route generator argument (iltar) * bug #17177 [Process] Fix potential race condition leading to transient tests (nicolas-grekas) * bug #17163 [Form] fix Catchable Fatal Error if choices is not an array (Gladhon, nicolas-grekas) * bug #17152 [DoctrineBridge] [PropertyInfo] Catch Doctrine\ORM\Mapping\MappingException (dunglas) * bug #17119 [Form] improve deprecation message for "empty_value" and "choice_list" options. (hhamon) * bug #17156 [HttpFoundation] add missing symfony/polyfill-php55 dependency (xabbuh) * bug #17162 [Form] Fix regression on Collection type (hason) * 3.0.1 (2015-12-26) * bug #16864 [Yaml] fix indented line handling in folded blocks (xabbuh) * bug #17052 Fixed flatten exception recursion with errors (GrahamCampbell) * bug #16826 Embedded identifier support (mihai-stancu) * bug #17079 Also transform inline mappings to objects (WouterJ) * bug #17129 [Config] Fix array sort on normalization in edge case (romainneutron) * feature #17035 [DomCrawler] Revert previous restriction, allow selection of every DOMNode object (EdgarPE) * bug #17094 [Process] More robustness and deterministic tests (nicolas-grekas) * bug #17112 [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace (alekitto) * bug #17109 Improved the design of the web debug toolbar (javiereguiluz) * bug #16797 [Filesystem] Recursively widen non-executable directories (Slamdunk) * bug #16926 [DependencyInjection] fixed definition loosing property shared when decorated by a parent definition (wahler) * bug #17040 [Console] Avoid extra blank lines when rendering exceptions (ogizanagi) * bug #17044 [Form] fix BC break introduced with prototype_data option (memphys) * bug #17055 [Security] Verify if a password encoded with bcrypt is no longer than 72 characters (jakzal) * bug #16959 [Form] fix #15544 when a collection type attribute "required" is false, "prototype" should too (HeahDude) * bug #16806 [Validator] BicValidator - fixed raising violations to a maximum of one (mvhirsch) * bug #16842 [Ldap] Escape carriage returns in LDAP DNs. (ChadSikorra) * bug #16860 [Yaml] do not remove "comments" in scalar blocks (xabbuh) * bug #17002 [Console][Table] fixed render row that contains multiple cells. (aitboudad) * bug #16964 CSS min-height and min-width should not be "auto" (aschempp) * bug #16971 [HttpFoundation] Added the ability of using BinaryFileResponse with stream wrappers (jakzal, Sander-Toonen) * bug #17048 Fix the logout path when not using the router (stof) * bug #17049 Fix the logout path when not using the router (stof) * bug #17057 [FrameworkBundle][HttpKernel] the finder is required to discover bundle commands (xabbuh) * bug #17059 [HttpFoundation] fix error level for deprecation (xabbuh) * bug #17006 [Form] Fix casting regression in DoctrineChoiceLoader (bendavies) * bug #16911 [PropertyInfo] Update List Information from ReflectionExtractor (zanderbaldwin) * bug #16955 [FrameworkBundle] ContainerDebugCommand: pass the right object to the descriptors (xabbuh) * bug #16970 [HttpKernel] HttpCache: remove an ESI instance checking (voronkovich) * feature #16760 Show silenced errors in separate tab (peterrehm) * feature #16937 [PhpUnitBridge] Replace "weak-verbose" by "deprecations upper bound" mode (nicolas-grekas) * bug #16953 return ajax collector to collectors.php (NothingWeAre) * bug #16915 [Process] Enhance compatiblity with --enable-sigchild (nicolas-grekas) * bug #16829 [FrameworkBundle] prevent cache:clear creating too long paths (Tobion) * bug #16922 [FrameworkBundle] [Bug] Fixes new InputStyle bug #16920 (AlmogBaku) * bug #16921 Fix short array syntax for php 5.3 (ewgRa) * bug #16450 [Serializer] Fixed `array_unique` on array of objects in `getAllowedAttributes`. (CornyPhoenix) * bug #16757 [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command (jeremyFreeAgent) * bug #16902 [Security] Fix a Polyfill import statement in StringUtils (magnetik) * bug #16871 [FrameworkBundle] Disable built-in server commands when Process component is missing (gnugat, xabbuh) * bug #16870 [FrameworkBundle] Disable the server:run command when Process component is missing (gnugat, xabbuh) * feature #16789 [PhpUnitBridge] Add weak-verbose mode and match against message instead of test name (nicolas-grekas) * minor #16850 [MonologBridge] Added a test case for the Logger class (derrabus) * bug #16796 [Form] Fix choices defined as Traversable (nicolas-grekas) * bug #16742 [Console][ProgressBar] redrawFrequency should never be 0 (dritter) * bug #16846 [MonologBridge] Monolog Bridge 2.8 is incompatible with HttpKernel 3.0 (derrabus) * bug #16816 [Config] Throw an exception when using cannotBeEmpty() with numeric or boolean nodes (Ener-Getick) * bug #16799 Improve error message for undefined DIC aliases (mpdude) * bug #16825 [VarDumper] fix .sf-dump z-index (debug bar conflict) (Antoine LA) * bug #16772 Refactoring EntityUserProvider::__construct() to not do work, cause cache warm error (weaverryan) * bug #16788 Reapply the Yaml bugfix of #16745 (stof) * 3.0.0 (2015-11-30) * bug #16758 Fix BC for the default root form name (stof) * feature #16754 [Security] allow arbitrary types in VoterInterface::vote() (xabbuh) * bug #16753 [Process] Fix signaling/stopping logic on Windows (nicolas-grekas) * feature #16755 [Security] add subject variable to expression context (xabbuh) * bug #16642 [DI][autowiring] throw exception when many services use the same class. (aitboudad) * bug #16745 [Yaml] look for colon in parsed inline string (xabbuh) * bug #16733 [Console] do not encode backslashes in console default description (Tobion) * feature #16735 [WIP] [Ldap] Marked the Ldap component as internal (csarrazi) * bug #16734 Make sure security.role_hierarchy.roles always exists (WouterJ) * feature #16723 [Form] remove deprecated CSRF options (xabbuh) * feature #16725 [Form] Removed useless code (webmozart) * feature #16724 Added getBlockPrefix to FormTypeInterface (WouterJ) * feature #16722 [Security][SecurityBundle] Use csrf_token_id instead of deprecated intention (jakzal) * feature #16727 [Form] remove deprecated getTimezones() method (xabbuh) * bug #16312 [HttpKernel] clearstatcache() so the Cache sees when a .lck file has been released (mpdude) * bug #16351 [WIP] [Form] [TwigBridge] Bootstrap horizontal theme missing tests (pieter2627) * feature #16715 [Form] Remove choices_as_values option on ChoiceType (nicolas-grekas) * feature #16692 [Form] Drop remaining CsrfProviderAdapter/Interface mentions (nicolas-grekas) * feature #16719 [Security] remove deprecated HTTP digest auth key (xabbuh) * bug #16685 [Form] Fixed: Duplicate choice labels are remembered when using "choices_as_values" = false (webmozart) * feature #16709 [Bridge\PhpUnit] Display the stack trace of a deprecation on-demand (nicolas-grekas) * bug #16704 [Form+SecurityBundle] Trigger deprecation for csrf_provider+intention options (nicolas-grekas) * feature #16629 [HttpFoundation] Remove deprecated class method parameter (belka-ew) * feature #16706 [HttpFoundation] Deprecate $deep parameter on ParameterBag (nicolas-grekas) * bug #16705 [Form] Deprecated setting "choices_as_values" to "false" (webmozart) * feature #16690 [Form] Deprecated ArrayKeyChoiceList (webmozart) * feature #16687 [Form] Deprecated TimezoneType::getTimezones() (webmozart) * bug #16681 [Form] Deprecated setting "choices_as_values" to "false" (webmozart) * feature #16694 [SecurityBundle] make ACL an optional dependency (Tobion) * bug #16695 [SecurityBundle] disable the init:acl command if ACL is not used (Tobion) * bug #16677 [Form] Fixed wrong usages of the "text" type (webmozart) * bug #16679 [Form] Disabled view data validation if "data_class" is set to null (webmozart) * bug #16621 [Console] Fix bug with $output overloading (WouterJ) * feature #16601 [Security] Deprecate "AbstractVoter" in favor of "Voter" (nicolas-grekas, lyrixx) * bug #16676 [HttpFoundation] Workaround HHVM rewriting HTTP response line (nicolas-grekas) * bug #16668 [ClassLoader] Fix parsing namespace when token_get_all() is missing (nicolas-grekas) * bug #16615 fix type assignement (rande) * bug #16386 Bug #16343 [Router] Too many Routes ? (jelte) * bug #16498 fix unused variable warning (eventhorizonpl) * feature #16031 [Translation][Form] Do not translate form labels and placeholders when 'translation_domain' is false (Restless-ET) * bug #16651 [Debug] Ensure class declarations are loaded only once (nicolas-grekas) * feature #16637 Removed unneeded polyfill (GrahamCampbell) * security #16631 n/a (xabbuh) * security #16630 n/a (xabbuh) * bug #16633 [Filesystem] Fixed failing test due to tempdir symlink (toretto460) * bug #16607 [HttpFoundation] Delete not existing session handler proxy member (belka-ew) * bug #16609 [HttpKernel] Don't reset on shutdown but in FrameworkBundle/Test/KernelTestCase (nicolas-grekas) * bug #16477 [Routing] Changing RouteCollectionBuilder::import() behavior to add to the builder (weaverryan) * bug #16588 Sent out a status text for unknown HTTP headers. (dawehner) * bug #16295 [DependencyInjection] Unescape parameters for all types of injection (Nicofuma) * bug #16377 [WebProfilerBundle] Fix minitoolbar height (rvanlaak) * bug #16585 Add support for HTTP status code 418 back (dawehner) * bug #16574 [Process] Fix PhpProcess with phpdbg runtime (nicolas-grekas) * bug #16581 Fix call to undefined function json_last_error_message (dawehner) * bug #16573 [FrameworkBundle] Fix PropertyInfo extractor namespace in framework bundle (jvasseur) * bug #16578 [Console] Fix bug in windows detection (kbond) * bug #16546 [Serializer] ObjectNormalizer: don't serialize static methods and props (dunglas) * bug #16352 Fix the server variables in the router_*.php files (leofeyer) * bug #16537 [Validator] Allow an empty path with a non empty fragment or a query (jakzal) * bug #16528 [Translation] Add support for Armenian pluralization. (marcosdsanchez) * bug #16510 [Process] fix Proccess run with pts enabled (ewgRa) * 3.0.0-BETA1 (2015-11-16) * feature #16516 Remove some more legacy code (nicolas-grekas) * feature #11431 [Console] End of options (--) signal support (Seldaek) * feature #16411 [3.0] use ContainerAwareTrait (blanchonvincent, Tobion) * feature #16400 [3.0] [Templating] remove deprecated method (TomasVotruba) * feature #16381 remove polyfills for unsupported php versions (Tobion) * feature #16392 [3.0] [Security] remove deprecated SrtingUtils class (TomasVotruba) * feature #16390 [3.0] [Serializer] JsonEncoder: remove deprecated method (TomasVotruba) * feature #16301 [EventDispatcher] add method getListenerPriority() to interface (xabbuh) * feature #12119 [Console] Add progress indicator helper (kbond) * feature #16203 [Yaml] removed YAML parser \ escaping in double-quotes (fabpot) * feature #16107 [3.0] Various deprecations cleanups (nicolas-grekas) * feature #16125 Replace is_callable checks with type hints (mpajunen, nicolas-grekas) * feature #16076 [HttpFoundation] change precedence of parameters in Request::get (Tobion) * feature #16075 [3.0] Clean Form, Validator, DowCrawler and some more (nicolas-grekas) * feature #16035 [3.0][Security] Remove deprecated features (follow up of #15899) (Koc) * feature #8967 [HttpFoundation] Request->getRequestFormat should only rely on the request attributes (pvandommelen) * feature #16067 [3.0] Remove more deprecated interfaces in Form and Validator (nicolas-grekas) * feature #16020 [CssSelector] removed the deprecated CssSelector class (fabpot) * feature #15196 [HttpKernel] make RequestStack parameter required (Tobion) * feature #16024 [Validator] removed deprecated features in Validator and Form (fabpot) * feature #15900 [3.0][DoctrineBridge] Removed deprecated features (WouterJ) * feature #15904 [3.0][FrameworkBundle] Removed deprecated features (WouterJ) * feature #16019 [HttpFoundation] removed the ParameterBag::get() deep argument (fabpot) * feature #16018 [HttpKernel] removed deprecated profiler storages (fabpot) * feature #15899 [3.0][Security] Remove deprecated features (WouterJ) * feature #15929 [3.0][Config] Remove ResourceInterface::getResource() which was deprecated in 2.8 (mpdude) * feature #15965 [Finder] removed obsolete code (fabpot) * feature #15905 [3.0][Config] Removed isFresh() related functionality (WouterJ) * feature #15936 [Console] remove deprecated shell (Tobion) * feature #10788 [HttpKernel] Add better error message when controller action isn't callable (pierredup) * feature #15868 [Finder] Remove deprecated classes (nicolas-grekas) * feature #15869 [Translation][file dump] remove deprecated format method. (aitboudad) * feature #15801 [WebProfilerBundle][HttpKernel] removed import/export commands (jakzal) * feature #15759 [3.0][Translator] remove deprecated DiffOperation class. (aitboudad) * feature #15684 [Security] Remove deprecated interfaces (nicolas-grekas) * feature #15685 [3.0] Various deprecation removal (nicolas-grekas) * feature #15693 [DI] Remove deprecated scope concept (nicolas-grekas) * feature #15695 [FrameworkBundle] Removed deprecated code paths (nicolas-grekas) * feature #15430 [SecurityBundle] Remove deprecated code (dosten) * feature #15422 [Debug] Remove deprecated ExceptionHandler::createResponse (nicolas-grekas) * feature #15347 [DependencyInjection][3.0] Add initialized to container interface (znerol) * feature #15219 [DependencyInjection] Added ParameterBagInterface::remove (lyrixx) * feature #14927 Removed deprecated stuff from the Config component (dosten) * feature #14693 [3.0][Translator] changed the visibility of the locale from protected to private. (aitboudad) * feature #14979 [Security] removed obsolete translations (fabpot) * feature #14928 Removed deprecated stuff from the Console component (dosten) * feature #14155 Removed deprecations in DependencyInjection component (dosten) * feature #14145 Removed deprecations in Filesystem component (dosten) * feature #14153 Remove the legacy PDO session handler (dosten) * feature #14634 [3.0][HttpKernel] remove deprecated functions and classes (vincentaubert) * feature #14317 [3.0][FrameworkBundle][lint commands ] remove deprecated alias. (vincentaubert) * feature #14220 [3.0][Console][OutputStyle] Implements verbosity levels methods (ogizanagi) * feature #14169 [Debug] Removed deprecated interfaces (nicolas-grekas) * feature #14147 Removed deprecations in Process component (dosten) * feature #14150 Removed deprecations in Templating component (dosten) * feature #14156 Remove deprecated Locale component (stloyd) * feature #14120 Removed deprecation in translation component (saro0h) * feature #14118 Removed deprecations in Console component (saro0h) * feature #14119 Removed deprecation in YAML component (saro0h) * feature #14091 [3.0] [FrameworkBundle] Drop backward compatibility for debug commands (matthieuauger) * feature #14070 removed all *.class parameters (fabpot) * feature #13808 [OptionsResolver] removed deprecated functionality (Tobion) * feature #13756 [3.0][Console] Added type hint (francisbesset) * feature #13752 [PropertyAccess] remove deprecations for 3.0 (Tobion) * feature #13666 removed deprecated asset feature (fabpot) * feature #13407 [Form] Remove deprecated setDefaultOptions and OptionsResolverInterface (peterrehm) * feature #13396 [Routing] remove deprecations for 3.0 (Tobion) * feature #13444 [Serializer] Remove deprecated JSON error methods (dunglas) * feature #13258 [HttpFoundation] remove deprecated : FlashBag don't implement anymore IteratorAggregate (FlorianLB) * feature #13086 [Console] Define isVerbose(), etc. methods in OutputInterface (frne) * feature #13348 [3.0][Monolog] Remove deprecated interface and deprecated methods (rosier) * feature #13260 [3.0][EventDispatcher][Event] removed deprecated methods (aitboudad) * feature #13203 [3.0] [ClassLoader] removed deprecated UniversalClassLoader and DebugClassLoader classes. (hhamon) * feature #13409 removed deprecated Twig features (fabpot) * feature #13233 [TwigBundle] removed deprecated ActionsExtension (fabpot) * feature #12663 [FrameworkBundle] remove deprecated method 'createEsi' (FlorianLB) * feature #13122 [3.0][Form] Removed depracted events PRE_BIND, BIND and POST_BIND (saro0h) * feature #13216 [3.0] [Config] removed deprecated ReferenceDumper class. (hhamon) * feature #12457 [FrameworkBundle] REFS #11294 Controller class become abstract (mickaelandrieu) * feature #12460 [3.0] [FrameworkBundle] removed request service occurrences. (hhamon) * feature #13121 [Console] Removed DialogHelper, ProgressHelper and TableHelper (saro0h) * feature #13127 [FrameworkBundle] Removed the deprecated RouterApacheDumperCommand (saro0h) * feature #13128 [Form] Removed deprecated form_enctype() (saro0h) * feature #13130 [HttpKernel] Removed deprecated ErrorHandler and ExceptionHandler classes (saro0h) * feature #13129 [Yaml] Removed the ability to parse a file in Yaml::parse() (saro0h) * feature #12994 Add LegacyPdoSessionHandler class (jeremylivingston) * feature #13046 [3.0] [Bridge] [Swiftmailer] removed Swiftmailer bridge namespace. (hhamon) * feature #12854 [3.0][HttpKernel] Remove unused method Kernel::isClassInActiveBundle (hacfi) * feature #12697 [3.0][Process] Remove deprecated methods (romainneutron) * feature #12731 [Monolog Bridge] Remove deprecated log methods + add unit tests (FlorianLB) * feature #12461 [HttpKernel] Removed deprecated Kernel::init() method (saro0h) symfony-3.4.6/CHANGELOG-3.1.md000066400000000000000000001107601324732107100153450ustar00rootroot00000000000000CHANGELOG for 3.1.x =================== This changelog references the relevant changes (bug and security fixes) done in 3.1 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.1.0...v3.1.1 * 3.1.9 (2017-01-12) * bug #21218 [Form] DateTimeToLocalizedStringTransformer does not use timezone when using date only (magnetik) * bug #20605 [Ldap] Always have a valid connection when using the EntryManager (bobvandevijver) * bug #21104 [FrameworkBundle] fix IPv6 address handling in server commands (xabbuh) * bug #20793 [Validator] Fix caching of constraints derived from non-serializable parents (uwej711) * bug #19586 [TwigBundle] Fix bug where namespaced paths don't take parent bundles in account (wesleylancel) * bug #21237 [FrameworkBundle] Fix relative paths used as cache keys (nicolas-grekas) * bug #21183 [Validator] respect groups when merging constraints (xabbuh) * bug #21179 [TwigBundle] Fixing regression in TwigEngine exception handling (Bertalan Attila) * bug #21220 [DI] Fix missing new line after private alias (ogizanagi) * bug #21211 Classloader tmpname (lyrixx) * bug #21205 [TwigBundle] fixed usage when Templating is not installed (fabpot) * bug #21155 [Validator] Check cascasdedGroups for being countable (scaytrase) * bug #21200 [Filesystem] Check that directory is writable after created it in dumpFile() (chalasr) * bug #21165 [Serializer] int is valid when float is expected when deserializing JSON (dunglas) * bug #21166 [Cache] Fix order of writes in ChainAdapter (nicolas-grekas) * bug #21113 [FrameworkBundle][HttpKernel] Fix resources loading for bundles with custom structure (chalasr) * bug #21084 [Yaml] handle empty lines inside unindented collection (xabbuh) * bug #20925 [HttpFoundation] Validate/cast cookie expire time (ro0NL) * bug #21032 [SecurityBundle] Made collection of user provider unique when injecting them to the RemberMeService (lyrixx) * bug #21078 [Console] Escape default value when dumping help (lyrixx) * bug #21076 [Console] OS X Can't call cli_set_process_title php without superuser (ogizanagi) * bug #20900 [Console] Descriptors should use Helper::strlen (ogizanagi) * bug #21025 [Cache] remove is_writable check on filesystem cache (4rthem) * bug #21064 [Debug] Wrap call to ->log in a try catch block (lyrixx) * bug #21010 [Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes (SpacePossum) * bug #20991 [cache] Bump RedisAdapter default timeout to 5s (Nicofuma) * bug #20859 Avoid warning in PHP 7.2 because of non-countable data (wouterj) * bug #21053 [Validator] override property constraints in child class (xabbuh) * bug #21034 [FrameworkBundle] Make TemplateController working without the Templating component (dunglas) * bug #20970 [Console] Fix question formatting using SymfonyStyle::ask() (chalasr, ogizanagi) * bug #20999 [HttpKernel] Continuation of #20599 for 3.1 (ro0NL) * bug #20975 [Form] fix group sequence based validation (xabbuh) * bug #20599 [WebProfilerBundle] Display multiple HTTP headers in WDT (ro0NL) * bug #20799 [TwigBundle] do not try to register incomplete definitions (xabbuh) * bug #20961 [Validator] phpize default option values (xabbuh) * bug #20934 [FrameworkBundle] Fix PHP form templates on translatable attributes (ro0NL) * bug #20957 [FrameworkBundle] test for the Validator component to be present (xabbuh) * bug #20936 [DependencyInjection] Fix on-invalid attribute type in xsd (ogizanagi) * bug #20931 [VarDumper] Fix dumping by-ref variadics (nicolas-grekas) * bug #20734 [Security] AbstractVoter->supportsAttribute gives false positive if attribute is zero (0) (martynas-foodpanda) * bug #14082 [config] Fix issue when key removed and left value only (zerustech) * bug #20910 [HttpFoundation] Fix cookie to string conversion for raw cookies (ro0NL) * bug #20847 [Console] fixed BC issue with static closures (araines) * 3.1.8 (2016-12-13) * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr) * bug #20442 [FrameworkBundle] Bundle commands are not available via find() (julienfalque) * bug #20840 [WebProfilerBundle] add dependency on Twig (xabbuh) * bug #20828 [Validator] Fix init of YamlFileLoader::$classes for empty files (nicolas-grekas) * bug #20745 [Validator] add class name to the cache key (Simperfit) * bug #20530 [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize (dunglas) * bug #19141 Throw less misleading exception when property access not found (bramtweedegolf) * bug #20539 Cast result to int before adding to it (alcaeus) * bug #20831 [Twig] Fix deprecations with Twig 1.29 (nicolas-grekas) * bug #20816 [FrameworkBundle] Removed kernel.debug from the cache pool namespace seed (Sander Toonen) * bug #20646 Maintain the selected panel when redirecting to another profile (javiereguiluz) * bug #20767 [Cache] Fix dumping SplDoublyLinkedList iter mode (nicolas-grekas) * bug #20736 [Console] fixed PHP7 Errors when not using Dispatcher (keradus) * bug #20756 [HttpKernel] Regression test for missing controller arguments (iltar) * bug #20755 [HttpKernel] Regression test for missing controller arguments (iltar) * bug #20732 fix the inline level for dumped multi-line strings (xabbuh) * bug #20418 [Form][DX] FileType "multiple" fixes (yceruto) * bug #19902 [DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service. (antanas-arvasevicius) * bug #20704 [Console] Fix wrong handling of multiline arg/opt descriptions (ogizanagi) * bug #20712 [TwigBundle] Fix twig loader registered twice (ogizanagi) * bug #20716 [WebProfilerBundle] Fix dump block is unfairly restrained (ogizanagi) * bug #20671 [Config] ConfigCache::isFresh() should return false when unserialize() fails (nicolas-grekas) * bug #20676 [ClassLoader] Use only forward slashes in generated class map (nicolas-grekas) * bug #20664 [Validator] ensure the proper context for nested validations (xabbuh) * bug #20661 bug #20653 [WebProfilerBundle] Profiler includes ghost panels (jzawadzki) * bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag) * bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb) * bug #20566 [DI] Initialize properties before method calls (ro0NL) * bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129) * bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas) * bug #20600 [Process] Fix process continuing after reached timeout using getIterator() (chalasr) * bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas) * bug #20499 [Doctrine][Form] support large integers (xabbuh) * bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas) * bug #20577 [FrameworkBundle] Mark cache.default_*_provider services private (nicolas-grekas) * 3.1.7 (2016-11-21) * bug #20550 [YAML] Fix processing timestamp strings with timezone (myesain) * bug #20543 [DI] Fix error when trying to resolve a DefinitionDecorator (nicolas-grekas) * bug #20544 [PhpUnitBridge] Fix time-sensitive tests that use data providers (julienfalque) * bug #20484 bumped min version of Twig to 1.28 (fabpot) * bug #20519 [Debug] Remove GLOBALS from exception context to avoid endless recursion (Seldaek) * bug #20455 [ClassLoader] Fix ClassCollectionLoader inlining with __halt_compiler (giosh94mhz) * bug #20307 [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds (LuisDeimos) * bug #20480 [FrameworkBundle] Register the ArrayDenormalizer (dunglas) * bug #20286 [Serializer] Fix DataUriNormalizer's regex (dunglas) * bug #20466 [Translation] fixed nested fallback catalogue using multiple locales. (aitboudad) * bug #20465 [#18637][TranslationDebug] workaround for getFallbackLocales. (aitboudad) * bug #20453 [Cache] Make directory hashing case insensitive (nicolas-grekas) * bug #20440 [TwigBridge][TwigBundle][HttpKernel] prefer getSourceContext() over getSource() (xabbuh) * bug #20287 Properly format value in UniqueEntityValidator (alcaeus) * bug #20422 [Translation][fallback] add missing resources in parent catalogues. (aitboudad) * bug #20378 [Form] Fixed show float values as choice value in ChoiceType (yceruto) * bug #20294 Improved the design of the metrics in the profiler (javiereguiluz) * bug #20375 [HttpFoundation][Session] Fix memcache session handler (klandaika) * bug #20377 [Console] Fix infinite loop on missing input (chalasr) * bug #20372 [Console] simplified code (fabpot) * bug #20342 [Form] Fix UrlType transforms valid protocols (ogizanagi) * bug #20292 Enhance GAE compat by removing some realpath() (nicolas-grekas) * bug #20326 [VarDumper] Fix dumping Twig source in stack traces (nicolas-grekas) * bug #20321 Compatibility with Twig 1.27 (xkobal) * 3.1.6 (2016-10-27) * bug #20291 [Yaml] Fix 7.1 compat (nicolas-grekas) * bug #20289 Fix edge case with StreamedResponse where headers are sent twice (Nicofuma) * bug #20267 [DependencyInjection] A decorated service should not keep the autowiring types (chalasr) * bug #20278 [DependencyInjection] merge tags instead of completely replacing them (xabbuh) * bug #20271 Changes related to Twig 1.27 (fabpot) * bug #20252 Trim constant values in XmlFileLoader (lstrojny) * bug #20239 [HttpKernel] Fix a regression in the RequestDataCollector (jakzal) * bug #20253 [TwigBridge] Use non-deprecated Twig_Node::getTemplateLine() (fabpot) * bug #20243 [WebProfilerBundle][btn-link] add `cursor: pointer` (aitboudad) * bug #20175 [VarDumper] Fix source links with latests Twig versions (nicolas-grekas) * bug #20235 [DomCrawler] Allow pipe (|) character in link tags when using Xpath expressions (klausi, nicolas-grekas) * bug #20224 [Twig] removed deprecations added in Twig 1.27 (fabpot) * bug #19478 fixed Filesystem:makePathRelative and added 2 more testcases (muhammedeminakbulut) * bug #20218 [HttpFoundation] no 304 response if method is not cacheable (xabbuh) * bug #20207 [DependencyInjection] move tags from decorated to decorating service (xabbuh) * bug #20205 [HttpCache] fix: do not cache OPTIONS request (dmaicher) * bug #20146 [Validator] Prevent infinite loop in PropertyMetadata (wesleylancel) * bug #20184 [FrameworkBundle] Convert null prefix to an empty string in translation:update (chalasr) * bug #20154 [PropertyInfo] Fix edge cases in ReflectionExtractor (nicolas-grekas) * bug #19725 [Security] $attributes can be anything, but RoleVoter assumes strings (Jonatan Männchen) * bug #20127 [HttpFoundation] JSONP callback validation (ro0NL) * bug #20163 add missing use statement (xabbuh) * bug #19961 [Console] Escape question text and default value in SymfonyStyle::ask() (chalasr) * bug #20141 [Console] Fix validation of empty values using SymfonyQuestionHelper::ask() (chalasr) * bug #20147 [FrameworkBundle] Alter container class instead of kernel name in cache:clear command (nicolas-grekas) * bug #20156 Fix event annotation for arguments resolving event (Koc) * bug #20152 [HttpKernel] Fix nullable types handling (nicolas-grekas) * 3.1.5 (2016-10-03) * bug #20102 [Validator] Url validator not validating hosts ending in a number (gwkunze) * bug #20132 Use "more entropy" option for uniqid() (javiereguiluz) * bug #20122 [Validator] Reset constraint options (ro0NL) * bug #20116 fixed AddConstraintValidatorsPass config (fabpot) * bug #20078 Fix #19943 Make sure to process each interface metadata only once (lemoinem) * bug #20080 [Form] compound forms without children should be considered rendered implicitly (backbone87) * bug #20087 [VarDumper] Fix PHP 7.1 compat (nicolas-grekas) * bug #20086 [VarDumper] Fix PHP 7.1 compat (nicolas-grekas) * bug #20077 [Process] silent file operation to avoid open basedir issues (xabbuh) * bug #20079 fixed Twig support for 1.26 and 2.0 (fabpot) * bug #20051 Fix indexBy type extraction (lemoinem) * bug #19951 [Finder] Trim trailing directory slash in ExcludeDirectoryFilterIterator (ro0NL) * bug #19980 [Ldap] Fixed issue with legacy find() method not working as expected (csarrazi) * bug #20026 [Cache] Fixed password used to make the redis connection. (ErikSaunier) * bug #20018 [VarDumper] Fix test (nicolas-grekas) * bug #20011 Use UUID for error codes for Form validator. (Koc) * bug #20010 [DX] Fixed regression when exception message swallowed when logging it. (Koc) * bug #19983 [TwigBridge] removed Twig null nodes (deprecated as of Twig 1.25) (fabpot) * bug #19946 [Console] Fix parsing optionnal options with empty value in argv (chalasr) * bug #19636 [Finder] no PHP warning on empty directory iteration (ggottwald) * bug #19784 [HttpKernel] Fixed the nullable support for php 7.1 and below (iltar) * bug #19923 [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level (phansys) * bug #19811 Fixed the nullable support for php 7.1 and below (2.7, 2.8, 3.0) (iltar) * bug #19853 [PropertyInfo] Make ReflectionExtractor compatible with ReflectionType changes in PHP 7.1 (teohhanhui) * bug #19904 [Form] Fixed collapsed ChoiceType options attributes (HeahDude) * bug #19872 [Filesystem] Consider the umask setting when dumping a file (leofeyer) * bug #19908 [Config] Handle open_basedir restrictions in FileLocator (Nicofuma) * bug #19893 [FrameworkBundle] Remove cache clearer default value in config (nicolas-grekas) * bug #19924 [DoctrineBridge][PropertyInfo] Treat Doctrine decimal type as string (teohhanhui) * bug #19932 Fixed bad merge (GrahamCampbell) * bug #19922 [Yaml][TwigBridge] Use JSON_UNESCAPED_SLASHES for lint commands output (chalasr) * bug #19928 [Validator] Update IpValidatorTest data set with a valid reserved IP (jakzal) * bug #19813 [Console] fixed PHP7 Errors are now handled and converted to Exceptions (fonsecas72) * bug #19879 [Form] Incorrect timezone with DateTimeLocalizedStringTransformer (mbeccati) * bug #19878 Fix translation:update command count (tgalopin) * bug #19859 [ClassLoader] Fix ClassCollectionLoader inlining with declare(strict_types=1) (nicolas-grekas) * bug #19780 [FrameworkBundle] Incorrect line break in exception message (500 debug page) (pedroresende) * bug #19595 [form] lazy trans `post_max_size_message`. (aitboudad) * bug #19870 [DI] Fix setting synthetic services on ContainerBuilder (nicolas-grekas) * bug #19848 Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" (nicolas-grekas) * bug #19842 [FrameworkBundle] Check for class existence before is_subclass_of (chalasr) * bug #19827 [BrowserKit] Fix cookie expiration on 32 bit systems (jameshalsall) * 3.1.4 (2016-09-03) * bug #19812 [WebProfilerBundle] Fix margin on toolbar route panel when no route is found in the request (jameshalsall) * bug #19786 Update profiler's layout to use flexbox (javiereguiluz) * bug #19794 [VarDumper] Various minor fixes & cleanups (nicolas-grekas) * bug #19751 Fixes the calendar in constructor to handle null (wakqasahmed) * bug #19743 [symfony/symfony] add "provides" for psr/cache-implementation (alcohol) * bug #19388 [Validator][GroupSequence] fixed GroupSequence validation ignores PropetyMetadata of parent classes (Sandro Hopf) * bug #19729 Add symfony/inflector to composer.json "replaces" (teohhanhui) * bug #19601 [FrameworkBundle] Added friendly exception when constraint validator class does not exist (yceruto) * bug #19580 [Validator] fixed duplicate constraints with parent class interfaces (dmaicher) * bug #19647 [Debug] Swap dumper services at bootstrap (lyrixx) * bug #19685 [DI] Include dynamic services in alternatives (ro0NL) * bug #19702 [Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes (aka "small-bc-breaks") (nicolas-grekas) * bug #19704 [DependencyInjection] PhpDumper::isFrozen inconsistency (allflame) * bug #19643 [DependencyInjection] Fix service autowiring inheritance (chalasr) * bug #19649 [Serializer] Fix denormalization of arrays (dunglas) * bug #19667 [SecurityBundle] Add missing deprecation notice for form_login.intention (ro0NL) * bug #19666 Verify explicitly that the request IP is a valid IPv4 address (nesk) * bug #19660 Disable CLI color for Windows 10 greater than 10.0.10586 (mlocati) * bug #19663 Exception details break the layout (Dionysis Arvanitis) * bug #19651 [HttpKernel] Fix HttpCache validation HTTP method (tgalopin) * bug #19650 [FrameworkBundle] Fix default lifetime of cache pools (nicolas-grekas) * bug #19623 [VarDumper] Fix dumping continuations (nicolas-grekas) * bug #19437 [PropertyInfo] Fix an error in PropertyInfoCacheExtractor (Ener-Getick) * bug #19549 [HttpFoundation] fixed Request::getContent() reusage bug (1ma) * bug #19373 [Form] Skip CSRF validation on form when POST max size is exceeded (jameshalsall) * bug #19541 Fix #19531 [Form] DateType fails parsing when midnight is not a valid time (mbeccati) * bug #19567 [Cache] Handle unserialize() failures gracefully (nicolas-grekas) * bug #19579 [Process] Strengthen Windows pipe files opening (again...) (nicolas-grekas) * bug #19564 Added class existence check if is_subclass_of() fails in compiler passes (SCIF) * bug #19551 [Cache] Use SCAN instead of KEYS with Redis >= 2.8 (nicolas-grekas) * bug #19522 [SwiftMailerBridge] Fix flawed deprecation message (chalasr) * bug #19510 [Process] Fix double-fread() when reading unix pipes (nicolas-grekas) * bug #19508 [Process] Fix AbstractPipes::write() for a situation seen on HHVM (at least) (nicolas-grekas) * bug #19470 undefined offset fix (#19406) (ReenExe) * 3.1.3 (2016-07-30) * bug #19300 [HttpKernel] Use flock() for HttpCache's lock files (mpdude) * bug #19428 [Process] Fix write access check for pipes on Windows (nicolas-grekas) * bug #19442 [Cache] Fix default lifetime being ignored (nicolas-grekas) * bug #19435 [Cache] Fix incorrect timestamps generated by FilesystemAdapter (nicolas-grekas) * bug #19434 [Serializer] enable property info in framework bundle (David Badura) * bug #19439 [DependencyInjection] Fixed deprecated default message template with XML (jeremyFreeAgent) * bug #19397 [HttpFoundation] HttpCache refresh stale responses containing an ETag (maennchen) * bug #19426 [Form] Fix the money form type render with Bootstrap3 (Th3Mouk) * bug #19422 [DomCrawler] Inherit the namespace cache in subcrawlers (stof) * bug #19425 [BrowserKit] Uppercase the "GET" method in redirects (jakzal) * bug #19384 Fix PHP 7.1 related failures (nicolas-grekas) * bug #19379 [VarDumper] Fix for PHP 7.1 (nicolas-grekas) * bug #19342 Added class existence check if is_subclass_of() fails in compiler passes (SCIF) * bug #19369 Fix the DBAL session handler version check for Postgresql (stof) * bug #19368 [VarDumper] Fix dumping jsons casted as arrays (nicolas-grekas) * bug #19334 [Security] Fix the retrieval of the last username when using forwarding (stof) * bug #19352 [Serializer] Include the format in the cache key (dunglas) * bug #19321 [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods (dunglas) * bug #19317 [BrowserKit] Update Client::getAbsoluteUri() for query string only URIs (georaldc) * bug #19298 [ClassLoader] Fix declared classes being computed when not needed (nicolas-grekas) * bug #19316 [Validator] Added additional MasterCard range to the CardSchemeValidator (Dennis Væversted) * bug #19290 [HttpKernel] fixed internal subrequests having an if-modified-since-header (MalteWunsch) * bug #19307 [Security] Fix deprecated usage of DigestAuthenticationEntryPoint::getKey() in DigestAuthenticationListener (Maxime STEINHAUSSER) * bug #19309 [DoctrineBridge] added missing error code for constraint. (Koc) * bug #19306 [Form] fixed bug - name in ButtonBuilder (cheprasov) * bug #19292 [varDumper] Fix missing usage of ExceptionCaster::$traceArgs (nicolas-grekas) * bug #19288 [VarDumper] Fix indentation trimming in ExceptionCaster (nicolas-grekas) * bug #19267 [Validator] UuidValidator must accept a Uuid constraint. (hhamon) * bug #19272 [Security] fixed DebugAccessDecisionManager::setVoters() (HeahDude) * bug #19260 [Form] Fix depreciation triggers (tgalopin) * bug #19186 Fix for #19183 to add support for new PHP MongoDB extension in sessions. (omanizer) * bug #19253 [Console] Fix block() padding formatting after #19189 (chalasr) * bug #19218 [Security][Guard] check if session exist before using it (pasdeloup) * 3.1.2 (2016-06-30) * bug #19227 [DoctrineBridge] fixed default parameter value in UniqueEntityValidator (HeahDude) * bug #18934 Fixed some issues of the AccessDecisionManager profiler (javiereguiluz) * bug #19217 [HttpKernel] Inline ValidateRequestListener logic into HttpKernel (nicolas-grekas) * bug #18688 [HttpFoundation] Warning when request has both Forwarded and X-Forwarded-For (magnusnordlander) * bug #19173 [Console] Decouple SymfonyStyle from TableCell (ro0NL) * bug #19204 [Security] Allow LDAP loadUser override (tucksaun) * bug #19189 [Console] Fix formatting of SymfonyStyle::comment() (chalasr) * bug #19211 [Form] fix post max size translation type extension for >= 2.8 (Tobion) * bug #17822 [WIP] [Form] fix `empty_data` option in expanded `ChoiceType` (HeahDude) * bug #19159 [WebProfilerBundle] Added a conflict for Http-Kernel < 3.1 (HeahDude) * bug #19134 Distinguish between first and subsequent progress bar displays (rquadling) * bug #19061 [FORM] fix post_max_size_message translation (alt. 2) (David Badura) * bug #19100 [Console] Fixed SymfonyQuestionHelper multi-choice with defaults (sstok) * bug #18924 [DoctrineBridge] Don't use object IDs in DoctrineChoiceLoader when passing a value closure (webmozart) * bug #19138 [DomCrawler] No more exception on field name with strange format (guiled, fabpot) * bug #18935 [Form] Consider a violation even if the form is not submitted (egeloen) * bug #19127 [Form] Add exception to FormRenderer about non-unique block names (enumag) * bug #19118 [Process] Fix pipes cleaning on Windows (nicolas-grekas) * bug #19128 Avoid phpunit 5.4 warnings on getMock (2.7+) (iltar) * bug #19120 [FrameworkBundle] templating can be fully disabled (xabbuh) * bug #19114 [HttpKernel] Dont close the reponse stream in debug (nicolas-grekas) * bug #19101 [Session] fix PDO transaction aborted under PostgreSQL (Tobion) * bug #18501 [HttpFoundation] changed MERGE queries (hjkl) * bug #19081 [YAML] Fixed parsing problem with nested DateTime lists (jkphl, xabbuh) * bug #19062 [HttpFoundation] Fix UPSERT for PgSql >= 9.5 (nicolas-grekas) * bug #18548 [Form] minor fixes in DateTime transformers (HeahDude) * bug #18732 [PropertyAccess][DX] Enhance exception that say that some methods are missing if they don't (nykopol) * 3.1.1 (2016-06-15) * bug #19048 [HttpFoundation] Use UPSERT for sessions stored in PgSql >= 9.5 (nicolas-grekas) * bug #19042 [Cache] Fix double fetch in ProxyAdapter (nicolas-grekas) * bug #19038 Fix feature detection for IE (Alsciende) * bug #18915 [DependencyInjection] force enabling the external XML entity loaders (xabbuh) * bug #19020 [Form] Fixed collapsed choice attributes (HeahDude) * bug #19028 [Yaml] properly count skipped comment lines (xabbuh) * bug #19009 [WebProfilerBundle] Fix invalid CSS style (romainneutron) * bug #17733 [Yaml] Fix wrong line number when comments are inserted in the middle of a block. (paradajozsef) * bug #18909 Fixed singular of committee (peterrehm) * bug #18911 Fixed singular of committee (peterrehm) * bug #18971 Do not inject web debug toolbar on attachments (peterrehm) * bug #18944 [Ldap] Fixed issue with legacy client initialisation (csarrazi) * bug #18974 Added missing APCU CacheProvider of doctrine/cache 1.6.x (Carsten Eilers) * bug #18954 [HttpKernel] Fix RequestDataCollector starting the session (romainneutron) * bug #18949 [Security] Fix DebugAccessDecisionManager when object is not a scalar (romainneutron) * bug #18959 [WebProfilerBundle] Fixed forwarded request data in templates (HeahDude) * bug #18943 [Ldap][Security] The Ldap user provider abstract service now has the correct number of arguments (csarrazi) * bug #18925 [Console] Fix BC break introduced by #18101 (dunglas) * bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh) * bug #18893 [DependencyInjection] Skip deep reference check for 'service_container' (RobertMe) * bug #18812 Catch \Throwable (fprochazka) * bug #18821 [Form] Removed UTC specification with timestamp (francisbesset) * bug #18861 Fix for #18843 (inso) * 3.1.0 (2016-05-30) * bug #18889 [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments (chalasr) * bug #18907 [Routing] Fix the annotation loader taking a class constant as a beginning of a class name (jakzal, nicolas-grekas) * bug #18899 [Yaml] search for colons in strings only (xabbuh) * 3.1.0-RC1 (2016-05-26) * bug #18879 [Console] SymfonyStyle: Align multi-line/very-long-line blocks (chalasr) * bug #18881 [Security][Ldap] Fixed issue with password attribute containing an array of values. (csarrazi) * bug #18864 [Console][DX] Fixed ambiguous error message when using a duplicate option shortcut (peterrehm) * bug #18883 Fix js comment in profiler (linnaea) * feature #18867 [Cache] Drop counting hit/miss in ProxyAdapter (nicolas-grekas) * bug #18837 [Serializer] AbstractObjectNormalizer: be sure that isAllowedAttribute is called (dunglas) * bug #18838 [Serializer] ObjectNormalizer: add missing parameters (dunglas) * bug #18844 [Yaml] fix exception contexts (xabbuh) * bug #18840 [Yaml] properly handle unindented collections (xabbuh) * bug #18765 Catch \Throwable (fprochazka) * bug #18813 Catch \Throwable (fprochazka) * bug #18839 People - person singularization (Keeo) * bug #18820 [Config] Allow schemed paths in FileResource (nicolas-grekas) * bug #18828 [Yaml] chomp newlines only at the end of YAML documents (xabbuh) * bug #18814 Fixed server status command when port has been omitted (peterrehm) * bug #18759 [Validator] Support for DateTimeImmutable (krzysiekpiasecki) * bug #18799 Use levenshtein level for better Bundle matching (j0k3r) * bug #18413 [WebProfilerBundle] Fix CORS ajax security issues (romainneutron) * 3.1.0-BETA1 (2016-05-13) * feature #18725 [Ldap] Added the possibility to configure all available Ldap options for connection (csarrazi) * feature #18715 [FrameworkBundle] Default to Apcu+Filesystem cache chain (nicolas-grekas) * feature #18184 [DomCrawler] Expose getter for uri (hason) * feature #18654 [Bridge/Doctrine] Use better exception in the register mapping pass (dantleech) * feature #18676 [HttpKernel] Add request method to logger messages (gnat42) * feature #18716 [Cache] Add nonce based cache invalidation to ApcuAdapter (nicolas-grekas) * feature #18762 [Translation] XLIFF Add `id` to meta data. (SpacePossum) * feature #18689 [Cache] Add support for Predis, RedisArray and RedisCluster (nicolas-grekas) * feature #18667 [FrameworkBundle] Semantic config for app/system/pool caches (tgalopin, nicolas-grekas) * feature #18685 move event listener method type hint docs to @Event annotations defau… (Haehnchen) * feature #18681 [Cache] Add DSN based Redis connection factory (nicolas-grekas) * feature #18656 Updating the error message of an AuthenticationEntryPointInterface (weaverryan) * feature #18069 [DoctrineBridge] deprecate `MergeDoctrineCollectionListener::onBind()` (HeahDude) * feature #18492 [LDAP] Check whether an entry attribute exists (hiddewie) * feature #18359 [Form] [DoctrineBridge] optimized LazyChoiceList and DoctrineChoiceLoader (HeahDude) * feature #18357 [Form] Let `TextType` implement `DataTransformerInterface` (HeahDude) * feature #18631 [FrameworkBundle] Add optional logger to cache pools (nicolas-grekas) * feature #18597 [Cache] Add CacheItem::validateKey utility method (nicolas-grekas) * feature #17660 [Serializer] Integrate the PropertyInfo Component (recursive denormalization and hardening) (mihai-stancu, dunglas) * feature #18561 [FrameworkBundle] Fallback to default cache system in production for serializer (tgalopin) * feature #18567 [FrameworkBundle][Serializer] Fix APC cache service name (tgalopin) * feature #17959 [Serializer] Harden the ObjectNormalizer (dunglas) * feature #18547 DX: better error message if factory class is empty (dbu) * feature #18020 fix #17993 - Deprecated callable strings (hamza) * feature #18487 [Cache] Add DoctrineProvider, for using PSR-6 pools in Doctrine Cache (nicolas-grekas) * feature #18544 [FrameworkBundle] Fallback to default cache system in production for validation (tgalopin) * feature #18416 [FrameworkBundle] Calls support for debug:container (JhonnyL) * feature #18513 [Process] Turn getIterator() args to flags & add ITER_SKIP_OUT/ERR modes (nicolas-grekas) * feature #18371 [FrameworkBundle] integrate the Cache component (xabbuh, nicolas-grekas) * feature #18440 Add the kernel.controller_arguments event (stof) * feature #18308 Added an ArgumentResolver with clean extension point (iltar, HeahDude) * feature #18414 [Process] Implement IteratorAggregate to stream output (nicolas-grekas) * feature #18144 [DI] Only rebuild autowiring cache when actually needed (weaverryan) * feature #18386 [Process] Add InputStream to seamlessly feed running processes (nicolas-grekas) * feature #18167 [DependencyInjection] Fix a limitation of the PhpDumper (Ener-Getick) * feature #18387 [DX] [LDAP] Added default service name for the Security component's Ldap providers (csarrazi) * feature #18290 [Translation] deprecate the backup feature (xabbuh) * feature #18036 [Serializer] XmlEncoder: Make load flags configurable (dunglas) * feature #17589 [WebProfilerBundle] [DX] Feature allow forward and redirection detection in wdt (HeahDude) * feature #18260 Add Inflector component (from StringUtil of PropertyAccess) (teohhanhui) * feature #18356 [FrameworkBundle] Deprecated form types as services (HeahDude) * feature #17458 Add strict image validation (Koc) * feature #18350 [Process] Accept Traversable input (nicolas-grekas) * feature #18135 [Security] Deprecate onAuthenticationSuccess() (weaverryan) * feature #18294 [Yaml] dump non UTF-8 encoded strings as binary data (xabbuh) * feature #18215 [Cache] Add a Chain adapter (dunglas, nicolas-grekas) * feature #18242 [FrameworkBundle][TwigBundle] Make EngineInterface autowirable (dunglas) * feature #18197 Make Request::isFromTrustedProxy() public. (Peter Bex) * feature #18211 [Security] Use auth trust resolver to determine anonymous in ContextListener (WouterJ) * feature #18232 [Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER (nicolas-grekas) * feature #18181 [PhpUnitBridge] Mock DNS functions (nicolas-grekas) * feature #18176 [Cache] Restrict flushes to namespace scopes (nicolas-grekas) * feature #18172 [Cache] Redis adapter (gcds, nicolas-grekas) * feature #18101 [Console] Allow to register commands privately (Ener-Getick) * feature #18143 [DomCrawler] Exposed getter for baseHref (AAstakhov) * feature #18034 [FrameworkBundle] Deprecate absolute template paths (jakzal) * feature #18105 [HttpFoundation] Add support for sending raw cookies in the response (jakzal) * feature #17255 [Console] ApplicationTester - test stdout and stderr (SpacePossum) * feature #18024 [Cache] Add namespace handling to all adapters (nicolas-grekas) * feature #17734 [Cache] Count cache hits/misses in ProxyAdapter (nicolas-grekas) * feature #17887 Show more information in the security profiler (javiereguiluz) * feature #17642 [FrameworkBundle] [DX] Add `Controller::json` method to make it easy to send json (mcfedr) * feature #17484 [FrameworkBundle][DX] Add Levenshtein suggesters to AbstractConfigCommand (kix) * feature #17690 [FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency (Ener-Getick) * feature #17714 Adding new TargetPathTrait to get/set the authentication "target_path" (weaverryan) * feature #17852 Improved the logger panel when the log context is very long (javiereguiluz) * feature #17761 [Console] Add non-auto column width functionality (akeeman) * feature #17943 [Yaml] option to dump multi line strings as scalar blocks (xabbuh) * feature #17553 [Validator] Added a format option to the DateTime constraint. (dosten) * feature #17728 [Yaml] add option to dump objects as maps (xabbuh) * feature #17863 [Yaml] add support for parsing the !!binary tag (xabbuh) * feature #17738 [PropertyAccess] Throw an InvalidArgumentException when the type do not match (dunglas) * feature #17531 [PropertyInfo] Use last version of reflection docblock (joelwurtz) * feature #17782 Support autowiring for Doctrine\Common\Annotations\Reader (maryo) * feature #17603 [Serializer] Add a normalizer that support JsonSerializable objects (mcfedr) * feature #17630 [FrameworkBundle] Register the DateTimeNormalizer (dunglas) * feature #17631 [FrameworkBundle] Register the DataUriNormalizer (dunglas) * feature #17545 [Serializer] Add normalizer / denormalizer awarness (joelwurtz) * feature #17877 [DependencyInjection] Improving autowiring error messages (weaverryan) * feature #17732 [DEPRECATION] : deprecated support for Traversable in method ResizeFormListener::PreSubmit (ybensacq) * feature #17721 [Cache] Add FilesystemAdapter (nicolas-grekas) * feature #17836 [Yaml] support to parse and dump DateTime objects (xabbuh) * feature #17809 [Yaml] deprecate starting plain scalars with characters (xabbuh) * feature #17817 [Ldap] Add write support for the Ldap component (csarrazi) * feature #17560 [Ldap] Improving the LDAP component (csarrazi) * feature #17726 [FrameworkBundle] Improve debug:container command (voronkovich) * feature #17743 [Yaml] dumper flag for enabling exceptions on invalid type (xabbuh) * feature #17746 [Yaml] deprecate the Dumper::setIndentation() method (xabbuh) * feature #17730 [Yaml] introduce flags to customize the parser behavior (xabbuh) * feature #17125 Webprofiler add status code to search form (oktapodia) * feature #17705 [TwigBridge] deprecate the boolean object support trigger (xabbuh) * feature #17578 [Yaml] dump customization option with dumper flags (xabbuh) * feature #17585 [DomCrawler] Abstract URI logic and crawl images (valeriangalliat) * feature #17654 [Cache] Don't clone, serialize (nicolas-grekas) * feature #16947 [FrameworkBundle] PropertyInfo: register the SerializerExtractor (dunglas) * feature #17611 [HttpKernel] Deprecate passing objects as URI attributes to the ESI and SSI renderers (jakzal) * feature #14288 [Console] Add getters for Application::$autoExit and $catchExceptions (VasekPurchart) * feature #17504 [Console] Show code when an exception is thrown (maidmaid) * feature #17540 [WebProfilerBundle] Add HTTP return code in the Ajax request list table (kucharovic) * feature #17446 [Serializer] Add PSR-6 adapter (dunglas) * feature #16917 [PropertyInfo] Cache support (dunglas) * feature #17532 [Asset] Version as service (ewgRa) * feature #17440 [Validator] Add a PSR-6 adapter (dunglas) * feature #17113 [Serializer] Add a MaxDepth option (dunglas) * feature #17530 [Cache] Handle and log errors properly (nicolas-grekas) * feature #17522 [Cache] Use generator in ArrayAdapter (gcds) * feature #16164 [Serializer] Add a data: URI normalizer (dunglas) * feature #15279 Added {{ value }} message placeholder to UniqueEntityValidator (jperovic) * feature #16652 [console] Add truncate method to FormatterHelper (mheki) * feature #17438 [Cache] Allow and use generators in AbstractAdapter (nicolas-grekas) * feature #17111 [HttpKernel] added a setter for the headers property in the HttpException (smatyas) * feature #17132 [DependencyInjection] Properly ignore invalid reference arguments in collection arguments (ogizanagi) * feature #17427 [Process] Allow a callback whenever the output is disabled (romainneutron) * feature #17327 Added support links to exception and toolbar (peterrehm) * feature #16909 Allows access to payload in callback validator (conradkleinespel) * feature #17402 [Profiler] make it possible to omit the link var (xabbuh) * feature #17411 [Serializer] Add a new DateTime normalizer (dunglas) * feature #17462 [Yaml] deprecate parsing the !!php/object tag (xabbuh) * feature #17408 [Cache] Symfony PSR-6 implementation (nicolas-grekas) * feature #17323 [DependencyInjection] Deprecate unsupported attributes/elements for alias (Ener-Getick) * feature #17305 [VarDumper] Add flags to allow fine tuning dumps representation (nicolas-grekas) * feature #17318 [HttpFoundation] Allow to get all the mime types associated to a format in the Request (Ener-Getick) * feature #17133 [DependencyInjection] Make YamlFileLoader raise a deprecation notice if a service definition contains unsupported keywords. (hhamon) * feature #17191 [Serializer] Move the normalization logic in an abstract class (dunglas) * feature #16994 [Form] Deprecate the "choices_as_values" option of ChoiceType (nicolas-grekas) symfony-3.4.6/CHANGELOG-3.2.md000066400000000000000000001437711324732107100153560ustar00rootroot00000000000000CHANGELOG for 3.2.x =================== This changelog references the relevant changes (bug and security fixes) done in 3.2 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.2.0...v3.2.1 * 3.2.13 (2017-08-01) * bug #22244 [Console] Fix passing options with defaultCommand (Jakub Sacha) * bug #23684 [Debug] Missing escape in debug output (c960657) * bug #23654 [DI] Fix using private services in expressions (nicolas-grekas) * bug #23662 [VarDumper] Adapt to php 7.2 changes (nicolas-grekas) * bug #23649 [Form][TwigBridge] Don't render _method in form_rest() for a child form (fmarchalemisys) * bug #23023 [DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables (vudaltsov) * bug #23619 [Validator] Fix IbanValidator for ukrainian IBANs (paroe) * bug #23586 Fix case sensitive sameSite cookie (mikefrancis) * bug #23238 [Security] ensure the 'route' index is set before attempting to use it (gsdevme) * bug #23330 [WebProfilerBundle] Fix full sized dump hovering in toolbar (ogizanagi) * bug #23580 Fix login redirect when referer contains a query string (fabpot) * bug #23558 [FrameworkBundle] fix ValidatorCacheWarmer: use serializing ArrayAdapter (dmaicher) * bug #23574 [VarDumper] Move locale sniffing to dump() time (nicolas-grekas) * 3.2.12 (2017-07-17) * bug #23549 [PropertyInfo] conflict for phpdocumentor/reflection-docblock 3.2 (xabbuh) * security #23507 [Security] validate empty passwords again (xabbuh) * bug #23526 [HttpFoundation] Set meta refresh time to 0 in RedirectResponse content (jnvsor) * bug #23540 Disable inlining deprecated services (alekitto) * bug #23468 [DI] Handle root namespace in service definitions (ro0NL) * bug #23256 [Security] Fix authentication.failure event not dispatched on AccountStatusException (chalasr) * bug #23461 Use rawurlencode() to transform the Cookie into a string (javiereguiluz) * bug #23459 [TwigBundle] allow to configure custom formats in XML configs (xabbuh) * bug #23460 Don't display the Symfony debug toolbar when printing the page (javiereguiluz) * bug #23469 [FrameworkBundle] do not wire namespaces for the ArrayAdapter (xabbuh) * bug #23417 [DI][Security] Prevent unwanted deprecation notices when using Expression Languages (dunglas) * bug #23261 Fixed absolute url generation for query strings and hash urls (alexander-schranz) * bug #23398 [Filesystem] Dont copy perms when origin is remote (nicolas-grekas) * 3.2.11 (2017-07-05) * bug #23390 [Cache] Handle APCu failures gracefully (nicolas-grekas) * bug #23378 [FrameworkBundle] Do not remove files from assets dir (1ed) * 3.2.10 (2017-07-04) * bug #23366 [FrameworkBundle] Don't get() private services from debug:router (chalasr) * bug #23341 [DoctrineBridge][Security][Validator] do not validate empty values (xabbuh) * bug #23274 Display a better error design when the toolbar cannot be displayed (yceruto) * bug #23296 [WebProfilerBundle] Fix css trick used for offsetting html anchor from fixed header (ogizanagi) * bug #23333 [PropertyAccess] Fix TypeError discard (dunglas) * bug #23326 [Cache] fix cleanup of expired items for PdoAdapter (dmaicher) * bug #23345 [Console] fix description of INF default values (xabbuh) * bug #23299 [Workflow] Added more events to the announce function (Nyholm) * bug #23279 Don't call count on non countable object (pierredup) * bug #23283 [TwigBundle] add back exception check (xabbuh) * bug #23268 Show exception is checked twice in ExceptionController of twig (gmponos) * bug #23266 Display a better error message when the toolbar cannot be displayed (javiereguiluz) * bug #23271 [FrameworkBundle] allow SSI fragments configuration in XML files (xabbuh) * bug #23254 [Form][TwigBridge] render hidden _method field in form_rest() (xabbuh) * bug #23250 [Translation] return fallback locales whenever possible (xabbuh) * bug #23240 [Console] Fix catching exception type in QuestionHelper (voronkovich) * bug #23229 [WebProfilerBundle] Eliminate line wrap on count column (routing) (e-moe) * bug #22732 [Security] fix switch user _exit without having current token (dmaicher) * bug #22730 [FrameworkBundle] Sessions: configurable "use_strict_mode" option for NativeSessionStorage (MacDada) * bug #23195 [FrameworkBundle] [Command] Clean bundle directory, fixes #23177 (NicolasPion) * bug #23052 [TwigBundle] Add Content-Type header for exception response (rchoquet) * bug #23199 Reset redirectCount when throwing exception (hvanoch) * bug #23186 [TwigBundle] Move template.xml loading to a compiler pass (ogizanagi) * bug #23130 Keep s-maxage when expiry and validation are used in combination (mpdude) * bug #23129 Fix two edge cases in ResponseCacheStrategy (mpdude) * feature #22636 [Routing] Expose request in route conditions, if needed and possible (ro0NL) * bug #22636 [Routing] Expose request in route conditions, if needed and possible (ro0NL) * bug #22943 [SecurityBundle] Move cache of the firewall context into the request parameters (GromNaN) * bug #23057 [Translation][FrameworkBundle] Fix resource loading order inconsistency reported in #23034 (mpdude) * bug #23092 [Filesystem] added workaround in Filesystem::rename for PHP bug (VolCh) * bug #23128 [HttpFoundation] fix for Support for new 7.1 session options (vincentaubert) * bug #23176 [VarDumper] fixes (nicolas-grekas) * bug #23100 [PropertyAccess] Do not silence TypeErrors from client code. (tsufeki) * bug #23156 [PropertyAccess] Fix Usage with anonymous classes (mablae) * bug #23091 [Cache] ApcuAdapter::isSupported() should return true when apc.enable_cli=Off (nicolas-grekas) * bug #22953 #22839 - changed debug toolbar dump section to relative and use full window width (mkurzeja) * bug #23086 [FrameworkBundle] Fix perf issue in CacheClearCommand::warmup() (nicolas-grekas) * bug #23098 Cache ipCheck (2.7) (gonzalovilaseca) * bug #23069 [SecurityBundle] Show unique Inherited roles in profile panel (yceruto) * bug #23073 [TwigBridge] Fix namespaced classes (ogizanagi) * bug #23063 [Cache] Fix extensibility of TagAwareAdapter::TAGS_PREFIX (wucdbm) * bug #22936 [Form] Mix attr option between guessed options and user options (yceruto) * bug #22976 [DependencyInjection] Use more clear message when unused environment variables detected (voronkovich) * bug #23045 [Cache] fix Redis scheme detection (xabbuh) * bug #22988 [PropertyInfo][DoctrineBridge] The bigint Doctrine's type must be converted to string (dunglas) * bug #23014 Fix optional cache warmers are always instantiated whereas they should be lazy-loaded (romainneutron) * bug #23024 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null) (nicolas-grekas) * bug #22996 [Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 (romainneutron) * bug #22994 Harden the debugging of Twig filters and functions (stof) * 3.2.9 (2017-05-29) * bug #22847 [Console] ChoiceQuestion must have choices (ro0NL) * bug #22900 [FrameworkBundle][Console] Fix the override of a command registered by the kernel (aaa2000) * bug #22910 [Filesystem] improve error handling in lock() (xabbuh) * bug #22924 [Cache] Dont use pipelining with RedisCluster (nicolas-grekas) * bug #22718 [Console] Fixed different behaviour of key and value user inputs in multiple choice question (borNfreee) * bug #22829 [Yaml] fix colon without space deprecation (xabbuh) * bug #22901 Fix missing abstract key in XmlDumper (weaverryan) * bug #22912 [DI] Avoid private call to Container::has() (ro0NL) * bug #22866 [DI] Check for privates before shared services (ro0NL) * bug #22874 [WebProfilerBundle] Fix sub-requests display in time profiler panel (nicolas-grekas) * bug #22817 [PhpUnitBridge] optional error handler arguments (xabbuh) * bug #22752 Improved how profiler errors are displayed on small screens (javiereguiluz) * bug #22715 [FrameworkBundle] remove Security deps from the require section (xabbuh) * bug #22647 [VarDumper] Fix dumping of non-nested stubs (nicolas-grekas) * bug #22409 [Yaml] respect inline level when dumping objects as maps (goetas, xabbuh) * bug #22584 [Security] Avoid unnecessary route lookup for empty logout path (ro0NL) * bug #22690 [Console] Fix errors not rethrown even if not handled by console.error listeners (chalasr) * bug #22669 [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice (ogizanagi) * bug #22676 [FrameworkBundle] Adding the extension XML (flug) * bug #22652 [Workflow] Move twig extension registration to twig bundle (ogizanagi) * 3.2.8 (2017-05-01) * bug #22550 Allow Upper Case property names in ObjectNormalizer (insekticid) * bug #22528 [Asset] Starting slash should indicate no basePath wanted (weaverryan) * bug #22568 [EventDispatcher] fix getting priorities of listeners during dispatch (dmaicher) * bug #22541 [EventDispatcher] fix: unwrap listeners for correct info (dmaicher) * bug #22526 [Asset] Preventing the base path or absolute URL from being prefixed incorrectly (weaverryan) * bug #22523 [WebProfilerBundle] Fixed the flickering when loading complex profiler panels (javiereguiluz) * bug #21958 [Console] Fix bar width with multilines ProgressBar's format (maidmaid) * bug #22435 [Console] Fix dispatching throwables from ConsoleEvents::COMMAND (nicolas-grekas) * bug #22478 [Serializer] XmlEncoder: fix negative int and large numbers handling (dunglas) * bug #22424 [Debug] Set exit status to 255 on error (nicolas-grekas) * bug #22426 [PropertyInfo] Prevent returning int values in some cases (dunglas) * bug #22401 Prevent double registrations related to tag priorities (nicolas-grekas) * bug #22399 Prevent double registrations related to tag priorities (nicolas-grekas) * bug #22396 Prevent double registrations related to tag priorities (nicolas-grekas) * bug #22374 [Cache] Remove exception false-positive from FilesystemAdapterTrait (nicolas-grekas) * bug #22377 [Console] Allow terminal dimensions to be set to 0 (unbounded) (duncan3dc) * bug #22352 [HttpFoundation] Add `use_strict_mode` in validOptions for session (sstok) * bug #22351 [Yaml] don't keep internal state between parser runs (xabbuh) * bug #22304 Moved $this->setDate() before the deprecation handling. (mpdonadio) * bug #22307 [Debug] Fix php notice (enumag) * bug #22311 [DI] Fix second auto-registration (nicolas-grekas) * bug #22109 [Validator] check for empty host when calling checkdnsrr() (apetitpa) * bug #22280 [DI] Fix the xml schema (GuilhemN) * bug #22282 [DI] Prevent AutowirePass from triggering irrelevant deprecations (chalasr) * bug #22255 [Translation] avoid creating cache files for fallback locales. (aitboudad) * bug #22292 Fixes #22264 - add support for Chrome headless (redthor) * 3.2.7 (2017-04-05) * bug #22285 [HttpKernel] Fix forward compat with Request::setTrustedProxies() (nicolas-grekas) * bug #22265 Allow Upper Case property names (insekticid) * bug #22258 [DI] Autowiring and factories are incompatible with each others (nicolas-grekas) * bug #22254 [DI] Don't use auto-registered services to populate type-candidates (nicolas-grekas) * bug #22229 [ExpressionLanguage] Provide the expression in syntax errors (k0pernikus, stof) * bug #22251 [PropertyInfo] Support nullable array or collection (4rthem) * bug #22240 [DI] Fix fatal error at ContainerBuilder::compile() if config is not installed (chalasr) * bug #22140 [Form] Improve the exceptions when trying to get the data in a PRE_SET_DATA listener and the data has not already been set (fancyweb) * bug #22217 [Console] Fix table cell styling (ro0NL) * bug #22194 [Console] CommandTester: disable color support detection (julienfalque) * bug #22188 [Console] Revised exception rendering (ro0NL) * bug #22154 [WebProfilerBundle] Normalize whitespace in exceptions passed in headers (curry684) * bug #22183 [Process] Fix bug which wiped or mangled env vars (pjcdawkins) * bug #22142 [Console] Escape exception messages in renderException (chalasr) * bug #22172 Fix port usage in server:status command (alcaeus) * bug #22164 [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite (nicolas-grekas) * bug #22159 [FrameworkBundle] Cache pool clear command requires at least 1 pool (ro0NL) * bug #22133 [Filesystem] normalize paths before making them relative (xabbuh) * bug #22138 [HttpFoundation][bugfix] $bags should always be initialized (MacDada) * bug #21810 #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile (Antanas Arvasevicius) * bug #22123 [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page (e-moe) * bug #19778 [Security] Fixed roles serialization on token from user object (eko) * bug #22036 Set Date header in Response constructor already (mpdude) * bug #22022 [Validator] fix URL validator to detect non supported chars according to RFC 3986 (e-moe) * bug #21849 [HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header (nicolas-grekas) * bug #21968 Fixed pathinfo calculation for requests starting with a question mark. (syzygymsu) * bug #22027 Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)" (chalasr) * bug #21846 [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST (nicolas-grekas) * bug #21208 [Validator] Add object handling of invalid constraints in Composite (SenseException) * bug #22044 [Serializer] [XML] Ignore Process Instruction (jordscream) * bug #22090 [WebProfilerBundle] Fix Content-Security-Policy compatibility in case of a `style-src 'self'` policy (romainneutron) * bug #22079 [HttpKernel] Fixed bug with purging of HTTPS URLs (ausi) * bug #22045 [WebProfilerBundle] Handle Content-Security-Policy-Report-Only header correctly (romainneutron) * bug #21523 #20411 fix Yaml parsing for very long quoted strings (RichardBradley) * bug #22001 [Doctrine Bridge] fix priority for doctrine event listeners (dmaicher) * bug #22040 [FrameworkBundle] improve message when workflows are missing (xabbuh) * bug #22032 [FrameworkBundle] Fix translation dep constraint (chalasr) * bug #21996 [Cache] Enhance error reporting for FilesystemAdapter (nicolas-grekas) * bug #21981 [Console] Use proper line endings in BufferedOutput (julienfalque) * bug #21976 [VarDumper] Add missing isset() checks in some casters (nicolas-grekas) * bug #21973 [VarDumper] Add missing isset() checks in some casters (nicolas-grekas) * bug #21957 [Form] Choice type int values (BC Fix) (mcfedr) * 3.2.6 (2017-03-10) * bug #21930 [Cache] Cached files rely on umask (4rthem) * bug #21946 Use PHPUnit 5.4 instead of 5.3 (j0k3r) * bug #21936 [PropertyAccess] Use ArrayAdapter in debug mode (chalasr) * 3.2.5 (2017-03-09) * bug #21923 [travis] Test with hhvm 3.18 (nicolas-grekas) * bug #21793 [Workflow] Fixed marking state on leave and enter events (HeahDude) * bug #21912 [Yaml] dump escape sequences when possible (xabbuh) * bug #21908 [Cache] Fix Redis pipelining/multi-ops (nicolas-grekas) * bug #21823 dumpFile(), preserve existing file permissions (chs2) * bug #21880 [Form] Fixed overridden choices option in extended choice types (HeahDude) * bug #21896 [PHPunitBridge] Count @expectedDeprecation as an assertion (wouterj) * bug #21865 [Security] context listener: hardening user provider handling (xabbuh) * bug #21883 [HttpKernel] fix Kernel name when stored in a directory starting with a number (fabpot) * bug #21841 [Console] Do not squash input changes made from console.command event (chalasr) * bug #21481 [Form] Fixed empty conversion of Intl types (HeahDude) * bug #21671 [Serializer] Xml encoder throws exception for valid data (gr1ev0us) * bug #21805 Provide less state in getRequestFormat (dawehner) * bug #21851 Adding use statement for InvalidArgumentException (Nyholm) * bug #21832 [Routing] Ignore hidden directories when loading routes from annotations (jakzal) * bug #21769 [Form] Improve rounding precision (foaly-nr1) * bug #21825 [PhpUnitBridge] disable global test listener when not registered (xabbuh) * bug #21267 [Form] Fix ChoiceType to ensure submitted data is not nested unnecessarily (issei-m) * bug #21813 Update phpstorm helper to the official format (pierredup) * bug #21731 Fix emacs link (rubenrua) * bug #21802 Fix issues reported by static analyse (romainneutron) * bug #21800 Fix issues reported by static analyze (romainneutron) * bug #21782 [DependencyInjection] add missing dumped private services list in a container frozen constructor. (hhamon) * bug #21798 Revert "bug #21791 [SecurityBundle] only pass relevant user provider (xabbuh)" (xabbuh) * bug #21791 [SecurityBundle] only pass relevant user provider (xabbuh) * bug #21776 [Process] Fix ignoring of bad env var names (nicolas-grekas) * bug #21787 [PhpUnitBridge] do not register the test listener twice (xabbuh) * bug #21756 [Yaml] Stop replacing NULLs when merging (gadelat) * bug #21689 [WebServerBundle] fixed html attribute escape (Seb33300) * bug #21722 [ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported (maidmaid) * bug #21679 [SecurityBundle] fix priority ordering of security voters (xabbuh) * bug #21656 [DoctrineBridge] Fixed validating custom doctrine type columns (dmaicher) * bug #21115 [Validator] do not guess getter method names (xabbuh) * bug #21670 [DependencyInjection] Fix autowiring types when there are more than 2 services colliding (GuilhemN) * bug #21665 [DependencyInjection] Fix autowiring collisions detection (nicolas-grekas, GuilhemN) * bug #21661 Fix Composer constraints (fabpot) * bug #21582 [HttpCache] purge both http and https from http cache (dbu) * bug #21637 [FrameworkBundle] remove translation data collector when not usable (xabbuh) * bug #21647 [Yaml] consistently parse omitted keys as the colon (xabbuh) * 3.2.4 (2017-02-16) * bug #21634 [VarDumper] Added missing persistent stream cast (lyrixx) * bug #21436 [DependencyInjection] check for circular refs caused by method calls (xabbuh) * bug #21400 [Serializer] fix upper camel case conversion (see #21399) (markusu49) * bug #21599 [Console][Table] fixed render when using multiple rowspans. (aitboudad) * bug #21613 [Process] Permit empty suffix on Windows (Bilge) * bug #21057 [DI] Auto register extension configuration classes as a resource (ro0NL) * bug #21607 Improve tracking of environment variables in the case of private services (tgalopin) * bug #21592 [Validator] property constraints can be added in child classes (angelk, xabbuh) * bug #21458 [Config] Early return for DirectoryResource (robfrawley) * bug #21562 [DoctrineBridge] make sure that null can be the invalid value (xabbuh) * bug #21556 [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap (nicolas-grekas) * bug #21584 [WebProfilerBundle] Readd Symfony version status in the toolbar (wouterj) * bug #21557 [VarDumper] Improve dump of AMQP* Object (lyrixx) * bug #21579 [Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry (csarrazi) * bug #21552 [FrameworkBundle] Fix annotations cache folder path (akeeman) * bug #21542 [VarDumper] Fixed dumping of terminated generator (lyrixx) * bug #21292 Ignore missing 'debug.file_link_formatter' service in Debug bundle (core23) * 3.2.3 (2017-02-06) * bug #21528 [Cache] Fix class exists checks in PhpArrayAdapter (nicolas-grekas) * bug #20844 [Config] Fix checking cache for non existing meta file (hason) * bug #21063 [Form] Fixed DateType format option for single text widget (HeahDude) * bug #21430 Casting TableCell value to string. (jaydiablo) * bug #21359 [FrameworkBundle] fixed custom domain for translations in php templates (robinlehrmann) * bug #21485 [Process] Non ASCII characters disappearing during the escapeshellarg (GuillaumeVerdon) * bug #21370 [FrameworkBundle] Execute the PhpDocExtractor earlier (GuilhemN) * bug #21462 [BrowserKit] ignore invalid cookies expires date format (xabbuh) * bug #21438 [Console] Fix TableCell issues with decoration (ogizanagi) * bug #21431 [DoctrineBridge] always check for all fields to be mapped (xabbuh) * bug #21360 [PropertyAccess] Handle interfaces in the invalid argument exception (fancyweb) * bug #21403 [DI] Fix defaults overriding empty strings in AutowirePass (nicolas-grekas) * bug #21401 [Debug] Workaround "null" $context (nicolas-grekas) * bug #21381 [FrameworkBundle] Dont wire "annotations.cached_reader" before removing passes (nicolas-grekas) * bug #21387 Fix double escaping of the decision attributes in the profiler (stof) * bug #21372 [DependencyInjection] Fixed variadic method parameter in autowired classes (brainexe) * bug #21338 [Cache] Fix tags expiration (nicolas-grekas) * bug #21333 [HttpKernel] Fix ArgumentValueResolver for arguments default null (chalasr) * bug #20871 [HttpKernel] Give higher priority to adding request formats (akeeman) * bug #21332 [PropertyInfo] Don't try to access a property thru a static method (dunglas) * bug #21336 [PhpUnit] Blacklist DeprecationErrorHandler in stack traces (nicolas-grekas) * bug #21331 [PropertyInfo] Exclude static methods form properties guessing (dunglas) * bug #21280 [Workflow] Fixed support of multiple transitions with the same name. (lyrixx) * bug #21271 [Workflow] Added new validator to make sure each place has unique translation names (Nyholm) * bug #21323 [Cache] [PdoAdapter] Fix MySQL 1170 error (blob as primary key) (akeeman) * bug #21318 Don't add csp-headers if none are required (arjenm) * bug #21291 [Ldap] Ldap username case fix (quentinus95) * bug #21311 [Debug] Fix fatal error when changing ErrorHandler loggers if an exception is buffered (skalpa) * bug #21288 [Doctrine Bridge] fix UniqueEntityValidator for composite object primary keys (dmaicher, HeahDude) * bug #21285 [TwigBundle] do not lose already set method calls (xabbuh) * bug #21279 #20411 fix Yaml parsing for very long quoted strings (RichardBradley) * bug #21276 [Cache] Fix missing use statement in FilesystemAdapter (Lctrs) * bug #21269 [Cache] Using strpbrk() instead of strcspn() is faster (nicolas-grekas) * 3.2.2 (2017-01-12) * bug #21257 [Profiler][Form] Fix form profiler errors profiler_dump (ogizanagi) * bug #21243 [FrameworkBundle] Fix class_exists() checks in PhpArrayAdapter-related cache warmers (nicolas-grekas, mpajunen) * bug #21218 [Form] DateTimeToLocalizedStringTransformer does not use timezone when using date only (magnetik) * bug #20605 [Ldap] Always have a valid connection when using the EntryManager (bobvandevijver) * bug #21104 [FrameworkBundle] fix IPv6 address handling in server commands (xabbuh) * bug #20793 [Validator] Fix caching of constraints derived from non-serializable parents (uwej711) * bug #19586 [TwigBundle] Fix bug where namespaced paths don't take parent bundles in account (wesleylancel) * bug #21237 [FrameworkBundle] Fix relative paths used as cache keys (nicolas-grekas) * bug #21183 [Validator] respect groups when merging constraints (xabbuh) * bug #21179 [TwigBundle] Fixing regression in TwigEngine exception handling (Bertalan Attila) * bug #21220 [DI] Fix missing new line after private alias (ogizanagi) * bug #21211 Classloader tmpname (lyrixx) * bug #21205 [TwigBundle] fixed usage when Templating is not installed (fabpot) * bug #21155 [Validator] Check cascasdedGroups for being countable (scaytrase) * bug #21200 [Filesystem] Check that directory is writable after created it in dumpFile() (chalasr) * bug #21186 [Bridge/PhpUnit] Relax expectedDeprecation for forward compat (nicolas-grekas) * bug #21184 [FrameworkBundle] Remove Response* from classes to compile (nicolas-grekas) * bug #21165 [Serializer] int is valid when float is expected when deserializing JSON (dunglas) * bug #21167 [Cache] Remove silenced warning tiggered by PhpArrayAdapter (nicolas-grekas) * bug #21166 [Cache] Fix order of writes in ChainAdapter (nicolas-grekas) * bug #21113 [FrameworkBundle][HttpKernel] Fix resources loading for bundles with custom structure (chalasr) * bug #20995 [DependencyInjection] Fix the priority order of compiler pass trait (francoispluchino) * bug #21084 [Yaml] handle empty lines inside unindented collection (xabbuh) * bug #21143 [PhpUnitBridge] Set COMPOSER_ROOT_VERSION while installing (nicolas-grekas) * bug #20925 [HttpFoundation] Validate/cast cookie expire time (ro0NL) * bug #21138 [PhpUnitBridge] skip tests with failure and error states too (xabbuh) * bug #21135 [PhpUnitBridge] hide stack trace of expected deprecation failures (xabbuh) * bug #21117 [Yaml] add missing indicator character (xabbuh) * bug #21121 [PhpUnitBridge] respect skipped and incomplete tests (xabbuh) * bug #21032 [SecurityBundle] Made collection of user provider unique when injecting them to the RemberMeService (lyrixx) * bug #21078 [Console] Escape default value when dumping help (lyrixx) * bug #21076 [Console] OS X Can't call cli_set_process_title php without superuser (ogizanagi) * bug #20900 [Console] Descriptors should use Helper::strlen (ogizanagi) * bug #21025 [Cache] remove is_writable check on filesystem cache (4rthem) * bug #21064 [Debug] Wrap call to ->log in a try catch block (lyrixx) * bug #21069 [Debug] Fixed cast of stream (lyrixx) * bug #21010 [Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes (SpacePossum) * bug #20991 [cache] Bump RedisAdapter default timeout to 5s (Nicofuma) * bug #20959 [FrameworkBundle] Ignore AnnotationException exceptions in the AnnotationsCacheWarmer (fancyweb) * bug #20795 [FrameworkBundle] Allow multiple transitions with the same name (Padam87) * bug #20859 Avoid warning in PHP 7.2 because of non-countable data (wouterj) * bug #21053 [Validator] override property constraints in child class (xabbuh) * bug #21034 [FrameworkBundle] Make TemplateController working without the Templating component (dunglas) * bug #20970 [Console] Fix question formatting using SymfonyStyle::ask() (chalasr, ogizanagi) * bug #20999 [HttpKernel] Continuation of #20599 for 3.1 (ro0NL) * bug #20975 [Form] fix group sequence based validation (xabbuh) * bug #20599 [WebProfilerBundle] Display multiple HTTP headers in WDT (ro0NL) * bug #20799 [TwigBundle] do not try to register incomplete definitions (xabbuh) * bug #20961 [Validator] phpize default option values (xabbuh) * bug #20934 [FrameworkBundle] Fix PHP form templates on translatable attributes (ro0NL) * bug #20957 [FrameworkBundle] test for the Validator component to be present (xabbuh) * bug #20936 [DependencyInjection] Fix on-invalid attribute type in xsd (ogizanagi) * bug #20931 [VarDumper] Fix dumping by-ref variadics (nicolas-grekas) * bug #20749 [FrameworkBundle] Smarter default for framework.annotations (ogizanagi) * bug #20734 [Security] AbstractVoter->supportsAttribute gives false positive if attribute is zero (0) (martynas-foodpanda) * bug #14082 [config] Fix issue when key removed and left value only (zerustech) * bug #20910 [HttpFoundation] Fix cookie to string conversion for raw cookies (ro0NL) * bug #20909 Fix misresolved parameters in debug:config on 3.2 (chalasr) * bug #20904 [TwigBundle] Config is now a hard dependency (dunglas) * bug #20847 [Console] fixed BC issue with static closures (araines) * 3.2.1 (2016-12-13) * bug #20891 Add support for REDIS_URL environment variables. (robinvdvleuten) * bug #20724 [WebProfilerBundle] Fix AJAX panel with fetch requests (OnekO) * bug #20883 Don’t compile when Opcache is not enabled on CLI (ruudk) * bug #20877 DateIntervalType: 'invert' should not inherit the 'required' option (galeaspablo) * bug #20886 [Form] DateIntervalType: Do not try to translate choices (ogizanagi) * bug #20855 [Yaml] do not trigger deprecations for valid YAML (xabbuh) * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr) * bug #20862 Allow simple-phpunit to be used with an HTTP proxy (Cydonia7) * bug #20882 [TwigBridge] fix constructor args check (xabbuh) * bug #20860 [WebProfilerBundle] Fix a web profiler form issue with fields added to the form after the form was built (tgalopin) * bug #20442 [FrameworkBundle] Bundle commands are not available via find() (julienfalque) * bug #20840 [WebProfilerBundle] add dependency on Twig (xabbuh) * bug #20833 [HttpKernel] Fix open_basedir compat in DataCollector (nicolas-grekas) * bug #20828 [Validator] Fix init of YamlFileLoader::$classes for empty files (nicolas-grekas) * bug #20688 [FrameworkBundle] Resolve env params in debug:config command (nicolas-grekas) * bug #20725 [HttpKernel] Fix annotation cache warmer with failing or missing classes (nicolas-grekas) * bug #20830 [FrameworkBundle] Fix validation cache warmer with failing or missing classes (nicolas-grekas) * bug #20760 [FrameworkBundle] [Workflow] Fix service marking store configuration (fduch) * bug #20745 [Validator] add class name to the cache key (Simperfit) * bug #20530 [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize (dunglas) * bug #19141 Throw less misleading exception when property access not found (bramtweedegolf) * bug #20539 Cast result to int before adding to it (alcaeus) * bug #20831 [Twig] Fix deprecations with Twig 1.29 (nicolas-grekas) * bug #20701 Ignore missing 'debug.file_link_formatter' service in Debug and Twig bundles (mbabker) * bug #20816 [FrameworkBundle] Removed kernel.debug from the cache pool namespace seed (Sander Toonen) * bug #20769 [Bridge\Twig] Trigger deprecation when using FormExtension::$renderer (nicolas-grekas) * bug #20646 Maintain the selected panel when redirecting to another profile (javiereguiluz) * bug #20767 [Cache] Fix dumping SplDoublyLinkedList iter mode (nicolas-grekas) * bug #20690 [Serializer] Fix argument object denormalization (ogizanagi) * bug #20762 [Form] Fix FormDataCollector (nicolas-grekas, Padam87) * bug #20747 [HttpKernel] Fixed RequestDataCollector handling of null header values. (Gabriel Moreira) * bug #20727 [TwigBundle] Inject project root path into twig filesystem loader (4rthem) * bug #20736 [Console] fixed PHP7 Errors when not using Dispatcher (keradus) * bug #20756 [HttpKernel] Regression test for missing controller arguments (iltar) * bug #20755 [HttpKernel] Regression test for missing controller arguments (iltar) * bug #20732 fix the inline level for dumped multi-line strings (xabbuh) * bug #20418 [Form][DX] FileType "multiple" fixes (yceruto) * bug #19902 [DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service. (antanas-arvasevicius) * bug #20704 [Console] Fix wrong handling of multiline arg/opt descriptions (ogizanagi) * bug #20700 [WebProfilerBundle][Translator] Fix TranslationDataCollector should use cloneVar (ogizanagi) * bug #20712 [TwigBundle] Fix twig loader registered twice (ogizanagi) * bug #20716 [WebProfilerBundle] Fix dump block is unfairly restrained (ogizanagi) * bug #20717 Fix hide button in toolbar (nicolasdewez) * 3.2.0 (2016-11-30) * bug #20687 [FrameworkBundle] Forbid env parameters in routing configuration (nicolas-grekas) * bug #20607 [Validator] Bring egulias/email-validator ~2.0 to parity with ~1.2 (Lctrs) * bug #20671 [Config] ConfigCache::isFresh() should return false when unserialize() fails (nicolas-grekas) * bug #20679 [VarDumper] Use default color for ellipsed namespaces/paths (nicolas-grekas) * bug #20676 [ClassLoader] Use only forward slashes in generated class map (nicolas-grekas) * bug #20664 [Validator] ensure the proper context for nested validations (xabbuh) * bug #20661 bug #20653 [WebProfilerBundle] Profiler includes ghost panels (jzawadzki) * bug #20652 Fixed getRouteParams() when no parameters are available (wouterj) * 3.2.0-RC2 (2016-11-27) * bug #20601 [FrameworkBundle] Don't rely on any parent definition for "cache.annotations" (nicolas-grekas) * bug #20638 Fix legacy tests that do not trigger any depreciation (julienfalque) * bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag) * bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb) * bug #20616 [Bridge/Doctrine] Use cache.prefix.seed parameter for generating cache namespace (nicolas-grekas) * bug #20566 [DI] Initialize properties before method calls (ro0NL) * bug #20583 [Workflow] Fixed graphviz dumper for state machine (lyrixx) * bug #20621 [HttpKernel] Fix exception when serializing request attributes (nicolas-grekas) * bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129) * bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas) * bug #20600 [Process] Fix process continuing after reached timeout using getIterator() (chalasr) * bug #20603 [HttpKernel] Deprecate checking for cacheable HTTP methods in Request::isMethodSafe() (nicolas-grekas) * bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas) * bug #20610 [FrameworkBundle] Add framework.cache.prefix_seed for predictible cache key prefixes (nicolas-grekas) * bug #20595 [WebProfilerBundle] Fix deprecated uses of profiler_dump (nicolas-grekas) * bug #20589 [SecurityBundle] Fix FirewallConfig nullable arguments (ogizanagi) * bug #20590 [DI] Allow null as default env value (sroze) * bug #20499 [Doctrine][Form] support large integers (xabbuh) * bug #20559 [FrameworkBundle] Avoid warming up the validator cache for non-existent class (Seldaek) * bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas) * bug #20577 [FrameworkBundle] Mark cache.default_*_provider services private (nicolas-grekas) * bug #20550 [YAML] Fix processing timestamp strings with timezone (myesain) * bug #20543 [DI] Fix error when trying to resolve a DefinitionDecorator (nicolas-grekas) * bug #20544 [PhpUnitBridge] Fix time-sensitive tests that use data providers (julienfalque) * 3.2.0-RC1 (2016-11-17) * feature #20533 [DI] Revert "deprecate get() for uncompiled container builders" (nicolas-grekas) * bug #20525 [TwigBundle] Give some love to exception pages (nicolas-grekas) * bug #20484 bumped min version of Twig to 1.28 (fabpot) * bug #20512 [DI] Fix accepting null as default env param value (nicolas-grekas) * bug #20519 [Debug] Remove GLOBALS from exception context to avoid endless recursion (Seldaek) * bug #20455 [ClassLoader] Fix ClassCollectionLoader inlining with __halt_compiler (giosh94mhz) * bug #20307 [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds (LuisDeimos) * bug #20432 [FrameworkBundle] Add --no-prefix option to translation:update (chalasr) * bug #20480 [FrameworkBundle] Register the ArrayDenormalizer (dunglas) * bug #20286 [Serializer] Fix DataUriNormalizer's regex (dunglas) * bug #20466 [Translation] fixed nested fallback catalogue using multiple locales. (aitboudad) * bug #20465 [#18637][TranslationDebug] workaround for getFallbackLocales. (aitboudad) * bug #20453 [Cache] Make directory hashing case insensitive (nicolas-grekas) * bug #20428 [TwigBundle] fixed template root path (fabpot) * feature #20447 [DI] Force env params to be string|null (nicolas-grekas) * feature #20451 [Workflow] Added Definition builder (Nyholm) * bug #20460 [FrameworkBundle] Fixed WorkflowCommand to support state machines (HeahDude) * bug #20440 [TwigBridge][TwigBundle][HttpKernel] prefer getSourceContext() over getSource() (xabbuh) * feature #19629 [Workflow] Make the Workflow support State Machines (Nyholm, lyrixx) * bug #20287 Properly format value in UniqueEntityValidator (alcaeus) * bug #20422 [Translation][fallback] add missing resources in parent catalogues. (aitboudad) * bug #20378 [Form] Fixed show float values as choice value in ChoiceType (yceruto) * feature #20416 [Bridge\Monolog][FrameworkBundle] Add & wire a DebugProcessor (nicolas-grekas) * bug #20415 [DI][Serializer] Add missing deprecations (nicolas-grekas) * bug #20294 Improved the design of the metrics in the profiler (javiereguiluz) * bug #20375 [HttpFoundation][Session] Fix memcache session handler (klandaika) * bug #20377 [Console] Fix infinite loop on missing input (chalasr) * feature #20232 [DependencyInjection] fixed ini file values conversion (fabpot) * feature #19490 [SecurityBundle] Integrate current firewall in Profiler (chalasr) * feature #19398 [DX][SecurityBundle] Introduce a FirewallConfig class accessible from FirewallContext (chalasr) * bug #20336 [HttpKernel] Base DataCollector throws warning on unsupported scheme strings (ogizanagi) * bug #20335 [Yaml] Fix String offset cast error in Inline parser (romainneutron) * bug #20372 [Console] simplified code (fabpot) * bug #20342 [Form] Fix UrlType transforms valid protocols (ogizanagi) * bug #20341 Fix YamlReferenceDumper unnamed nested prototypes (ogizanagi) * bug #20292 Enhance GAE compat by removing some realpath() (nicolas-grekas) * bug #20325 [VarDumper] Fix source links to Twig files (nicolas-grekas) * bug #20328 [Console] Fix empty COLUMNS/LINES env vars (nicolas-grekas) * bug #20326 [VarDumper] Fix dumping Twig source in stack traces (nicolas-grekas) * bug #20321 Compatibility with Twig 1.27 (xkobal) * 3.2.0-BETA1 (2016-10-27) * feature #19973 Added a default ide file link web view (jeremyFreeAgent) * feature #20285 [TwigBundle] made Twig cache independent of the project root directory (fabpot) * feature #20266 [Console] rename Command::private to Command::hidden (xabbuh) * feature #20270 [PhpUnitBridge] Drop ErrorAssert (nicolas-grekas) * feature #20256 [PhpUnitBridge] Allow configuring removed deps and phpunit versions (nicolas-grekas) * feature #20255 [PhpUnitBridge] Replace ErrorAssert by `@expectedDeprecation` (nicolas-grekas) * feature #20047 [Form] Change FormTypeGuesserChain to accept Traversable (enumag) * feature #19982 [Validator] Allow validating multiple groups in one GroupSequence step (enumag) * feature #19741 [ExpressionLanguage] Making cache PSR6 compliant (Alexandre GESLIN) * feature #20217 [Serializer] Support specifying format for DateTimeNormalizer::denormalize (teohhanhui) * feature #19452 Remove the new SecurityUserValueResolver (weaverryan) * feature #15002 [DoctrineBridge] Add a way to select the repository used by the UniqueEntity validator (ogizanagi) * feature #20113 Use the method map as authoritative list of factories for dumped containers (stof) * feature #19576 [WebProfiler] added support for window.fetch calls in ajax section (ivoba) * feature #19991 [TwigBridge] Added access to token from twig AppVariable (HeahDude) * feature #20029 Hide commands from ApplicationDescriptor, but allow invoking (jwdeitch, Jordan Deitch) * feature #20121 Class existence resource (fabpot) * feature #20119 [TwigBundle] changed the runtime loader to return null if there is no match (fabpot) * feature #20093 Twig extensions refatoring to decouple definitions from implementations (fabpot) * feature #20094 added Twig runtimes for "critical" Twig extensions (fabpot) * feature #20097 [FrameworkBundle] removed the Doctrine Annotations lib dependency on FrameworkBundle (fabpot) * feature #20019 [FrameworkBundle] Add phpstorm ide (hason) * feature #20092 added a Twig runtime loader (fabpot) * feature #20075 [FrameworkBundle] removed the Security Core and Security CSRF component dependencies on FrameworkBundle (fabpot) * feature #20072 [FrameworkBundle] removed the Templating component dependency on FrameworkBundle (fabpot) * feature #20070 [FrameworkBundle] removed the Translation component dependency on FrameworkBundle (fabpot) * feature #20067 [FrameworkBundle] removed the Asset component dependency on FrameworkBundle (fabpot) * feature #20037 [Cache] Handle arbitrary key length when the backend cant using hashing (nicolas-grekas) * feature #20040 [Bridge/PhpUnit] Handle native E_DEPRECATED (nicolas-grekas) * feature #19987 [VarDumper] Use ClassStub for reflected types (nicolas-grekas) * feature #20012 [Translation] added Base Exception for the component. (aitboudad) * feature #19996 removed obsolete images (since 2.2) (fabpot) * feature #19997 inlined some CSS (fabpot) * feature #19304 [Yaml] fix parsing multi-line mapping values (xabbuh) * feature #19191 [DependencyInjection] Automatically detect the definitions class when possible (Ener-Getick) * feature #19745 [Validator] Added context object method callback to choice validator (Peter Bouwdewijn) * feature #19614 [HttpKernel] Use VarDumper in the profiler (wouterj, nicolas-grekas) * feature #19480 [Config] Fix (Yaml|Xml)ReferenceDumper for nested prototypes (ogizanagi) * feature #19681 [DI] Allow injecting ENV parameters at runtime using env(MY_ENV_VAR) (nicolas-grekas) * feature #19197 [Serializer][FrameworkBundle] Add a CSV encoder (dunglas) * feature #19257 [Validator][Choice] Make strict the default option for choice validation (peterrehm) * feature #19326 [Serializer][FrameworkBundle] Add a YAML encoder (dunglas) * feature #19484 [PropertyInfo] Extract the logic converting a php doc to a Type (Ener-Getick) * feature #19495 [master][console] Allow multiple options to be set. (SpacePossum) * feature #19584 [DependencyInjection] Improve ParameterNotFoundException when accessing a nested parameter (wouterj) * feature #19485 [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter (tgalopin) * feature #19790 [FrameworkBundle] add support for prioritizing form type extension tags (dmaicher) * feature #19507 [FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter (tgalopin) * feature #19734 [HttpFoundation] Deprecate extending some methods (Ener-Getick) * feature #19795 Replace count with a given number out of the box (bocharsky-bw) * feature #19807 [FrameworkBundle] Add debug.file_link_format with remapping for IDE links (nicolas-grekas) * feature #19891 [FrameworkBundle] Add cache:pool:clear command (nicolas-grekas) * feature #19900 [FrameworkBundle] Add CachePoolClearerPass for weak cache pool refs in cache clearers (nicolas-grekas) * feature #19570 [Config] Fix YamlReferenceDumper prototyped array support (ogizanagi) * feature #19824 [Console] Add ability to regress the ProgressBar (jameshalsall) * feature #19892 [DI] Add corresponding service id in some exception messages (nicolas-grekas) * feature #19843 [Security] Allow run-time configuration of hash algo (nicolas-grekas) * feature #19894 [Cache] Add "persistent_id" option to RedisAdapter::createConnection() (nicolas-grekas) * feature #19915 [Bridge/PhpUnit] Add bin/simple-phpunit wrapper (=phpunit - yaml - prophecy) (nicolas-grekas) * feature #19826 [VarDumper] Add ClassStub for clickable & shorter PHP identifiers (nicolas-grekas) * feature #19816 [VarDumper] Add LinkStub to create links in HTML dumps (nicolas-grekas) * feature #19768 [VarDumper] Enhance dumping arguments in stack traces (nicolas-grekas) * feature #19796 [VarDumper] Make the line clickable to toggle dumps (nicolas-grekas) * feature #19764 [Config] Add ExprBuilder::ifEmpty() (ogizanagi) * feature #19797 [VarDumper] Handle attributes in Data clones for more semantic dumps (nicolas-grekas) * feature #19755 [VarDumper] Get dump as string with `$dumper->dump(..., true);` (nicolas-grekas) * feature #19604 [Routing] Add seamless support for unicode requirements (nicolas-grekas) * feature #19714 [VarDumper] Handle "title" attribute on virtual properties (nicolas-grekas) * feature #19687 [FrameworkBundle] Use relative paths in templates paths cache (tgalopin) * feature #19339 [WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors (yceruto) * feature #19519 [Cache] Add PDO + Doctrine DBAL adapter (nicolas-grekas) * feature #19672 [VarDumper] Allow dumping subparts of cloned Data structures (nicolas-grekas) * feature #19657 [VarDumper] Add line in trace indexes (nicolas-grekas) * feature #19639 [Routing] Generate URLs in compliance with PHP_QUERY_RFC3986 (jameshalsall) * feature #19568 [Debug] Better error handling (lyrixx) * feature #19552 [HttpFoundation] Add named constructor on JsonResponse (tyx) * feature #19630 [VarDumper] Enhance dumping __PHP_Incomplete_Class objects (nicolas-grekas) * feature #19515 [Cache] Drop TaggedCacheItemInterface (nicolas-grekas) * feature #19511 Use a dedicated exception in the file locator (leofeyer) * feature #19529 Add Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates (Alex Pott) * feature #19473 [Security] Expose the required roles in AccessDeniedException (Nicofuma) * feature #19524 [Cache] Add generic TagAwareAdapter wrapper (replaces TagAwareRedisAdapter) (nicolas-grekas) * feature #19504 [Yaml] deprecate missing space after mapping key colon (xabbuh) * feature #19430 [DomCrawler] Add support for XPath expression evaluation (jakzal) * feature #19205 [HttpKernel] Allow bundles to declare classes and annotated classes to compile using patterns (tgalopin) * feature #18533 [FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations (tgalopin) * feature #17498 [Filesystem] Add a cross-platform readlink method (tgalopin) * feature #19289 [VarDumper] Dumping exceptions is now more compact (nicolas-grekas) * feature #19276 [ClassLoader] Add ClassCollectionLoader::inline() to generate inlined-classes files (nicolas-grekas) * feature #19325 [FrameworkBundle] Allow to specify a domain when updating translations (antograssiot) * feature #19277 [Serializer] Argument objects (theofidry, dunglas) * feature #19322 [HttpFoundation] Add Request::isMethodIdempotent method (dunglas) * feature #18510 Added a SecurityUserValueResolver for controllers (iltar) * feature #19203 [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service (nicolas-grekas) * feature #19236 [FrameworkBundle] Deprecate the service serializer.mapping.cache.doctrine.apc (Ener-Getick) * feature #19174 [FrameworkBundle] Show server:run logs by default (nicolas-grekas) * feature #19137 [Serializer] Allow to use easily static constructors (Ener-Getick) * feature #19146 [DependencyInjection] deprecate access to private shared services. (hhamon) * feature #19190 [DependencyInjection] Add support for short services configurators syntax (voronkovich) * feature #18823 [Cache] Add PhpArrayAdapter to use shared memory on PHP 7.0 (tgalopin) * feature #18948 [VarDumper] Add maxDepth & maxStringLength display options (MGDSoft, nicolas-grekas) * feature #18626 [Yaml] Added support for parsing PHP constants (HeahDude) * feature #19104 Adds support for the SameSite attribute in cookies. (iangcarroll) * feature #19153 [Validator] support egulias/email-validator 2.x (xabbuh) * feature #11394 [Routing] support for array values in route defaults (xabbuh) * feature #11882 [Workflow] Introducing the workflow component (fabpot, lyrixx) * feature #19151 [VarDumper] Add support for XmlReader objects (Taluu) * feature #18471 [Console] Add Lockable trait (geoffrey-brier) * feature #19139 [FrameworkBundle][Yaml] Move YamlLintCommand to the Yaml component (chalasr) * feature #19143 Response headers fix (fabpot) * feature #16809 [Form][FrameworkBundle][Bridge] Add a DateInterval form type (MisatoTremor) * feature #18466 [Bridge][Twig] Optionally pass dumper into DumpExtension (CarsonF) * feature #18022 [DependencyInjection] Sort the CompilerPass by priority (Ener-Getick) * feature #19090 [Console] Add ConsoleLogger::hasErrored() (nicolas-grekas) * feature #19079 [Debug] Do not quote numbers in stack trace (c960657) * feature #19012 [Console] progress bar fix (TomasVotruba, fabpot) * feature #19047 [Cache] Add tags based invalidation + TagAwareRedisAdapter (nicolas-grekas) * feature #17644 Deprecate using Form::isValid() with an unsubmitted form (Ener-Getick) * feature #12979 [Router] added appending of new optional document fragment (rodnaph) * feature #18710 [Console] Simplify simulation of user inputs in CommandTester (chalasr) * feature #18999 [Console] Centralize input stream in base Input class (chalasr) * feature #19060 [ExpressionLanguage] Add a way to hook on each node when dumping the AST (nicolas-grekas) * feature #18880 [PhpUnitBridge] add a triggered errors assertion helper (xabbuh) * feature #16906 [Console] Better support for one command app (lyrixx) * feature #17203 Move Constraint validator test case to Test namespace (WouterJ) * feature #18502 [FrameworkBundle] Add file helper to Controller (dfridrich) * feature #19053 [Process] Allow inheriting env vars instead of replacing them (nicolas-grekas) * feature #18833 [HttpKernel] Move duplicated logic from Esi/Ssi to an AbstractSurrogate (chalasr) * feature #18220 Don't send default cache header for 301 redirects (e-moe) * feature #17662 [Translation][transChoice] allows escaping the pipe character. (aitboudad) * feature #18322 [DomCrawler] Attach label to form fields (carlosV2) * feature #18482 Created a trait to sort tagged services (iltar) * feature #15458 [Filesystem] Add feature to create hardlinks for files (andrerom) * feature #18940 [Console] Add path argument to dump a specific option in debug:config (chalasr) * feature #19013 [ExpressionLanguage] Added a way to dump the AST (lyrixx) * feature #18332 [Form] added `CallbackChoiceLoader` and refactored ChoiceType's children (HeahDude) * feature #18869 [Routing] Throw exception when PHP start tag is missing (WouterJ) * feature #18781 [Console] Display errors in quiet mode (multi-io) * feature #19011 [HttpKernel] Add convenient method ArgumentResolver:: getDefaultArgumentValueResolvers (romainneutron) * feature #18568 [WebProfilerBundle] Fix bundle usage in Content-Security-Policy context without unsafe-inline (romainneutron) * feature #16838 [PropertyAccess] Add PSR-6 cache (dunglas) * feature #18790 [Console] Show aliases in command description instead of in different lines in application description (juanmirod) * feature #18728 deprecate get() for uncompiled container builders (xabbuh) * feature #18483 [Serializer] Deprecate SerializerAwareEncoder (JhonnyL) * feature #18337 [PropertyInfo] Support singular adder and remover (dunglas) * feature #18894 [Cache] Added PhpFilesAdapter (trakos, nicolas-grekas) * feature #18964 [PhpUnitBridge] Make DnsMock match namespaces that begin with Tests\\ (teohhanhui) * feature #18726 [PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\ (teohhanhui) * feature #18825 [Cache] Create NullAdapter to disable cache if needed (tgalopin) * feature #18675 [VarDumper] Add Redis caster (nicolas-grekas) * feature #18785 [Yaml] deprecate comma separators in floats (xabbuh) * feature #18486 [Yaml] Allow using _ in some numeric notations (Taluu) symfony-3.4.6/CHANGELOG-3.3.md000066400000000000000000001660241324732107100153530ustar00rootroot00000000000000CHANGELOG for 3.3.x =================== This changelog references the relevant changes (bug and security fixes) done in 3.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.3.0...v3.3.1 * 3.3.15 (2018-01-05) * bug #25532 [HttpKernel] Disable CSP header on exception pages (ostrolucky) * bug #25491 [Routing] Use the default host even if context is empty (sroze) * bug #25672 [WebServerBundle] use interface_exists instead of class_exists (kbond) * bug #25662 Dumper shouldn't use html format for phpdbg / cli-server (jhoff) * bug #25529 [Validator] Fix access to root object when using composite constraint (ostrolucky) * bug #25430 Fixes for Oracle in PdoSessionHandler (elislenio) * bug #25599 Add application/ld+json format associated to json (vincentchalamon) * bug #25623 [HttpFoundation] Fix false-positive ConflictingHeadersException (nicolas-grekas) * bug #25624 [WebServerBundle] Fix escaping of php binary with arguments (nicolas-grekas) * bug #25567 [Process] Fix setting empty env vars (nicolas-grekas) * bug #25407 [Console] Commands with an alias should not be recognized as ambiguous (Simperfit) * bug #25523 [WebServerBundle] fix a bug where require would not require the good file because of env (Simperfit) * bug #25559 [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions (nicolas-grekas) * bug #25552 [WebProfilerBundle] Let fetch() cast URL to string (ro0NL) * bug #25521 [Console] fix a bug when you are passing a default value and passing -n would output the index (Simperfit) * bug #25489 [FrameworkBundle] remove esi/ssi renderers if inactive (dmaicher) * bug #25427 Preserve percent-encoding in URLs when performing redirects in the UrlMatcher (mpdude) * bug #25480 [FrameworkBundle] add missing validation options to XSD file (xabbuh) * bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit) * bug #25425 When available use AnnotationRegistry::registerUniqueLoader (jrjohnson) * bug #24594 [Translation] Fix InvalidArgumentException when using untranslated plural forms from .po files (BjornTwachtmann) * bug #25233 [TwigBridge][Form] Fix hidden currency element with Bootstrap 3 theme (julienfalque) * bug #25413 [HttpKernel] detect deprecations thrown by container initialization during tests (nicolas-grekas) * bug #25408 [Debug] Fix catching fatal errors in case of nested error handlers (nicolas-grekas) * bug #25330 [HttpFoundation] Support 0 bit netmask in IPv6 (`::/0`) (stephank) * bug #25378 [VarDumper] Fixed file links leave blank pages when ide is configured (antalaron) * bug #25410 [HttpKernel] Fix logging of post-terminate errors/exceptions (nicolas-grekas) * bug #25417 [Process] Dont rely on putenv(), it fails on ZTS PHP (nicolas-grekas) * bug #25333 [DI] Impossible to set an environment variable and then an array as container parameter (Phantas0s) * bug #25438 [Yaml] empty lines don't count for indent detection (xabbuh) * bug #25389 [Yaml] fix some edge cases with indented blocks (xabbuh) * bug #25340 [Serializer] Unset attributes when creating child context (dunglas) * bug #25323 [ExpressionLanguage] throw an SyntaxError instead of an undefined index notice (Simperfit) * bug #25364 [DependencyInjection] Prevent a loop in aliases within the `findDefinition` method (sroze) * 3.3.14 (2017-12-04) * bug #25304 [Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argv (ricknox) * bug #25308 [FrameworkBundle] Fix a bug where a color tag will be shown when passing an antislash (Simperfit) * bug #25278 Fix for missing whitespace control modifier in form layout (kubawerlos) * bug #25305 [Form][TwigBridge] Fix collision between view properties and form fields (yceruto) * bug #25236 [Form][TwigBridge] Fix collision between view properties and form fields (yceruto) * bug #25312 [DI] Fix deep-inlining of non-shared refs (nicolas-grekas) * bug #25309 [Yaml] parse newlines in quoted multiline strings (xabbuh) * bug #25241 [Yaml] do not eagerly filter comment lines (xabbuh) * bug #25258 [link] Prevent warnings when running link with 2.7 (dunglas) * bug #24750 [Validator] ExpressionValidator should use OBJECT_TO_STRING (Simperfit) * bug #25232 [WebProfilerBundle] [TwigBundle] Fix Profiler breaking XHTML pages (tistre) * bug #25209 [VarDumper] Dont use empty(), it chokes on eg GMP objects (nicolas-grekas) * bug #25200 [HttpKernel] Arrays with scalar values passed to ESI fragment renderer throw deprecation notice (Simperfit) * bug #25217 [Dotenv] Changed preg_match flags from null to 0 (deekthesqueak) * bug #25203 [DI] Fix infinite loop in InlineServiceDefinitionsPass (nicolas-grekas) * bug #25185 [Serializer] Do not cache attributes if `attributes` in context (sroze) * bug #25182 [HttpFoundation] AutExpireFlashBag should not clear new flashes (Simperfit, sroze) * bug #25179 [FrameworkBundle][Serializer] Remove YamlEncoder definition if Yaml component isn't installed (ogizanagi) * bug #25163 [DI] Fix tracking of env vars in exceptions (nicolas-grekas) * bug #25152 [Form] Don't rely on `Symfony\Component\HttpFoundation\File\File` if http-foundation isn't in FileType (issei-m) * bug #24987 [Console] Fix global console flag when used in chain (Simperfit) * bug #25146 [DI] Dont resolve envs in service ids (nicolas-grekas) * bug #25113 [Routing] Fix "config-file-relative" annotation loader resources (nicolas-grekas, sroze) * bug #25109 Make debug:container search command case-insensitive (jzawadzki) * bug #25043 [Yaml] added ability for substitute aliases when mapping is on single line (Michał Strzelecki, xabbuh) * bug #25102 [Form] Fixed ContextErrorException in FileType (chihiro-adachi) * bug #25130 [DI] Fix handling of inlined definitions by ContainerBuilder (nicolas-grekas) * bug #25094 [FrameworkBundle][DX] Display a nice error message if an enabled component is missing (derrabus) * bug #25097 [Bridge\PhpUnit] Turn "preserveGlobalState" to false by default, revert "Blacklist" removal (nicolas-grekas) * bug #25072 [Bridge/PhpUnit] Remove trailing "\n" from ClockMock::microtime(false) (joky) * bug #25032 [Bridge\PhpUnit] Disable broken auto-require mechanism of phpunit (nicolas-grekas) * bug #24956 Fix ambiguous pattern (weltling) * 3.3.13 (2017-11-16) * security #24995 Validate redirect targets using the session cookie domain (nicolas-grekas) * security #24994 Prevent bundle readers from breaking out of paths (xabbuh) * security #24993 Ensure that submitted data are uploaded files (xabbuh) * security #24992 Namespace generated CSRF tokens depending of the current scheme (dunglas) * 3.3.12 (2017-11-13) * bug #24954 [DI] Fix dumping with custom base class (nicolas-grekas) * bug #24952 [HttpFoundation] Fix session-related BC break (nicolas-grekas, sroze) * bug #24929 [Console] Fix traversable autocomplete values (ro0NL) * 3.3.11 (2017-11-10) * bug #24888 [FrameworkBundle] Specifically inject the debug dispatcher in the collector (ogizanagi) * bug #24909 [Intl] Update ICU data to 60.1 (jakzal) * bug #24870 [YAML] Allow to parse custom tags when linting yaml files (pierredup) * bug #24910 [HttpKernel][Debug] Remove noise from stack frames of deprecations (nicolas-grekas) * bug #24906 [Bridge/ProxyManager] Remove direct reference to value holder property (nicolas-grekas) * bug #24900 [Validator] Fix Costa Rica IBAN format (Bozhidar Hristov) * bug #24904 [Validator] Add Belarus IBAN format (Bozhidar Hristov) * bug #24881 [WebserverBundle] fixed the bug that caused that the webserver would … (Serkan Yildiz) * bug #24531 [HttpFoundation] Fix forward-compat of NativeSessionStorage with PHP 7.2 (sroze) * bug #24665 Fix dump panel hidden when closing a dump (julienfalque) * bug #24816 [Serializer] Fix extra attributes when no group specified (ogizanagi) * bug #24814 [Intl] Make intl-data tests pass and save language aliases again (jakzal) * bug #24810 [Serializer] readd default argument value (xabbuh) * bug #24735 [VarDumper] fix trailling comma when dumping an exception (Simperfit) * bug #24764 [HttpFoundation] add Early Hints to Reponse to fix test (Simperfit) * bug #24759 Removes \n or space when $context/$extra are empty (kirkmadera) * bug #24758 Throwing exception if redis and predis unavailable (aequasi) * bug #24744 debug:container --types: Fix bug with non-existent classes (weaverryan) * bug #24605 [FrameworkBundle] Do not load property_access.xml if the component isn't installed (ogizanagi) * bug #24706 [DependencyInjection] Add the possibility to disable assets via xml (renatomefi) * bug #24696 Ensure DeprecationErrorHandler::collectDeprecations() is triggered (alexpott) * bug #24686 Fix $_ENV/$_SERVER precedence in test framework (fabpot) * bug #24606 [HttpFoundation] Fix FileBag issue with associative arrays (enumag) * bug #24673 [DI] Throw when a service name or an alias contains dynamic values (prevent an infinite loop) (dunglas) * bug #24681 Fix isolated error handling (alexpott) * bug #24575 Ensure that PHPUnit's error handler is still working in isolated tests (alexpott) * bug #24597 [PhpUnitBridge] fix deprecation triggering test detection (xabbuh) * bug #24660 Escape trailing \ in QuestionHelper autocompletion (kamazee) * bug #24598 Prefer line formatter on missing cli dumper (greg0ire) * bug #24644 [Security] Fixed auth provider authenticate() cannot return void (glye) * bug #24642 [Routing] Fix resource miss (dunglas) * bug #24608 Adding the Form default theme files to be warmed up in Twig's cache (weaverryan) * bug #24626 streamed response should return $this (DQNEO) * bug #24589 Username and password in basic auth are allowed to contain '.' (Richard Quadling) * bug #24566 Fixed unsetting from loosely equal keys OrderedHashMap (maryo) * bug #24570 [Debug] Fix same vendor detection in class loader (Jean-Beru) * bug #24573 Fixed pathinfo calculation for requests starting with a question mark. (syzygymsu) * bug #24565 [Serializer] YamlEncoder: throw if the Yaml component isn't installed (dunglas) * bug #24563 [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed (dunglas) * bug #24571 [PropertyInfo] Add support for the iterable type (dunglas) * bug #24579 pdo session fix (mxp100) * bug #24536 [Security] Reject remember-me token if UserCheckerInterface::checkPostAuth() fails (kbond) * bug #24548 [Bridge\PhpUnit] Handle deprecations triggered in separate processes (paul-m) * bug #24519 [Validator] [Twig] added magic method __isset() to File Constraint class (loru88) * bug #24532 [DI] Fix possible incorrect php-code when dumped strings contains newlines (Strate) * bug #24502 [HttpFoundation] never match invalid IP addresses (xabbuh) * bug #24460 [Form] fix parsing invalid floating point numbers (xabbuh) * bug #24490 [HttpFoundation] Combine Cache-Control headers (c960657) * bug #23711 Fix support for PHP 7.2 (Simperfit, nicolas-grekas) * bug #24494 [HttpFoundation] Add missing session.lazy_write config option (nicolas-grekas) * bug #24498 [Bridge\PhpUnit] Fix infinite loop when running isolated method (nicolas-grekas) * bug #24434 [Form] Use for=ID on radio/checkbox label. (Nyholm) * bug #24455 [Console] Escape command usage (sroze) * bug #24462 [Yaml] parse references on merge keys with objects (xabbuh) * 3.3.10 (2017-10-05) * bug #23906 Added support for guards when advancing workflow from a command (GDIBass) * bug #24448 [Session] fix MongoDb session handler to gc all expired sessions (Tobion) * bug #24431 [FrameworkBundle] Fix bad interface hint in AbstractController (nicolas-grekas) * bug #24419 [Cache] Fix race condition in TagAwareAdapter (nicolas-grekas) * bug #24417 [Yaml] parse references on merge keys (xabbuh) * bug #24416 [Yaml] treat trailing backslashes in multi-line strings (xabbuh) * bug #24421 [Config] Fix dumped files invalidation by OPCache (nicolas-grekas) * bug #24418 [DI] Allow setting any public non-initialized services (nicolas-grekas) * bug #23980 Tests and fix for issue in array model data in EntityType field with multiple=true (stoccc) * bug #22586 [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible (aaa2000) * bug #24157 [Intl] Fixed support of Locale::getFallback (lyrixx) * bug #24198 [HttpFoundation] Fix file upload multiple with no files (enumag) * bug #24379 [PHPUnitBridge] don't remove when set to empty string (Simperfit) * bug #24036 [Form] Fix precision of MoneyToLocalizedStringTransformer's divisions and multiplications (Rubinum) * bug #24191 [DependencyInjection] include file and line number in deprecation (xabbuh) * bug #24367 PdoSessionHandler: fix advisory lock for pgsql (Tobion) * bug #24189 [Yaml] parse merge keys with PARSE_OBJECT_FOR_MAP flag (xabbuh) * bug #24243 HttpCache does not consider ESI resources in HEAD requests (mpdude) * bug #24237 [WebProfilerBundle] Added missing link to profile token (vtsykun) * bug #24244 TwigBundle exception/deprecation tweaks (ro0NL) * bug #24281 [TwigBundle] Remove profiler related scripting (ro0NL, javiereguiluz) * bug #24251 [PropertyAccess] Set a NullLogger in ApcuAdapter when Apcu is disabled in CLI (iamluc) * bug #24304 [FrameworkBundle] Fix Routing\DelegatingLoader (nicolas-grekas) * bug #24305 [HttpKernel] Make array vs "::" controller definitions consistent (nicolas-grekas) * bug #24255 [TwigBundle] Break long lines in exceptions (kevin-verschaeve) * bug #24219 [Console] Preserving line breaks between sentences according to the exception message (yceruto) * bug #24192 [PhpUnitBridge] do not require an error context (xabbuh) * bug #23722 [Form] Fixed GroupSequence with "constraints" option (HeahDude) * bug #22321 [Filesystem] Fixed makePathRelative (ausi) * bug #24234 [DI] Fix decorated service merge in ResolveInstanceofConditionalsPass (dunglas) * bug #24203 [Security] Preserve URI fragment in HttpUtils::generateUri() (chalasr) * bug #24199 [DI] Fix non-instantiables auto-discovery (nicolas-grekas) * bug #23473 [Filesystem] mirror - fix copying content with same name as source/target. (gitlost) * bug #24177 [FrameworkBundle] Add support to environment variables APP_ENV/DEBUG in KernelTestCase (yceruto) * bug #24162 [WebProfilerBundle] fixed TemplateManager when using Twig 2 without compat interfaces (fabpot) * 3.3.9 (2017-09-11) * bug #24141 [DomCrawler] Fix conversion to int on GetPhpFiles (MaraBlaga) * bug #23853 Filtering empty uuids in ORMQueryBuilderLoader. (mlazovla) * bug #24101 [Security] Fix exception when use_referer option is true and referer is not set or empty (linniksa) * bug #24105 [Filesystem] check permissions if dump target dir is missing (xabbuh) * bug #24126 [HttpKernel] "controller.service_arguments" services should be public (nicolas-grekas) * bug #24113 [FrameworkBundle] Get KERNEL_CLASS through $_ENV too for KernelTestCase (yceruto) * bug #24115 [FrameworkBundle] Get KERNEL_DIR through $_ENV too for KernelTestCase (yceruto) * bug #24041 [ExpressionLanguage] throws an exception on calling uncallable method (fmata) * bug #24096 Fix ArrayInput::toString() for VALUE_IS_ARRAY options/args (chalasr) * bug #24082 [DI] Minor fix in dumped code (nicolas-grekas) * bug #23969 [Cache] Use namespace versioning for backends that dont support clearing by keys (nicolas-grekas) * bug #24021 [DI] Don't track merged configs when the extension doesn't expose it (nicolas-grekas) * bug #24011 [Cache] Always require symfony/polyfill-apcu to provide APCuIterator everywhere (guillaumelecerf) * bug #23730 Fixed the escaping of back slashes and << in console output (javiereguiluz) * 3.3.8 (2017-08-28) * bug #24016 [DI] Fix tracking env var placeholders nested in object graphs (nicolas-grekas) * 3.3.7 (2017-08-28) * bug #24009 [DI] Fix tracking env vars when merging configs (bis) (nicolas-grekas) * bug #23952 [PhpUnitBridge] install PHPUnit 6 on PHP 7.2 (xabbuh) * bug #23985 [Cache] Workaround zend.detect_unicode + zend.multibyte (nicolas-grekas) * bug #23989 [Debug] Remove false-positive check in DebugClassLoader (nicolas-grekas) * bug #23983 [VarDumper] Strengthen dumped JS (nicolas-grekas) * bug #23982 [VarDumper] Strengthen dumped JS (nicolas-grekas) * bug #23925 [Validator] Fix use of GroupSequenceProvider in child classes (linniksa) * bug #23971 [Cache] Fix lazy Memcached connections (nicolas-grekas) * bug #23970 [Cache] Fix >30 days expirations with Memcached (nicolas-grekas) * bug #23949 [Dotenv] Get env using $_SERVER to work with fastcgi_param and workaround thread safety issues (nicolas-grekas) * bug #23799 [Dotenv][WebServerBundle] Override previously loaded variables (voronkovich) * bug #23676 [WebProfilerBundle] Re add missing link to the controller (lyrixx) * bug #23870 [DI] Use GlobResource for non-tracked directories (vudaltsov) * bug #23945 [Validator] Fix Greek translation (azhurb) * bug #23940 [DI] Fix resolving env vars when compiling a ContainerBuilder (nicolas-grekas) * bug #23903 [DI] Fix merging of env vars in configs (nicolas-grekas) * bug #23825 Revert "feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (fabpot)" (nicolas-grekas) * bug #23899 [DI] Fix reading env vars from fastcgi params (nicolas-grekas) * bug #23909 [Console] Initialize lazily to render exceptions properly (nicolas-grekas) * bug #23878 [VarDumper] play nice with open_basedir when looking for composer.json (nicolas-grekas) * bug #23897 Allow phpdocumentor/reflection-docblock 4 (derrabus) * bug #23865 [Workflow] fixed InvalidDefinitionException message for StateMachineValidator (fmata) * bug #23856 [DI] Fix dumping abstract with YamlDumper (nicolas-grekas) * bug #23848 restrict reflection doc block (ElectricMaxxx) * bug #23854 [DI] Fix YamlDumper not dumping abstract and autoconfigure (nicolas-grekas) * bug #23752 Ignore memcached missing key error on session destroy (jderusse) * bug #23829 Fixed the exception page design in responsive mode (javiereguiluz) * bug #23828 [Console] Log exit codes as debug messages instead of errors (haroldiedema) * bug #23763 [Cache] Hash cache key on save (lstrojny) * bug #23806 [Profiler] Fix request_collector check in main layout (ogizanagi) * bug #23658 [HttpFoundation] Generate safe fallback filename for wrongly encoded filename (xelaris) * bug #23776 [FrameworkBundle] Warmup annotations for bundle-less controllers and entities (nicolas-grekas) * bug #23783 Avoid infinite loops when profiler data is malformed (javiereguiluz) * bug #23638 [FrameworkBundle][Workflow] better errors when security deps are missing (xabbuh) * bug #23729 [Bridge\ProxyManager] Dont call __destruct() on non-instantiated services (nicolas-grekas) * bug #23703 Bump minimal PHP version to ^5.5.9|>=7.0.8 (nicolas-grekas) * bug #23755 [Config] Fix checking class existence freshness (nicolas-grekas) * 3.3.6 (2017-08-01) * bug #22244 [Console] Fix passing options with defaultCommand (Jakub Sacha) * bug #23705 [Form] Add notice to upgrade to PHP v7.0.8+ (nicolas-grekas) * bug #23683 [VarDumper] Keep and reuse array stubs in memory (nicolas-grekas) * bug #23686 [Console][WebServerBundle] Use "exec" when possible (nicolas-grekas) * bug #23684 [Debug] Missing escape in debug output (c960657) * bug #23644 [VarDumper] Dont use Stub objects for arrays - lower GC pressure (nicolas-grekas) * bug #23615 [Cache] Handle serialization failures for Memcached (nicolas-grekas) * bug #23654 [DI] Fix using private services in expressions (nicolas-grekas) * bug #23662 [VarDumper] Adapt to php 7.2 changes (nicolas-grekas) * bug #23649 [Form][TwigBridge] Don't render _method in form_rest() for a child form (fmarchalemisys) * bug #23588 [WebProfilerBundle] Display trace and context in the logger profiler (lyrixx) * bug #23023 [DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables (vudaltsov) * bug #23618 [Routing] allow HEAD method to be defined first (DavidBadura) * bug #23619 [Validator] Fix IbanValidator for ukrainian IBANs (paroe) * bug #23605 [DI][Bug] Autowiring thinks optional args on core classes are required (weaverryan) * bug #23586 Fix case sensitive sameSite cookie (mikefrancis) * bug #23584 Fix the design of the profiler exceptions when there is no message (javiereguiluz) * bug #23238 [Security] ensure the 'route' index is set before attempting to use it (gsdevme) * bug #23330 [WebProfilerBundle] Fix full sized dump hovering in toolbar (ogizanagi) * bug #23581 [Config] Minor fix (nicolas-grekas) * bug #23580 Fix login redirect when referer contains a query string (fabpot) * bug #23577 [WebProfilerBundle][TwigBundle] Fix infinite js loop on exception pages (ogizanagi) * bug #23558 [FrameworkBundle] fix ValidatorCacheWarmer: use serializing ArrayAdapter (dmaicher) * bug #23573 [Config] Make ClassExistenceResource throw on invalid parents (nicolas-grekas) * bug #23574 [VarDumper] Move locale sniffing to dump() time (nicolas-grekas) * bug #23575 [VarDumper] Use "C" locale when using "comma" flags (nicolas-grekas) * 3.3.5 (2017-07-17) * bug #23549 [PropertyInfo] conflict for phpdocumentor/reflection-docblock 3.2 (xabbuh) * bug #23513 [FrameworkBundle] Set default public directory on install assets (yceruto) * security #23507 [Security] validate empty passwords again (xabbuh) * bug #23526 [HttpFoundation] Set meta refresh time to 0 in RedirectResponse content (jnvsor) * bug #23535 Make server:* commands work out of the box with the public/ root dir (fabpot) * bug #23540 Disable inlining deprecated services (alekitto) * bug #23498 [Process] Fixed issue between process builder and exec (lyrixx) * bug #23490 [DependencyInjection] non-conflicting anonymous service ids across files (xabbuh) * bug #23468 [DI] Handle root namespace in service definitions (ro0NL) * bug #23477 [Process] Fix parsing args on Windows (nicolas-grekas) * bug #23256 [Security] Fix authentication.failure event not dispatched on AccountStatusException (chalasr) * bug #23461 Use rawurlencode() to transform the Cookie into a string (javiereguiluz) * bug #23465 [HttpKernel][VarDumper] Truncate profiler data & optim perf (nicolas-grekas) * bug #23457 [FrameworkBundle] check _controller attribute is a string before parsing it (alekitto) * bug #23459 [TwigBundle] allow to configure custom formats in XML configs (xabbuh) * bug #23460 Don't display the Symfony debug toolbar when printing the page (javiereguiluz) * bug #23469 [FrameworkBundle] do not wire namespaces for the ArrayAdapter (xabbuh) * bug #23434 [DotEnv] Fix variable substitution (brieucthomas) * bug #23426 Fixed HttpOnly flag when using Cookie::fromString() (Toflar) * bug #22439 [DX] [TwigBundle] Enhance the new exception page design (sustmi) * bug #23417 [DI][Security] Prevent unwanted deprecation notices when using Expression Languages (dunglas) * bug #23261 Fixed absolute url generation for query strings and hash urls (alexander-schranz) * bug #23398 [Filesystem] Dont copy perms when origin is remote (nicolas-grekas) * 3.3.4 (2017-07-05) * bug #23413 [VarDumper] Reduce size of serialized Data objects (nicolas-grekas) * bug #23385 [DoctrineBridge] Fix resetting entity managers with case sensitive id (chalasr) * bug #23390 [Cache] Handle APCu failures gracefully (nicolas-grekas) * bug #23371 [FrameworkBundle] 3.3: Don't get() private services from debug:router (ogizanagi) * bug #23378 [FrameworkBundle] Do not remove files from assets dir (1ed) * 3.3.3 (2017-07-04) * bug #23366 [FrameworkBundle] Don't get() private services from debug:router (chalasr) * bug #23239 [FrameworkBundle] call setContainer() for autowired controllers (xabbuh) * bug #23351 [Dotenv] parse concatenated variable values (xabbuh) * bug #23341 [DoctrineBridge][Security][Validator] do not validate empty values (xabbuh) * bug #23274 Display a better error design when the toolbar cannot be displayed (yceruto) * bug #23342 [Dotenv] parse escaped quotes in unquoted env var values (xabbuh) * bug #23291 [Security] Fix Firewall ExceptionListener priority (chalasr) * bug #23296 [WebProfilerBundle] Fix css trick used for offsetting html anchor from fixed header (ogizanagi) * bug #23333 [PropertyAccess] Fix TypeError discard (dunglas) * bug #23326 [Cache] fix cleanup of expired items for PdoAdapter (dmaicher) * bug #23345 [Console] fix description of INF default values (xabbuh) * bug #23328 [FrameworkBundle] Display a proper warning on cache:clear without the --no-warmup option (ogizanagi) * bug #23299 [Workflow] Added more events to the announce function (Nyholm) * bug #23279 Don't call count on non countable object (pierredup) * bug #23283 [TwigBundle] add back exception check (xabbuh) * bug #23268 Show exception is checked twice in ExceptionController of twig (gmponos) * bug #23266 Display a better error message when the toolbar cannot be displayed (javiereguiluz) * bug #23271 [FrameworkBundle] allow SSI fragments configuration in XML files (xabbuh) * bug #23254 [Form][TwigBridge] render hidden _method field in form_rest() (xabbuh) * bug #23250 [Translation] return fallback locales whenever possible (xabbuh) * bug #23237 [Cache] Fix Predis client cluster with pipeline (flolivaud) * bug #23240 [Console] Fix catching exception type in QuestionHelper (voronkovich) * bug #23218 [DI] Dedup tags when using instanceof/autoconfigure (ogizanagi) * bug #23231 Improved the exception page when there is no message (javiereguiluz) * bug #23229 [WebProfilerBundle] Eliminate line wrap on count column (routing) (e-moe) * bug #22732 [Security] fix switch user _exit without having current token (dmaicher) * bug #23226 [Validator] replace hardcoded service id (xabbuh) * bug #22730 [FrameworkBundle] Sessions: configurable "use_strict_mode" option for NativeSessionStorage (MacDada) * bug #23195 [FrameworkBundle] [Command] Clean bundle directory, fixes #23177 (NicolasPion) * bug #23213 Fixed composer resources between web/cli (iltar) * bug #23160 [WebProfilerBundle] Fix the icon for the Cache panel (javiereguiluz) * bug #23052 [TwigBundle] Add Content-Type header for exception response (rchoquet) * bug #23173 [WebServerBundle] Fix router script option BC (1ed) * bug #23199 Reset redirectCount when throwing exception (hvanoch) * bug #23180 [FrameworkBundle] Expose the AbstractController's container to its subclasses (BPScott) * bug #23186 [TwigBundle] Move template.xml loading to a compiler pass (ogizanagi) * bug #23130 Keep s-maxage when expiry and validation are used in combination (mpdude) * bug #23129 Fix two edge cases in ResponseCacheStrategy (mpdude) * feature #22636 [Routing] Expose request in route conditions, if needed and possible (ro0NL) * bug #22636 [Routing] Expose request in route conditions, if needed and possible (ro0NL) * bug #22943 [SecurityBundle] Move cache of the firewall context into the request parameters (GromNaN) * bug #23088 [FrameworkBundle] Dont set pre-defined esi/ssi services (ro0NL) * bug #23057 [Translation][FrameworkBundle] Fix resource loading order inconsistency reported in #23034 (mpdude) * bug #23092 [Filesystem] added workaround in Filesystem::rename for PHP bug (VolCh) * bug #23074 [HttpFoundation] add back support for legacy constant values (xabbuh) * bug #23128 [HttpFoundation] fix for Support for new 7.1 session options (vincentaubert) * bug #23176 [VarDumper] fixes (nicolas-grekas) * bug #23100 [PropertyAccess] Do not silence TypeErrors from client code. (tsufeki) * bug #23156 [PropertyAccess] Fix Usage with anonymous classes (mablae) * bug #23168 [Config] Fix ** GlobResource on Windows (nicolas-grekas) * bug #23171 [Yaml] Fix linting yaml with constants as keys (chalasr) * bug #23121 [Routing] Revert the change in [#b42018] with respect to Routing/Route.php (Dan Wilga) * bug #23141 [DI] Fix keys resolution in ResolveParameterPlaceHoldersPass (nicolas-grekas) * bug #23145 Fix the conditional definition of the SymfonyTestsListener (stof) * bug #23091 [Cache] ApcuAdapter::isSupported() should return true when apc.enable_cli=Off (nicolas-grekas) * bug #22953 #22839 - changed debug toolbar dump section to relative and use full window width (mkurzeja) * bug #23086 [FrameworkBundle] Fix perf issue in CacheClearCommand::warmup() (nicolas-grekas) * bug #23090 [SecurityBundle] Made 2 service aliases private (nicolas-grekas) * bug #23108 [Yaml] Remove line number in deprecation notices (nicolas-grekas) * bug #23098 Cache ipCheck (2.7) (gonzalovilaseca) * bug #23082 [MonologBridge] Do not silence errors in ServerLogHandler::formatRecord (lyrixx) * bug #23007 [HttpKernel][Debug] Fix missing trace on deprecations collected during bootstrapping & silenced errors (ogizanagi) * bug #23069 [SecurityBundle] Show unique Inherited roles in profile panel (yceruto) * 3.3.2 (2017-06-06) * bug #23073 [TwigBridge] Fix namespaced classes (ogizanagi) * bug #23063 [Cache] Fix extensibility of TagAwareAdapter::TAGS_PREFIX (wucdbm) * bug #22936 [Form] Mix attr option between guessed options and user options (yceruto) * bug #22976 [DependencyInjection] Use more clear message when unused environment variables detected (voronkovich) * 3.3.1 (2017-06-05) * bug #23067 [HttpFoundation][FrameworkBundle] Revert "trusted proxies" BC break (nicolas-grekas) * bug #23065 [Cache] Fallback to positional when keyed results are broken (nicolas-grekas) * bug #22981 [DependencyInjection] Fix named args support in ChildDefinition (dunglas) * bug #23050 [Form][Profiler] Fixes form collector triggering deprecations (ogizanagi) * bug #22971 [Profiler] Fix code excerpt wrapping (ogizanagi) * bug #23049 [FrameworkBundle] mitigate BC break with empty trusted_proxies (xabbuh) * bug #23045 [Cache] fix Redis scheme detection (xabbuh) * bug #23013 Parse the _controller format in sub-requests (weaverryan) * bug #23015 [PhpUnitBridge] Fix detection of PHPUnit 5 (enumag) * bug #23041 [Config] Always protected ClassExistenceResource against bad parents (nicolas-grekas) * bug #22988 [PropertyInfo][DoctrineBridge] The bigint Doctrine's type must be converted to string (dunglas) * bug #23014 Fix optional cache warmers are always instantiated whereas they should be lazy-loaded (romainneutron) * feature #23022 [Di] Remove closure-proxy arguments (nicolas-grekas) * bug #23024 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null) (nicolas-grekas) * bug #23008 [EventDispatcher] Handle laziness internally instead of relying on ClosureProxyArgument (nicolas-grekas) * bug #23018 [FrameworkBundle] Fix CacheCollectorPass priority (chalasr) * bug #23009 [Routing] Allow GET requests to be redirected. Fixes #23004 (frankdejonge) * bug #22996 [Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 (romainneutron) * bug #22965 [Cache] Ignore missing annotations.php (ro0NL) * bug #22993 [DI] Autowiring exception thrown when inlined service is removed (weaverryan) * bug #22999 Better DI type deprecation message (weaverryan) * bug #22985 [Config] Allow empty globs (nicolas-grekas) * bug #22961 [HttpKernel] Support unknown format in LoggerDataCollector (iltar) * bug #22991 [DI] Don't throw Autowire exception for removed service with private __construct (weaverryan) * bug #22968 [Profiler] Fix text selection & click on file links on exception pages (ogizanagi) * bug #22994 Harden the debugging of Twig filters and functions (stof) * bug #22960 [Cache] Fix decoration of TagAware adapters in dev (chalasr) * 3.3.0 (2017-05-29) * bug #22940 [Config] Fallback to regular import when glob fails (nicolas-grekas) * bug #22847 [Console] ChoiceQuestion must have choices (ro0NL) * bug #22900 [FrameworkBundle][Console] Fix the override of a command registered by the kernel (aaa2000) * bug #22930 Revert "bug #22925 [PhpUnitBridge] Adjust PHPUnit class_alias check (nicolas-grekas) * bug #22910 [Filesystem] improve error handling in lock() (xabbuh) * bug #22924 [Cache] Dont use pipelining with RedisCluster (nicolas-grekas) * bug #22928 [WebProfilerBundle] Fixed options stub values display in form profiler (HeahDude) * feature #22838 Make the simple exception pages match the new style (javiereguiluz) * bug #22925 [PhpUnitBridge] Adjust PHPUnit class_alias check to also check for namespaced class (GawainLynch) * bug #22718 [Console] Fixed different behaviour of key and value user inputs in multiple choice question (borNfreee) * bug #22921 [FrameworkBundle] Only override getProjectDir if it exists in the kernel (aschempp) * feature #22905 [FrameworkBundle][Validator] Move the PSR-11 factory to the component (ogizanagi) * bug #22728 [HttpKernel] Fix kernel.project_dir extensibility (chalasr) * bug #22829 [Yaml] fix colon without space deprecation (xabbuh) * bug #22901 Fix missing abstract key in XmlDumper (weaverryan) * bug #22912 [DI] Avoid private call to Container::has() (ro0NL) * feature #22904 [HttpFoundation] Add Request::HEADER_X_FORWARDED_AWS_ELB const (nicolas-grekas) * bug #22878 [Yaml] parse PHP constants in mapping keys (xabbuh) * bug #22873 [HttpKernel] don't call getTrustedHeaderName() if possible (xabbuh) * feature #22892 [ProxyManager] Add FC layer (nicolas-grekas) * bug #22866 [DI] Check for privates before shared services (ro0NL) * feature #22884 [DI] Add missing deprecation on Extension::getClassesToCompile (nicolas-grekas) * bug #22874 [WebProfilerBundle] Fix sub-requests display in time profiler panel (nicolas-grekas) * bug #22853 [Yaml] fix multiline block handling (xabbuh) * bug #22872 [FrameworkBundle] Handle project dir in cache:clear command (nicolas-grekas) * feature #22808 [FrameworkBundle][Validator] Deprecate passing validator instances/aliases over using the service locator (ogizanagi) * bug #22857 [DI] Fix autowire error for inlined services (weaverryan) * bug #22858 [SecurityBundle] Prevent auto-registration of UserPasswordEncoderCommand (chalasr) * bug #22859 [Profiler][VarDumper] Fix searchbar css when in toolbar (ogizanagi) * bug #22614 [Process] Fixed escaping arguments on Windows when inheritEnvironmentVariables is set to false (maryo) * bug #22817 [PhpUnitBridge] optional error handler arguments (xabbuh) * bug #22781 [DI][Serializer] Fix missing de(normalizer|coder) autoconfig (ogizanagi) * bug #22790 [DependencyInjection] Fix dumping of RewindableGenerator with empty IteratorArgument (meyerbaptiste) * bug #22787 [MonologBridge] Fix the Monlog ServerLogHandler from Hanging on Windows (ChadSikorra) * bug #22768 Use 0.0.0.0 as the server log command host default. (ChadSikorra) * bug #22752 Improved how profiler errors are displayed on small screens (javiereguiluz) * 3.3.0-RC1 (2017-05-17) * bug #22715 [FrameworkBundle] remove Security deps from the require section (xabbuh) * bug #22613 [Process] Fix incorrectly calling PHP process when path contains space (maryo) * feature #22680 [DI] Fixing missing "exclude" functionality from PSR4 loader (weaverryan) * bug #22699 [TwigBundle] service workflow.twig_extension should stay public (ogizanagi) * feature #22708 Adding autowire alias for AuthenticationUtils (weaverryan) * bug #22695 [WebServerBundle] fix dependencies (xabbuh) * bug #22647 [VarDumper] Fix dumping of non-nested stubs (nicolas-grekas) * bug #22409 [Yaml] respect inline level when dumping objects as maps (goetas, xabbuh) * bug #22584 [Security] Avoid unnecessary route lookup for empty logout path (ro0NL) * bug #22642 [DX] Making the RegisterControllerArgumentLocatorsPass throw exception on bad types (weaverryan) * bug #22664 [Security] Fix TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer (ogizanagi) * bug #22690 [Console] Fix errors not rethrown even if not handled by console.error listeners (chalasr) * bug #22681 Fixing a bug where abstract classes were wired with the prototype loader (weaverryan) * feature #22665 [DI] Do not throw autowiring exceptions for a service that will be removed (weaverryan) * bug #22669 [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice (ogizanagi) * bug #22676 [FrameworkBundle] Adding the extension XML (flug) * bug #22611 [FrameworkBundle] Fix "Locale class not found" in AboutCommand (rubenrua) * bug #22677 [DI] Fixed index args bug with ResolveNamedArgumentsPass (weaverryan) * bug #22652 [Workflow] Move twig extension registration to twig bundle (ogizanagi) * feature #22668 [FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var (ogizanagi) * bug #22639 [WebLink][TwigBundle] Fix registration of the twig extension (ogizanagi) * bug #22658 Make the exception pages work when the WebProfilerBundle is not installed (javiereguiluz) * bug #22657 [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use (ogizanagi) * feature #22624 debug:container --types (classes/interfaces) (weaverryan) * bug #22626 Fix missing parenthesis (yceruto) * bug #22621 [Config] Fix resource tracking with new GlobResource (nicolas-grekas) * feature #22385 [DX][FrameworkBundle] Show private aliases in debug:container (chalasr) * bug #22615 [DI] Defaults to public=false in all service config files (nicolas-grekas) * 3.3.0-BETA1 (2017-05-01) * feature #22530 Making tags under _defaults always apply (weaverryan) * feature #22590 [Lock] remove the component from 3.3 (fabpot) * feature #22527 [DI] Throw useful exception on bad XML argument tags (nicolas-grekas) * feature #22537 [Serializer] Allow to pass csv encoder options in context (ogizanagi) * feature #22563 Not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition (weaverryan) * feature #22441 [Console] Review console.ERROR related behavior (nicolas-grekas) * feature #22234 [DI] Introducing autoconfigure: automatic _instanceof configuration (weaverryan) * feature #21502 Persist app bootstrapping logs for logger datacollector (ScullWM, nicolas-grekas) * feature #22459 [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass (nicolas-grekas) * feature #22416 [FrameworkBundle][Workflow] Deprecate the default type of a workflow (lyrixx) * feature #22313 [Workflow] Move ValidateWorkflowsPass to the Workflow component (chalasr) * feature #22420 [DI] Make tagged abstract services throw earlier (nicolas-grekas) * feature #22384 [DI] Replace autowiring BC break by regular deprecation (nicolas-grekas) * feature #22383 added a more specialized exception for a better error message (fabpot) * feature #22356 [DI] Rework config hierarchy: defaults > instanceof > service config (weaverryan, nicolas-grekas) * feature #22362 [DI] Populate class of ChildDefinition when its id matches an existing FQCN (nicolas-grekas) * feature #22239 [Finder] Glob wildcard while using double-star without ending slash (sroze) * feature #22273 Add a new Link component (dunglas) * feature #22315 Add Kernel::getProjectDir() (fabpot) * feature #22314 [HttpKernel][FrameworkBundle] Dump container logs in Kernel, to have them also on errors (nicolas-grekas) * feature #22316 [WebServerBundle] added a way to dump current status host/port/address when getting the status (fabpot) * feature #22323 [DI] Report cascades of autowiring error messages (nicolas-grekas) * feature #22306 [DI] Restrict autowired registration to "same-vendor" namespaces (nicolas-grekas) * feature #22295 [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services (nicolas-grekas) * feature #20951 Redesigned the exception pages (javiereguiluz) * feature #21919 [Form] Deprecated usage of "choices" option in sub types (HeahDude) * feature #22274 [Yaml] report deprecations when linting YAML files (xabbuh) * feature #22286 [DI/Yaml] Remove `@experimental` flag from "instanceof" and "prototype" (nicolas-grekas) * feature #22181 [Console] Allow to catch CommandNotFoundException (chalasr) * feature #22296 Bump monolog to 1.19 and use the agent regex const from parent (redthor) * feature #21437 [Security] Use IteratorArgument for voters (jvasseur) * feature #22277 [DI] Add "factory" support to named args and autowiring (nicolas-grekas) * feature #22276 [FrameworkBundle] Returns the kernel instance in KernelTestCase::bootKernel (lyrixx) * feature #22256 [DI] Reduce complexity of autowiring (nicolas-grekas) * feature #22238 [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument (nicolas-grekas) * feature #22175 [DI] add ServiceLocatorTagPass::register() to share service locators (nicolas-grekas) * feature #22180 [Workflow] Added 'workflow_marked_places' twig function (lyrixx) * feature #22185 [DI] Enhance DX by throwing instead of triggering a deprecation notice (nicolas-grekas) * feature #22060 [DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention (nicolas-grekas) * feature #22158 Revert "feature #20973 [DI] Add getter injection (nicolas-grekas)" (nicolas-grekas) * feature #22157 [FrameworkBundle] Introduce AbstractController, replacing ControllerTrait (nicolas-grekas) * feature #22046 [Asset] Adding a new version strategy that reads from a manifest JSON file (weaverryan) * feature #22129 [WebProfilerBundle] Improve cache panel (ro0NL) * feature #21819 [Twig Bridge] A simpler way to retrieve flash messages (javiereguiluz) * feature #19026 [Security] Strengthen comparison of target_url vs login_path (mrzard) * feature #19496 [DX][Form][Validator] Add ability check if cocrete constraint fails. (Koc) * feature #18140 [Console] Add console.ERROR event and deprecate console.EXCEPTION (wouterj) * feature #22120 [FrameworkBundle] Multiple services on one Command class (SenseException) * feature #21771 [FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions (nicolas-grekas) * feature #22114 [lock] Rename Quorum into Strategy (jderusse) * feature #20516 [Security][SecurityBundle] Enhance automatic logout url generation (ogizanagi) * feature #22081 [FrameworkBundle][Validator] Move Validator passes to the component (chalasr) * feature #20567 [WebProfilerBundle] Improved cookie traffic (ro0NL) * feature #19887 Sort alternatives alphabetically when a command is not found (javiereguiluz) * feature #20851 [Cache] Add CacheItem::getPreviousTags() (nicolas-grekas) * feature #21830 [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it (nicolas-grekas) * feature #21924 [FrameworkBundle] Allow to configure Serializer mapping paths (chalasr) * feature #19278 [FrameworkBundle] Added about command (ro0NL) * feature #21708 [DI] Add and wire ServiceSubscriberInterface - aka explicit service locators (nicolas-grekas) * feature #22011 [FrameworkBundle][Serializer] Add option to register a circular_reference_handler (lyrixx) * feature #19673 [DI] Deprecate Container::isFrozen and introduce isCompiled (ro0NL) * feature #19954 [Console] Exclude empty namespaces in text descriptor (ro0NL) * feature #21093 [Lock] Create a lock component (jderusse) * feature #21007 [WebProfilerBundle] Improve AJAX toolbar panel (ro0NL) * feature #20642 [FrameworkBundle] Add project directory default for installing assets (Noah Heck) * feature #20365 [TwigBridge] Handle form label attributes like others (ro0NL) * feature #22010 [FrameworkBundle][Translator] Make the Translator works with any PSR-11 container (chalasr) * feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (fabpot) * feature #22098 [*Bundle] Add autowiring aliases for common services (nicolas-grekas) * feature #22095 [DI] Add logging and better failure recovery to AutowirePass (nicolas-grekas) * feature #21889 Deprecate the special SYMFONY__ environment variables (javiereguiluz) * feature #22059 [Yaml] deprecate "? " starting unquoted strings (xabbuh) * feature #22030 [DI] Remove skipping magic for autowired methods (nicolas-grekas) * feature #22024 [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument (nicolas-grekas) * feature #21837 [FrameworkBundle] Lazy configuration of annotations' loader and `@required` (nicolas-grekas) * feature #21970 [DependencyInjection] Support anonymous services in Yaml (GuilhemN) * feature #21979 [FrameworkBundle][TwigBundle] Require PSR-11 container instead of Symfony container (enumag) * feature #21935 [FrameworkBundle][Workflow] Add a way to register a guard expression in the configuration (lyrixx) * feature #21080 [FrameworkBundle][Monolog] Added a new way to follow logs (lyrixx) * feature #21978 [DoctrineBridge][Routing] Require PSR-11 container instead of Symfony container (enumag) * feature #21950 [Workflow] Added fluent interface to the DefinitionBuilder (lyrixx) * feature #21933 [FrameworkBundle][Workflow] Add a way to enable the AuditTrail Logger (lyrixx) * feature #21925 [Workflow] Added the workflow name to all events dispatched (lyrixx) * feature #21774 [Yaml] deprecate implicit string casting of mapping keys (xabbuh) * feature #21780 [DX] [Form] Add helper method to register form extensions during unit testing (pierredup) * feature #21842 [HttpKernel] Allow signing URIs with a custom query string parameter (thewilkybarkid) * feature #21705 [Bridge/Monolog] Enhance the Console Handler (lyrixx) * feature #21893 Added a castToArray() config helper (javiereguiluz) * feature #21421 Use proper error message when session write fails #20807 (digilist) * feature #21770 [DI] Allow extensions to create ServiceLocator as services (nicolas-grekas) * feature #21767 [DI][Router][DX] Invalidate routing cache when container parameters changed (ogizanagi) * feature #21835 [FrameworkBundle][Routing] Move RoutingResolverPass to the Routing component (chalasr) * feature #21815 [FrameworkBundle][HttpKernel] Move ControllerArgumentValueResolverPass to the HttpKernel component (chalasr) * feature #21824 Add deprecation note on routing class parameters (lepiaf) * feature #21854 [Router] Follow symlinks and skip dots in the annotation directory loader (jakzal) * feature #18193 [FrameworkBundle] Introduce autowirable ControllerTrait (dunglas) * feature #20680 DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. (FractalizeR) * feature #21828 [PhpUnitBridge] include expected deprecations in assertion counter (xabbuh) * feature #21763 [DI] Replace wildcard-based methods autowiring by `@required` annotation (nicolas-grekas) * feature #21730 [DependencyInjection] Use a service locator in AddConstraintValidatorsPass (GuilhemN) * feature #21118 [Yaml] parse omitted inlined mapping values as null (xabbuh) * feature #21806 [FrameworkBundle][PropertyInfo] Move PropertyInfoPass to the PropertyInfo component (chalasr) * feature #19822 [HttpKernel] Deprecate X-Status-Code for better alternative (jameshalsall) * feature #21228 [Console] Explicitly passed options without value (or empty) should remain empty (chalasr) * feature #21723 [Routing][DX] Add full route definition for invokable controller/class (yceruto) * feature #21768 [HttpKernel] Add a ContainerControllerResolver (psr-11) (ogizanagi) * feature #21690 [Form] allow form types + form type extensions + form type guessers to be private services (hhamon) * feature #21755 [Routing] Optimised dumped router matcher, prevent unneeded function calls. (frankdejonge) * feature #21375 [FrameworkBundle][Config] Move ConfigCachePass from FrameworkBundle to Config (Deamon) * feature #21786 [PhpUnitBridge] testing for deprecations is not risky (xabbuh) * feature #21792 [Security] deprecate multiple providers in context listener (xabbuh) * feature #21625 Remove some container injections in favor of service locators (nicolas-grekas, chalasr) * feature #21539 Introduce weak vendors mode (greg0ire) * feature #21638 [VarDumper] Allow seamless use of Data clones (nicolas-grekas) * feature #21164 [HttpKernel] Added the SessionValueResolver (iltar) * feature #21718 [SecurityBundle] Don't normalize username of in-memory users (chalasr) * feature #20107 Added a build method to the kernel to replace Bundle::build() (iltar) * feature #21694 [Bridge/PhpUnit] Add PHPUnit 6 support (nicolas-grekas) * feature #21122 [ExpressionLanguage] Create an ExpressionFunction from a PHP function name (maidmaid) * feature #21653 [VarDumper] Added a way to print or not comma separator and/or trailing comma (lyrixx) * feature #21471 [Yaml] Allow dumping empty array as YAML sequence (c960657) * feature #21478 [Asset] Add support for preloading with links and HTTP/2 push (dunglas) * feature #20632 [FrameworkBundle] Make use of stderr for non reliable output (chalasr, ogizanagi) * feature #21664 [Console] simplify the implementation of SymfonyStyle::comment() (fabpot) * feature #21578 [Translation] Added a lint:xliff command for XLIFF files (javiereguiluz) * feature #21635 added support for glob loaders in Config (fabpot) * feature #21654 [PropertyInfo] Use iterators for PropertyInfoExtractor (GuilhemN) * feature #21655 [PropertyInfo] Make classes final (GuilhemN) * feature #21530 [DependencyInjection] Add "instanceof" section for local interface-defined configs (nicolas-grekas, dunglas) * feature #21643 [Yaml] deprecate parsing mappings without keys (xabbuh) * feature #20677 [DX][SecurityBundle] UserPasswordEncoderCommand: ask user class choice question (ogizanagi) * feature #21283 [Form][FrameworkBundle] Move FormPass to the Form component (chalasr) * feature #21293 [FrameworkBundle][Serializer] Move SerializerPass to the Serializer (chalasr) * feature #21450 [Security] Lazy load guard authenticators and authentication providers (chalasr) * feature #21484 [DI] Deprecate underscore-services in YamlFileLoader (nicolas-grekas) * feature #21270 [DependencyInjection] Use glob pattern to load config files (pierredup) * feature #19815 [WebProfilerBundle] Make the IP address in the profiler header clickable (jameshalsall) * feature #21383 [DependencyInjection] Add support for named arguments (dunglas, nicolas-grekas) * feature #19371 [Serializer] Give access to the context to support* methods (dunglas) * feature #21553 [DI] Replace container injection by explicit service locators (chalasr) * feature #18834 [Serializer] Add the possibility to filter attributes (dunglas) * feature #20787 [Workflow] Added an entered event (Padam87) * feature #21289 [DI] Add prototype services for PSR4-based discovery and registration (nicolas-grekas) * feature #21465 [Debug] Support `@final` on methods (GuilhemN) * feature #21505 [Config][DI] Add ComposerResource to track the runtime engine + deps (nicolas-grekas) * feature #21533 [DI] Deprecate (un)setting pre-defined services (ro0NL) * feature #21194 [Yaml] Add tags support (GuilhemN) * feature #21460 [DI] ContainerBuilder::compile() can optionally resolve env vars in parameter bag (nicolas-grekas) * feature #21572 [Finder] Add double-star matching to Glob::toRegex() (nicolas-grekas) * feature #21265 [DI] Implement PSR-11 (greg0ire) * feature #21474 [Process] Accept command line arrays and per-run env vars, fixing signaling and escaping (nicolas-grekas) * feature #21517 [FrameworkBundle] Add missing autowiring aliases for common interfaces (chalasr) * feature #21516 [HttpKernel][FrameworkBundle] Lazy load argument value resolvers (chalasr) * feature #21031 [DI] Getter autowiring (dunglas) * feature #21419 [DI][Config] Add & use ReflectionClassResource (nicolas-grekas) * feature #21455 [DI] Allow to count on lazy collection arguments (ogizanagi) * feature #21408 [DI] Add ContainerBuilder::fileExists() for checking/tracking resource existence (chalasr) * feature #21470 [Process] Deprecate not inheriting env vars + compat related settings (nicolas-grekas) * feature #21494 [DI] Deprecate autowiring-types in favor of aliases (nicolas-grekas) * feature #21451 [SecurityBundle] Lazy load request matchers in FirewallMap (chalasr) * feature #20973 [DI] Add getter injection (nicolas-grekas) * feature #21396 [DI] Enhance logging in compiler passes (nicolas-grekas) * feature #21402 [Security] make LdapBindAuthenticationProvider capable of searching for the DN (lsmith77, nietonfir) * feature #21404 [DI] Generalize constructor autowiring to partial method calls (nicolas-grekas) * feature #21388 [Debug] Deprecate ContextErrorException (nicolas-grekas) * feature #20943 [DependencyInjection] Use current class as default class for factory declarations (ogizanagi) * feature #21003 [Console][FrameworkBundle] Log console exceptions (jameshalsall, chalasr) * feature #21313 [DI] Add Yaml syntax for short services definition (ogizanagi) * feature #20694 [Cache] Implement PSR-16 SimpleCache v1.0 (nicolas-grekas) * feature #21327 [DI] Factorize compiler passes around new AbstractRecursivePass (nicolas-grekas) * feature #19086 [FrameworkBundle] add "mapping" configuration key at validation secti… (davewwww) * feature #21350 [Yaml] Remove internal arguments from the api (GuilhemN) * feature #21353 [ClassLoader] Deprecated the component (nicolas-grekas) * feature #21334 [Workflow] Introduce concept of SupportStrategyInterface (andesk, lyrixx) * feature #20390 [Ldap] added Ldap entry rename for ExtLdap adapter (fruitwasp) * feature #21065 Added cache data collector and profiler page (Nyholm) * feature #21306 [DependencyInjection] Always autowire the constructor (dunglas) * feature #20493 [Debug] Trigger deprecation on `@final` annotation in DebugClassLoader - prepare making some classes final (GuilhemN) * feature #21244 [DI] Remove synthetic services from methodMap + generated methods (nicolas-grekas) * feature #21238 [VarDumper] Add search keyboard shortcuts (ogizanagi) * feature #21290 [FrameworkBundle] Fix debug:container --show-arguments missing cases (chalasr) * feature #21263 [DI] Mark generated containers as final (nicolas-grekas) * feature #21253 [TwigBridge][Worklow] Added a new workflow_has_place function (Padam87, lyrixx) * feature #21234 Add a new Dotenv component (fabpot) * feature #20861 Add a --show-arguments flag to the debug:container command (Cydonia7) * feature #21223 [DI] Deprecate case insentivity of service identifiers (nicolas-grekas) * feature #20887 [Form] DateIntervalType: Allow to configure labels & enhance form theme (ogizanagi) * feature #19443 [Console] Move AddConsoleCommandPass from FrameworkBundle to Console. (bcremer) * feature #21231 [FrameworkBundle] allow to reference files directly from kernel.root_dir (fabpot) * feature #20611 [DI] FileLoaders: Allow to explicit type to load (ogizanagi) * feature #20689 [Config][FrameworkBundle] Allow to dump extension config reference sub-path (ogizanagi) * feature #21188 [HttpFoundation] Add File\Stream for size-unknown BinaryFileResponse (nicolas-grekas) * feature #21214 [DI] Allow ~ instead of {} for services in Yaml (wouterj) * feature #20612 [Filesystem] Add appendToFile() (chalasr) * feature #20612 [Filesystem] Add appendToFile() (chalasr) * feature #21114 [Yaml] parse multi-line strings (xabbuh) * feature #21196 [FrameworkBundle] changed some default configs from canBeEnabled to canBeDisabled (fabpot) * feature #20937 [EventDispatcher] Deprecate ContainerAwareEventDispatcher (nicolas-grekas) * feature #21190 [WebServerBundle] Decouple server commands from the container (chalasr) * feature #21071 [DI] Add "inherit-tags" with configurable defaults + same for "public", "tags" & "autowire" (nicolas-grekas, ogizanagi) * feature #21133 [DI] Optional class for named services (hason, nicolas-grekas) * feature #20953 [DI][EventDispatcher] Add & wire closure-proxy argument type (nicolas-grekas) * feature #20586 [Console] Ease writing to stderr using SymfonyStyle (chalasr) * feature #20547 [FrameworkBundle] Allowed symlinks when searching for translation, searialization and validation files (tifabien) * feature #20735 Deprecate ClassCollectionLoader and Kernel::loadClassCache (dbrumann) * feature #21140 [PhpUnitBridge] deprecate the testLegacy test name prefix (xabbuh) * feature #21109 [Profiler][VarDumper] Add a search feature to the HtmlDumper (ogizanagi) * feature #21039 Web server bundle (fabpot) * feature #20907 [DependencyInjection] Implement lazy collection type using generators (tgalopin, nicolas-grekas) * feature #21075 [Console] Show hidden commands in json & xml descriptors (ogizanagi) * feature #21129 [FrameworkBundle] Display original definition for aliases in debug:container (chalasr) * feature #21108 [Cache] Add DSN, createClient & better error reporting to MemcachedAdapter (nicolas-grekas, robfrawley) * feature #21147 [PhpUnitBridger] Bump simple-phpunit to PHPUnit 5.7 by default (nicolas-grekas) * feature #21112 [PhpUnitBridge] run PHPUnit in the same process (xabbuh) * feature #21106 [Validator] support DateTimeInterface instances for times (xabbuh) * feature #20809 [FrameworkBundle] Display the controller class name in 'debug:router' (lyrixx) * feature #21082 [Cache] TraceableAdapter (Nyholm) * feature #20938 [DI] Prepare dropping "strict" handling in loaders (nicolas-grekas) * feature #20971 [WebProfilerBundle] Split PHP version if needed (ro0NL) * feature #20634 [DI] Deprecate dumping an uncompiled container (ro0NL) * feature #20923 #20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr… (skafandri) * feature #20569 [HttpFoundation] Create cookie from string + synchronize response cookies (ro0NL) * feature #20618 [DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars. (nicolas-grekas) * feature #20962 Request exceptions (thewilkybarkid, fabpot) * feature #20928 [FrameworkBundle] don't load translator services if not required (xabbuh) * feature #20644 [HttpFoundation] Compute cookie max-age attribute (ro0NL) * feature #20167 [DependencyInjection] Make method (setter) autowiring configurable (dunglas) * feature #20663 [DependencyInjection] replace DefinitionDecorator by ChildDefinition (xabbuh) * feature #20197 [WebProfilerBundle] Improve Ajax Profiling Performance (javascript) (patrick-mcdougle) * feature #20487 [Console] Disallow inheritance from ProgressBar (a-ast) * feature #20651 [DependencyInjection] Added Yaml syntax shortcut for name-only tags (wouterj) * feature #20648 [DependencyInjection] Added a shortcut method for autowired definitions (wouterj) * feature #20697 Updated the "PHP config" panel in the profiler (javiereguiluz) * feature #20773 [FrameworkBundle] Added GlobalVariables::getToken() (HeahDude) * feature #20866 [Console] Improve markdown format (ro0NL) * feature #20867 [Console] Include application name/version in JSON descriptions (ro0NL) * feature #20869 [Console] Improve UX on not found namespace/command (Seldaek) * feature #20858 [Cache] Simple Memcached Adapter (robfrawley) * feature #20881 [VarDumper] Add SymfonyCaster::castRequest() (nicolas-grekas) * feature #20810 [FrameworkBundle] Allow clearing private cache pools in cache:pool:clear (chalasr) * feature #20417 [SecurityBundle] Rename FirewallContext#getContext() (chalasr) * feature #20801 [Security] deprecate the RoleInterface (xabbuh) * feature #20260 [DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface (chalasr) * feature #20777 [ClassLoader] Deprecate Apc/WinCache/Xcache class loaders (nicolas-grekas) * feature #20524 [Serializer][XmlEncoder] Allow removing empty tags in generated XML (amoiraud) * feature #19958 [Serializer] Throw exception when extra attributes are used during an object denor… (juliendidier) * feature #20310 [Ldap] Allow search scoping (xunto) * feature #18952 [Security] Add a JSON authentication listener (dunglas) * feature #20161 add toolbar & profiler SVG style classes (havvg) * feature #20467 [DomCrawler] Add support for formaction and formmethod attributes (stof) * feature #20509 [Serializer] Allow to specify a single value in @Groups (dunglas) * feature #20722 Updated the "Symfony Config" panel in the profiler (javiereguiluz) symfony-3.4.6/CHANGELOG-3.4.md000066400000000000000000001401561324732107100153520ustar00rootroot00000000000000CHANGELOG for 3.4.x =================== This changelog references the relevant changes (bug and security fixes) done in 3.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.4.0...v3.4.1 * 3.4.6 (2018-03-05) * bug #26393 [DI] Skip resource tracking if disabled (chalasr) * bug #26355 [DI] Fix missing "id" normalization when dumping the container (nicolas-grekas) * bug #26368 [WebProfilerBundle] Fix Debug toolbar breaks app (xkobal) * bug #26369 Use fill instead of style for svg colors (rpkamp) * bug #26358 [FrameworkBundle] Silence "Failed to remove directory" on cache:clear (nicolas-grekas) * 3.4.5 (2018-03-01) * bug #26327 [Form][WCAG] Errors sign for people that do not see colors (Nyholm) * bug #26326 [Form][WCAG] Added role="presentation" on tables & removed bootstrap4 table (Nyholm) * bug #26325 [Form][WCAG] Add hidden labels on date and time fields (Nyholm) * bug #26338 [Debug] Keep previous errors of Error instances (Philipp91) * bug #26328 [Form][WCAG] Fixed HTML errors (Nyholm) * bug #26290 [FrameworkBundle] [Console][DX] add a warning when command is not found (Simperfit) * bug #26318 [Routing] Fix GC control of PHP-DSL (nicolas-grekas) * bug #26312 [Routing] Don't throw 405 when scheme requirement doesn't match (nicolas-grekas) * bug #26275 Set controller without __invoke method from invokable class (Tobion) * bug #26298 Fix ArrayInput::toString() for InputArgument::IS_ARRAY args (maximium) * bug #26177 Update excluded_ajax_paths for sf4 (jenaye) * bug #26286 [Security] Add missing use for RoleInterface (tony-tran) * bug #26265 [PropertyInfo] throw exception if docblock factory does not exist (xabbuh) * bug #26247 [Translation] Process multiple segments within a single unit. (timewasted) * bug #26254 fix custom radios/inputs for checkbox/radio type (mssimi) * bug #26234 [FrameworkBundle] Add missing XML config for circular_reference_handler (dunglas) * bug #26236 [PropertyInfo] ReflectionExtractor: give a chance to other extractors if no properties (dunglas) * bug #26227 Add support for URL-like DSNs for the PdoSessionHandler (stof) * bug #25557 [WebProfilerBundle] add a way to limit ajax request (Simperfit) * bug #26088 [FrameworkBundle] Fix using annotation_reader in compiler pass to inject configured cache provider (Laizerox) * bug #26157 [HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation (rpkamp) * bug #26230 [WebProfilerBundle] Fix anchor CSS (ro0NL) * bug #26228 [HttpFoundation] Fix missing "throw" in JsonResponse (nicolas-grekas) * bug #26211 [Console] Suppress warning from sapi_windows_vt100_support (adawolfa) * bug #26176 Retro-fit proxy code to make it deterministic for older proxy manager implementations (lstrojny) * bug #25787 Yaml parser regression with comments and non-strings (alexpott) * bug #26156 Fixes #26136: Avoid emitting warning in hasParameterOption() (greg-1-anderson) * bug #26183 [DI] Add null check for removeChild (changmin.keum) * bug #26167 [TwigBridge] Apply some changes to support Bootstrap4-stable (mpiot, Nyholm) * bug #26173 [Security] fix accessing request values (xabbuh) * bug #26089 [PhpUnitBridge] Added support for PHPUnit 7 in Coverage Listener (lyrixx) * bug #26170 [PHPUnit bridge] Avoid running the remove command without any packages (stof) * bug #26159 created validator.tl.xlf for Form/Translations (ergiegonzaga) * bug #26100 [Routing] Throw 405 instead of 404 when redirect is not possible (nicolas-grekas) * bug #26119 [TwigBundle][WebProfilerBundle] Fix JS collision (ro0NL) * bug #26040 [Process] Check PHP_BINDIR before $PATH in PhpExecutableFinder (nicolas-grekas) * bug #26067 [YAML] Issue #26065: leading spaces in YAML multi-line string literals (tamc) * bug #26012 Exit as late as possible (greg0ire) * bug #26082 [Cache][WebProfiler] fix collecting cache stats with sub-requests + allow clearing calls (dmaicher) * bug #26024 [PhpBridge] add PHPUnit 7 support to SymfonyTestsListener (shieldo) * bug #26020 [Lock] Log already-locked errors as "notice" instead of "warning" (Simperfit) * bug #26043 [Serialized] add context to serialize and deserialize (andrey1s) * bug #26127 Deterministic time in cache items for reproducible builds (lstrojny) * bug #26128 Make kernel build time optionally deterministic (lstrojny) * bug #26112 Env var maps to undefined constant. (dsmink) * bug #26111 [Security] fix merge of 2.7 into 2.8 + add test case (dmaicher) * bug #25893 [Console] Fix hasParameterOption / getParameterOption when used with multiple flags (greg-1-anderson) * bug #25756 [TwigBundle] Register TwigBridge extensions first (fancyweb) * bug #26051 [WebProfilerBundle] Fix sub request link (ro0NL) * bug #25947 PhpDocExtractor::getTypes() throws fatal error when type omitted (Jared Farrish) * bug #25940 [Form] keep the context when validating forms (xabbuh) * bug #26057 [SecurityBundle] use libsodium to run Argon2i related tests (xabbuh) * bug #25373 Use the PCRE_DOLLAR_ENDONLY modifier in route regexes (mpdude) * bug #24435 [Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2 (Nyholm) * bug #25762 [DependencyInjection] always call the parent class' constructor (xabbuh) * bug #25976 [Config] Handle Service/EventSubscriberInterface in ReflectionClassResource (nicolas-grekas) * bug #25989 [DI][Routing] Fix tracking of globbed resources (nicolas-grekas, sroze) * bug #26009 [SecurityBundle] Allow remember-me factory creation when multiple user providers are configured. (iisisrael) * bug #26010 [CssSelector] For AND operator, the left operand should have parentheses, not only right operand (Arnaud CHASSEUX) * bug #26000 Fixed issue #25985 (KevinFrantz) * bug #25996 Don't show wanna-be-private services as public in debug:container (chalasr) * bug #25914 [HttpKernel] collect extension information as late as possible (xabbuh) * bug #25981 [DI] Fix tracking of source class changes for lazy-proxies (nicolas-grekas) * bug #25971 [Debug] Fix bad registration of exception handler, leading to mem leak (nicolas-grekas) * bug #25962 [Routing] Fix trailing slash redirection for non-safe verbs (nicolas-grekas) * bug #25948 [Form] Fixed empty data on expanded ChoiceType and FileType (HeahDude) * bug #25978 Deterministic proxy names (lstrojny) * bug #25972 support sapi_windows_vt100_support for php 7.2+ (jhdxr) * bug #25744 [TwigBridge] Allow label translation to be safe (MatTheCat) * 3.4.4 (2018-01-29) * bug #25932 Don't stop PSR-4 service discovery if a parent class is missing (derrabus) * bug #25922 [HttpFoundation] Use the correct syntax for session gc based on Pdo driver (tanasecosminromeo) * bug #25933 Disable CSP header on exception pages only in debug (ostrolucky) * bug #25926 [Form] Fixed Button::setParent() when already submitted (HeahDude) * bug #25927 [Form] Fixed submitting disabled buttons (HeahDude) * bug #25397 [Console] Provide a DX where an array could be passed (Simperfit) * bug #25858 [DI] Fix initialization of legacy containers by delaying include_once (nicolas-grekas) * bug #25891 [DependencyInjection] allow null values for root nodes in YAML configs (xabbuh) * bug #24864 Have weak_vendors ignore deprecations from outside (greg0ire) * bug #25848 [Validator] add missing parent isset and add test (Simperfit) * bug #25869 [Process] Skip environment variables with false value in Process (francoispluchino) * bug #25864 [Yaml] don't split lines on carriage returns when dumping (xabbuh) * bug #25861 do not conflict with egulias/email-validator 2.0+ (xabbuh) * bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric) * bug #25837 [SecurityBundle] Don't register in memory users as services (chalasr) * bug #25835 [HttpKernel] DebugHandlersListener should always replace the existing exception handler (nicolas-grekas) * bug #25829 [Debug] Always decorate existing exception handlers to deal with fatal errors (nicolas-grekas) * bug #25823 [Security] Notify that symfony/expression-language is not installed if ExpressionLanguage is used (giovannialbero1992) * bug #25824 Fixing a bug where the dump() function depended on bundle ordering (weaverryan) * bug #25763 [OptionsResolver] Fix options resolver with array allowed types (mcg-web) * bug #25789 Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen) * bug #25822 [Cache] Fix handling of apcu_fetch() edgy behavior (nicolas-grekas) * bug #25816 Problem in phar see mergerequest #25579 (betzholz) * bug #25781 [Form] Disallow transform dates beyond the year 9999 (curry684) * bug #25287 [Serializer] DateTimeNormalizer handling of null and empty values (returning it instead of new object) (Simperfit) * bug #25249 [Form] Avoid button label translation when it's set to false (TeLiXj) * bug #25127 [TwigBridge] Pass the form-check-inline in parent (Simperfit) * bug #25812 Copied NO language files to the new NB locale (derrabus) * bug #25753 [Console] Fix restoring exception handler (nicolas-grekas, fancyweb) * bug #25801 [Router] Skip anonymous classes when loading annotated routes (pierredup) * bug #25508 [FrameworkBundle] Auto-enable CSRF if the component *+ session* are loaded (nicolas-grekas) * bug #25657 [Security] Fix fatal error on non string username (chalasr) * bug #25791 [Routing] Make sure we only build routes once (sroze) * bug #25799 Fixed Request::__toString ignoring cookies (Toflar) * bug #25755 [Debug] prevent infinite loop with faulty exception handlers (nicolas-grekas) * bug #25771 [Validator] 19 digits VISA card numbers are valid (xabbuh) * bug #25751 [FrameworkBundle] Add the missing `enabled` session attribute (sroze) * bug #25750 [HttpKernel] Turn bad hosts into 400 instead of 500 (nicolas-grekas) * bug #25699 [HttpKernel] Fix session handling: decouple "save" from setting response "private" (nicolas-grekas) * bug #25490 [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR (diversantvlz) * bug #25737 [TwigBridge] swap filter/function and package names (xabbuh) * bug #25731 [HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler (nicolas-grekas) * bug #25733 [HttpKernel] Fix compile error when a legacy container is fresh again (nicolas-grekas) * bug #25709 Tweaked some styles in the profiler tables (javiereguiluz) * bug #25719 [HttpKernel] Uses cookies to track the requests redirection (sroze) * bug #25696 [FrameworkBundle] Fix using "annotations.cached_reader" in after-removing passes (nicolas-grekas) * feature #25669 [Security] Fail gracefully if the security token cannot be unserialized from the session (thewilkybarkid) * bug #25700 Run simple-phpunit with --no-suggest option (ro0NL) * 3.4.3 (2018-01-05) * bug #25685 Use triggering file to determine weak vendors if when the test is run in a separate process (alexpott) * bug #25671 Remove randomness from dumped containers (nicolas-grekas) * bug #25532 [HttpKernel] Disable CSP header on exception pages (ostrolucky) * bug #25678 [WebProfilerBundle] set the var in the right scope (Jochen Mandl) * bug #25491 [Routing] Use the default host even if context is empty (sroze) * bug #25672 [WebServerBundle] use interface_exists instead of class_exists (kbond) * bug #25662 Dumper shouldn't use html format for phpdbg / cli-server (jhoff) * bug #25529 [Validator] Fix access to root object when using composite constraint (ostrolucky) * bug #25404 [Form] Remove group options without data on debug:form command (yceruto) * bug #25430 Fixes for Oracle in PdoSessionHandler (elislenio) * bug #25117 [FrameworkBundle] Make cache:clear "atomic" and consistent with cache:warmup (hkdobrev) * bug #25583 [HttpKernel] Call Response->setPrivate() instead of sending raw header() when session is started (Toflar) * bug #25601 [TwigBundle/Brige] catch missing requirements to throw meaningful exceptions (nicolas-grekas) * bug #25547 [DX][DependencyInjection] Suggest to write an implementation if the interface cannot be autowired (sroze) * bug #25599 Add application/ld+json format associated to json (vincentchalamon) * bug #25623 [HttpFoundation] Fix false-positive ConflictingHeadersException (nicolas-grekas) * bug #25624 [WebServerBundle] Fix escaping of php binary with arguments (nicolas-grekas) * bug #25604 Add check for SecurityBundle in createAccessDeniedException (FGM) * bug #25591 [HttpKernel] fix cleaning legacy containers (nicolas-grekas) * bug #25526 [WebProfilerBundle] Fix panel break when stopwatch component is not installed. (umulmrum, javiereguiluz) * bug #25606 Updating message to inform the user how to install the component (weaverryan) * bug #25571 [SecurityBundle] allow auto_wire for SessionAuthenticationStrategy class (xavren) * bug #25567 [Process] Fix setting empty env vars (nicolas-grekas) * bug #25407 [Console] Commands with an alias should not be recognized as ambiguous (Simperfit) * bug #25523 [WebServerBundle] fix a bug where require would not require the good file because of env (Simperfit) * bug #25559 [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions (nicolas-grekas) * bug #25552 [WebProfilerBundle] Let fetch() cast URL to string (ro0NL) * bug #25521 [Console] fix a bug when you are passing a default value and passing -n would output the index (Simperfit) * 3.4.2 (2017-12-15) * bug #25489 [FrameworkBundle] remove esi/ssi renderers if inactive (dmaicher) * bug #25502 Fixing wrong class_exists on interface (weaverryan) * bug #25427 Preserve percent-encoding in URLs when performing redirects in the UrlMatcher (mpdude) * bug #25480 [FrameworkBundle] add missing validation options to XSD file (xabbuh) * bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit) * bug #25425 When available use AnnotationRegistry::registerUniqueLoader (jrjohnson) * bug #25474 [DI] Optimize Container::get() for perf (nicolas-grekas) * bug #24594 [Translation] Fix InvalidArgumentException when using untranslated plural forms from .po files (BjornTwachtmann) * bug #25233 [TwigBridge][Form] Fix hidden currency element with Bootstrap 3 theme (julienfalque) * bug #25413 [HttpKernel] detect deprecations thrown by container initialization during tests (nicolas-grekas) * bug #25408 [Debug] Fix catching fatal errors in case of nested error handlers (nicolas-grekas) * bug #25330 [HttpFoundation] Support 0 bit netmask in IPv6 (`::/0`) (stephank) * bug #25378 [VarDumper] Fixed file links leave blank pages when ide is configured (antalaron) * bug #25410 [HttpKernel] Fix logging of post-terminate errors/exceptions (nicolas-grekas) * bug #25417 [Process] Dont rely on putenv(), it fails on ZTS PHP (nicolas-grekas) * bug #25333 [DI] Impossible to set an environment variable and then an array as container parameter (Phantas0s) * bug #25447 [Process] remove false-positive BC breaking exception on Windows (nicolas-grekas) * bug #25381 [DI] Add context to service-not-found exceptions thrown by service locators (nicolas-grekas) * bug #25438 [Yaml] empty lines don't count for indent detection (xabbuh) * bug #25412 Extend Argon2i support check to account for sodium_compat (mbabker) * bug #25389 [Yaml] fix some edge cases with indented blocks (xabbuh) * bug #25396 [Form] Fix debug:form command definition (yceruto) * bug #25398 [HttpFoundation] don't prefix cookies with "Set-Cookie:" (pableu) * bug #25354 [DI] Fix non-string class handling in PhpDumper (nicolas-grekas, sroze) * bug #25340 [Serializer] Unset attributes when creating child context (dunglas) * bug #25325 [Yaml] do not evaluate PHP constant names (xabbuh) * bug #25380 [FrameworkBundle][Cache] register system cache clearer only if it's used (xabbuh) * bug #25323 [ExpressionLanguage] throw an SyntaxError instead of an undefined index notice (Simperfit) * bug #25363 [HttpKernel] Disable inlining on PHP 5 (nicolas-grekas) * bug #25364 [DependencyInjection] Prevent a loop in aliases within the `findDefinition` method (sroze) * bug #25337 Remove Exclusive Lock That Breaks NFS Caching (brianfreytag) * 3.4.1 (2017-12-04) * bug #25304 [Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argv (ricknox) * bug #25272 [SecurityBundle] fix setLogoutOnUserChange calls for context listeners (dmaicher) * bug #25282 [DI] Register singly-implemented interfaces when doing PSR-4 discovery (nicolas-grekas) * bug #25274 [Security] Adding a GuardAuthenticatorHandler alias (weaverryan) * bug #25308 [FrameworkBundle] Fix a bug where a color tag will be shown when passing an antislash (Simperfit) * bug #25278 Fix for missing whitespace control modifier in form layout (kubawerlos) * bug #25306 [Form][TwigBridge] Fix collision between view properties and form fields (yceruto) * bug #25305 [Form][TwigBridge] Fix collision between view properties and form fields (yceruto) * bug #25236 [Form][TwigBridge] Fix collision between view properties and form fields (yceruto) * bug #25312 [DI] Fix deep-inlining of non-shared refs (nicolas-grekas) * bug #25309 [Yaml] parse newlines in quoted multiline strings (xabbuh) * bug #25313 [DI] Fix missing unset leading to false-positive circular ref (nicolas-grekas) * bug #25285 [DI] Throw an exception if Expression Language is not installed (sroze) * bug #25241 [Yaml] do not eagerly filter comment lines (xabbuh) * bug #25297 [Validator] Fixed the @Valid(groups={"group"}) against null exception case (vudaltsov) * bug #25255 [Console][DI] Fail gracefully (nicolas-grekas) * bug #25264 [DI] Trigger deprecation when setting a to-be-private synthetic service (nicolas-grekas) * bug #25258 [link] Prevent warnings when running link with 2.7 (dunglas) * bug #25244 [DI] Add missing deprecation when fetching private services from ContainerBuilder (nicolas-grekas) * bug #24750 [Validator] ExpressionValidator should use OBJECT_TO_STRING (Simperfit) * bug #25247 [DI] Fix false-positive circular exception (nicolas-grekas) * bug #25226 [HttpKernel] Fix issue when resetting DumpDataCollector (Pierstoval) * bug #25230 Use a more specific file for detecting the bridge (greg0ire) * bug #25232 [WebProfilerBundle] [TwigBundle] Fix Profiler breaking XHTML pages (tistre) * 3.4.0 (2017-11-30) * bug #25220 [HttpFoundation] Add Session::isEmpty(), fix MockFileSessionStorage to behave like the native one (nicolas-grekas) * bug #25209 [VarDumper] Dont use empty(), it chokes on eg GMP objects (nicolas-grekas) * bug #25200 [HttpKernel] Arrays with scalar values passed to ESI fragment renderer throw deprecation notice (Simperfit) * bug #25201 [HttpKernel] Add a better error messages when passing a private or non-tagged controller (Simperfit) * bug #25217 [Dotenv] Changed preg_match flags from null to 0 (deekthesqueak) * bug #25180 [DI] Fix circular reference when using setters (nicolas-grekas) * bug #25204 [DI] Clear service reference graph (nicolas-grekas) * bug #25203 [DI] Fix infinite loop in InlineServiceDefinitionsPass (nicolas-grekas) * bug #25185 [Serializer] Do not cache attributes if `attributes` in context (sroze) * bug #25190 [HttpKernel] Keep legacy container files for concurrent requests (nicolas-grekas) * bug #25182 [HttpFoundation] AutExpireFlashBag should not clear new flashes (Simperfit, sroze) * bug #25174 [Translation] modify definitions only if the do exist (xabbuh) * bug #25179 [FrameworkBundle][Serializer] Remove YamlEncoder definition if Yaml component isn't installed (ogizanagi) * bug #25160 [DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist (dunglas) * bug #25163 [DI] Fix tracking of env vars in exceptions (nicolas-grekas) * bug #25162 [HttpKernel] Read $_ENV when checking SHELL_VERBOSITY (nicolas-grekas) * bug #25158 [DI] Remove unreachable code (GawainLynch) * bug #25152 [Form] Don't rely on `Symfony\Component\HttpFoundation\File\File` if http-foundation isn't in FileType (issei-m) * bug #24987 [Console] Fix global console flag when used in chain (Simperfit) * bug #25137 Adding checks for the expression language (weaverryan) * bug #25151 [FrameworkBundle] Automatically enable the CSRF protection if CSRF manager exists (sroze) * bug #25043 [Yaml] added ability for substitute aliases when mapping is on single line (Michał Strzelecki, xabbuh) * 3.4.0-RC2 (2017-11-24) * bug #25146 [DI] Dont resolve envs in service ids (nicolas-grekas) * bug #25113 [Routing] Fix "config-file-relative" annotation loader resources (nicolas-grekas, sroze) * bug #25065 [FrameworkBundle] Update translation commands to work with default paths (yceruto) * bug #25109 Make debug:container search command case-insensitive (jzawadzki) * bug #25121 [FrameworkBundle] Fix AssetsInstallCommand (nicolas-grekas) * bug #25102 [Form] Fixed ContextErrorException in FileType (chihiro-adachi) * bug #25130 [DI] Fix handling of inlined definitions by ContainerBuilder (nicolas-grekas) * bug #25119 [DI] Fix infinite loop when analyzing references (nicolas-grekas) * bug #25094 [FrameworkBundle][DX] Display a nice error message if an enabled component is missing (derrabus) * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) * bug #25097 [Bridge\PhpUnit] Turn "preserveGlobalState" to false by default, revert "Blacklist" removal (nicolas-grekas) * 3.4.0-RC1 (2017-11-21) * bug #25077 [Bridge/Twig] Let getFlashes starts the session (MatTheCat) * bug #25082 [HttpKernel] Disable container inlining when legacy inlining has been used (nicolas-grekas) * bug #25072 [Bridge/PhpUnit] Remove trailing "\n" from ClockMock::microtime(false) (joky) * bug #25069 [Debug] Fix undefined variable $lightTrace (nicolas-grekas) * bug #25053 [Serializer] Fixing PropertyNormalizer supports parent properties (Christopher Hertel) * bug #25055 [DI] Analyze setter-circular deps more precisely (nicolas-grekas) * feature #25056 [Bridge/PhpUnit] Sync the bridge version installed in vendor/ and in phpunit clone (nicolas-grekas) * bug #25045 [SecurityBundle] Don't trigger auto-picking notice if provider is set per listener (chalasr) * bug #25033 [FrameworkBundle] Dont create empty bundles directory by default (ro0NL) * bug #25037 [DI] Skip hot_path tag for deprecated services as their class might also be (nicolas-grekas) * bug #25038 [Cache] Memcached options should ignore "lazy" (nicolas-grekas) * bug #25014 Move deprecation under use statements (greg0ire) * bug #25030 [Console] Fix ability to disable lazy commands (chalasr) * bug #25032 [Bridge\PhpUnit] Disable broken auto-require mechanism of phpunit (nicolas-grekas) * bug #25027 [FrameworkBundle] Hide server:log command based on deps (sroze) * bug #24991 [DependencyInjection] Single typed argument can be applied on multiple parameters (nicolas-grekas, sroze) * bug #24983 [Validator] enter the context in which to validate (xabbuh) * bug #24956 Fix ambiguous pattern (weltling) * bug #24732 [DependencyInjection] Prevent service:method factory notation in PHP config (vudaltsov) * bug #24979 [HttpKernel] remove services resetter even when it's an alias (xabbuh) * bug #24972 [HttpKernel] Fix service arg resolver for controllers as array callables (sroze, nicolas-grekas) * bug #24971 [FrameworkBundle] Empty event dispatcher earlier in CacheClearCommand (nicolas-grekas) * security #24995 Validate redirect targets using the session cookie domain (nicolas-grekas) * security #24994 Prevent bundle readers from breaking out of paths (xabbuh) * security #24993 Ensure that submitted data are uploaded files (xabbuh) * security #24992 Namespace generated CSRF tokens depending of the current scheme (dunglas) * bug #24954 [DI] Fix dumping with custom base class (nicolas-grekas) * bug #24952 [HttpFoundation] Fix session-related BC break (nicolas-grekas, sroze) * bug #24943 [FrameworkBundle] Wire the translation.reader service instead of deprecated translation.loader in commands (ogizanagi) * 3.4.0-BETA4 (2017-11-12) * bug #24874 [TwigBridge] Fixed the .form-check-input class in the bs4 templates (vudaltsov) * bug #24929 [Console] Fix traversable autocomplete values (ro0NL) * feature #24860 [FrameworkBundle] Add default translations path option and convention (yceruto) * bug #24921 [Debug] Remove false-positive deprecation from DebugClassLoader (nicolas-grekas) * bug #24856 [FrameworkBundle] Add default mapping path for validator component in bundle-less app (yceruto) * bug #24833 [FrameworkBundle] Add default mapping path for serializer component in bundle-less app (yceruto) * bug #24908 [WebServerBundle] Prevent console.terminate from being fired when server:start finishes (kbond) * bug #24888 [FrameworkBundle] Specifically inject the debug dispatcher in the collector (ogizanagi) * bug #24909 [Intl] Update ICU data to 60.1 (jakzal) * bug #24870 [YAML] Allow to parse custom tags when linting yaml files (pierredup) * bug #24910 [HttpKernel][Debug] Remove noise from stack frames of deprecations (nicolas-grekas) * bug #24906 [Bridge/ProxyManager] Remove direct reference to value holder property (nicolas-grekas) * feature #24887 [Cache][Lock] Add RedisProxy for lazy Redis connections (nicolas-grekas) * bug #24633 [Config] Fix cannotBeEmpty() (ro0NL) * bug #24900 [Validator] Fix Costa Rica IBAN format (Bozhidar Hristov) * bug #24904 [Validator] Add Belarus IBAN format (Bozhidar Hristov) * bug #24837 [TwigBridge] [Bootstrap 4] Fix validation error design for expanded choiceType (ostrolucky) * bug #24878 [HttpFoundation] Prevent PHP from sending Last-Modified on session start (nicolas-grekas) * bug #24881 [WebserverBundle] fixed the bug that caused that the webserver would … (Serkan Yildiz) * bug #24850 [DI] Fix cannot bind env var (ogizanagi) * bug #24851 [TwigBridge] Fix BC break due required twig environment (ro0NL) * 3.4.0-BETA3 (2017-11-05) * bug #24531 [HttpFoundation] Fix forward-compat of NativeSessionStorage with PHP 7.2 (sroze) * bug #24828 [DI] Fix the "almost-circular refs" fix (nicolas-grekas) * bug #24665 Fix dump panel hidden when closing a dump (julienfalque) * bug #24802 [TwigBridge] [Bootstrap 4] Fix hidden errors (ostrolucky) * bug #24816 [Serializer] Fix extra attributes when no group specified (ogizanagi) * bug #24822 [DI] Fix "almost-circular" dependencies handling (nicolas-grekas) * bug #24821 symfony/form auto-enables symfony/validator, even when not present (weaverryan) * bug #24824 [FrameworkBundle][Config] fix: do not add resource checkers for no-debug (dmaicher) * bug #24814 [Intl] Make intl-data tests pass and save language aliases again (jakzal) * bug #24810 [Serializer] readd default argument value (xabbuh) * bug #24809 [Config] Fix dump of config references for deprecated nodes (chalasr) * bug #24796 [PhpUnitBridge] Fixed fatal error in CoverageListener when something goes wrong in Test::setUpBeforeClass (lyrixx) * bug #24774 [HttpKernel] Let the storage manage the session starts (sroze) * bug #24735 [VarDumper] fix trailling comma when dumping an exception (Simperfit) * bug #24770 [Validator] Fix TraceableValidator is reset on data collector instantiation (ogizanagi) * bug #24764 [HttpFoundation] add Early Hints to Reponse to fix test (Simperfit) * bug #24759 Removes \n or space when $context/$extra are empty (kirkmadera) * bug #24758 Throwing exception if redis and predis unavailable (aequasi) * 3.4.0-BETA2 (2017-10-30) * bug #24728 [Bridge\Twig] fix bootstrap checkbox_row to render properly & remove spaceless (arkste) * bug #24709 [HttpKernel] Move services reset to Kernel::handle()+boot() (nicolas-grekas) * bug #24703 [TwigBridge] Bootstrap 4 form theme fixes (vudaltsov) * bug #24744 debug:container --types: Fix bug with non-existent classes (weaverryan) * bug #24747 [VarDumper] HtmlDumper: fix collapsing nodes with depth < maxDepth (ogizanagi) * bug #24743 [FrameworkBundle] Do not activate the cache if Doctrine's cache is not present (sroze) * bug #24605 [FrameworkBundle] Do not load property_access.xml if the component isn't installed (ogizanagi) * bug #24710 [TwigBridge] Fix template paths in profiler (ro0NL) * bug #24706 [DependencyInjection] Add the possibility to disable assets via xml (renatomefi) * bug #24696 Ensure DeprecationErrorHandler::collectDeprecations() is triggered (alexpott) * bug #24711 [TwigBridge] Re-add Bootstrap 3 Checkbox Layout (arkste) * bug #24713 [FrameworkBundle] fix CachePoolPrunerPass to use correct command service id (kbond) * bug #24686 Fix $_ENV/$_SERVER precedence in test framework (fabpot) * bug #24691 [HttpFoundation] Fix caching of session-enabled pages (nicolas-grekas) * bug #24606 [HttpFoundation] Fix FileBag issue with associative arrays (enumag) * bug #24673 [DI] Throw when a service name or an alias contains dynamic values (prevent an infinite loop) (dunglas) * bug #24684 [Security] remove invalid deprecation notice on AbstractGuardAuthenticator::supports() (kbond) * bug #24681 Fix isolated error handling (alexpott) * bug #24575 Ensure that PHPUnit's error handler is still working in isolated tests (alexpott) * bug #24597 [PhpUnitBridge] fix deprecation triggering test detection (xabbuh) * feature #24671 [DI] Handle container.autowiring.strict_mode to opt-out from legacy autowiring (nicolas-grekas) * bug #24660 Escape trailing \ in QuestionHelper autocompletion (kamazee) * bug #24624 [Security] Fix missing BC layer for AbstractGuardAuthenticator::getCredentials() (chalasr) * bug #24598 Prefer line formatter on missing cli dumper (greg0ire) * bug #24635 [DI] Register default env var provided types (ro0NL) * bug #24620 [FrameworkBundle][Workflow] Fix deprectation when checking workflow.registry service in dump command (Jean-Beru) * bug #24644 [Security] Fixed auth provider authenticate() cannot return void (glye) * bug #24642 [Routing] Fix resource miss (dunglas) * bug #24608 Adding the Form default theme files to be warmed up in Twig's cache (weaverryan) * bug #24626 streamed response should return $this (DQNEO) * bug #24630 [WebServerBundle] Prevent commands from being registered by convention (chalasr) * bug #24589 Username and password in basic auth are allowed to contain '.' (Richard Quadling) * bug #24566 Fixed unsetting from loosely equal keys OrderedHashMap (maryo) * bug #24570 [Debug] Fix same vendor detection in class loader (Jean-Beru) * bug #24573 Fixed pathinfo calculation for requests starting with a question mark. (syzygymsu) * bug #24565 [Serializer] YamlEncoder: throw if the Yaml component isn't installed (dunglas) * bug #24563 [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed (dunglas) * bug #24571 [PropertyInfo] Add support for the iterable type (dunglas) * bug #24579 pdo session fix (mxp100) * bug #24536 [Security] Reject remember-me token if UserCheckerInterface::checkPostAuth() fails (kbond) * 3.4.0-BETA1 (2017-10-18) * feature #24583 Adding a new debug:autowiring command (weaverryan) * feature #24523 [HttpFoundation] Make sessions secure and lazy (nicolas-grekas) * feature #22610 [Form] [TwigBridge] Added option to disable usage of default themes when rendering a form (emodric) * feature #23112 [OptionsResolver] Support array of types in allowed type (pierredup) * feature #24321 added ability to handle parent classes for PropertyNormalizer (ivoba) * feature #24505 [HttpKernel] implement reset() in DumpDataCollector (xabbuh) * feature #24425 [Console][HttpKernel] Handle new SHELL_VERBOSITY env var, also configures the default logger (nicolas-grekas) * feature #24387 [FORM] Prevent forms from extending itself as a parent (pierredup) * feature #24484 [DI] Throw accurate failures when accessing removed services (nicolas-grekas) * feature #24208 [Form] Display option definition from a given form type (yceruto, ogizanagi) * feature #23499 [Workflow] add guard is_valid() method support (alain-flaus, lyrixx) * feature #24388 [Security] Look at headers for switch_user username (chalasr) * feature #23708 Added deprecation to cwd not existing Fixes #18249 (alexbowers) * feature #24443 [Session] deprecate MemcacheSessionHandler (Tobion) * feature #24409 [Bridge\Doctrine][FrameworkBundle] Deprecate some remaining uses of ContainerAwareTrait (nicolas-grekas) * feature #24438 [Session][VarDumper] Deprecate accepting legacy mongo extension (Tobion) * feature #24389 [DoctrineBridge] Deprecate dbal session handler (Tobion) * feature #16835 [Security] Add Guard authenticator method (Amo, chalasr) * feature #24289 [FrameworkBundle][HttpKernel] Reset profiler (derrabus) * feature #24144 [FrameworkBundle] Expose dotenv in bin/console about (ro0NL) * feature #24403 [FrameworkBundle][Routing] Show welcome message if no routes are configured (yceruto) * feature #22679 [Form] Add tel and color types (apetitpa) * feature #23845 [Validator] Add unique entity violation cause (Ilya Vertakov) * feature #22132 [Lock] Automaticaly release lock when user forget it (jderusse) * feature #21751 Bootstrap4 support for Twig form theme (hiddewie, javiereguiluz) * feature #24383 [FrameworkBundle] Don't clear app pools on cache:clear (nicolas-grekas) * feature #24148 [Form] Hide label button when its setted to false (TeLiXj) * feature #24378 [SecurityBundle] Deprecate auto picking the first provider (ogizanagi) * feature #24260 [Security] Add impersonation support for stateless authentication (chalasr) * feature #24300 [HttpKernel][FrameworkBundle] Add a minimalist default PSR-3 logger (dunglas) * feature #21604 [Security] Argon2i Password Encoder (zanbaldwin) * feature #24372 [DowCrawler] Default to UTF-8 when possible (nicolas-grekas) * feature #24264 [TwigBundle] Improve the overriding of bundle templates (yceruto) * feature #24197 [Translation] Moved PhpExtractor and PhpStringTokenParser to Translation component (Nyholm) * feature #24362 [HttpKernel] Deprecate some compiler passes in favor of tagged iterator args (nicolas-grekas) * feature #21027 [Asset] Provide default context (ro0NL) * feature #22200 [DI] Reference tagged services in config (ro0NL) * feature #24337 Adding a shortcuts for the main security functionality (weaverryan, javiereguiluz) * feature #24358 [TwigBundle] register an identity translator as fallback (xabbuh) * feature #24357 [Yaml] include file and line no in deprecation message (xabbuh) * feature #24330 [FrameworkBundle] register class metadata factory alias (xabbuh) * feature #24349 [SecurityBundle] Add missing AclSchemaListener deprecation (ogizanagi) * feature #24202 [Filesystem] deprecate relative paths in makePathRelative() (xabbuh) * feature #21716 [Serializer] Add Support for `object_to_populate` in CustomNormalizer (chrisguitarguy) * feature #21960 Remove Validator\TypeTestCase and add validator logic to base TypeTestCase (pierredup) * feature #22113 [Lock] Include lock component in framework bundle (jderusse) * feature #24236 [WebProfilerBundle] Render file links for twig templates (ro0NL) * feature #21239 [Serializer] throw more specific exceptions (xabbuh) * feature #24256 CsvEncoder handling variable structures and custom header order (Oliver Hoff) * feature #23471 [Finder] Add a method to check if any results were found (duncan3dc) * feature #23149 [PhpUnitBridge] Added a CoverageListener to enhance the code coverage report (lyrixx) * feature #24318 [SecurityBundle] Deprecate ACL related code (chalasr) * feature #24335 [Security][SecurityBundle] Deprecate the HTTP digest auth (ogizanagi) * feature #21951 [Security][Firewall] Passing the newly generated security token to the event during user switching (klandaika) * feature #23485 [Config] extracted the xml parsing from XmlUtils::loadFile into XmlUtils::parse (Basster) * feature #22890 [HttpKernel] Add ability to configure catching exceptions for Client (kbond) * feature #24239 [HttpFoundation] Deprecate compatibility with PHP <5.4 sessions (afurculita) * feature #23882 [Security] Deprecated not being logged out after user change (iltar) * feature #24200 Added an alias for FlashBagInterface in config (tifabien) * feature #24295 [DI][DX] Throw exception on some ContainerBuilder methods used from extensions (ogizanagi) * feature #24253 [Yaml] support parsing files (xabbuh) * feature #24290 Adding Definition::addError() and a compiler pass to throw errors as exceptions (weaverryan) * feature #24301 [DI] Add AutowireRequiredMethodsPass to fix bindings for `@required` methods (nicolas-grekas) * feature #24226 [Cache] Add ResettableInterface to allow resetting any pool's local state (nicolas-grekas) * feature #24303 [FrameworkBundle] allow forms without translations and validator (xabbuh) * feature #24291 [SecurityBundle] Reset the authentication token between requests (derrabus) * feature #24280 [VarDumper] Make `dump()` a little bit more easier to use (freekmurze) * feature #24277 [Serializer] Getter for extra attributes in ExtraAttributesException (mdeboer) * feature #24257 [HttpKernel][DI] Enable Kernel to implement CompilerPassInterface (nicolas-grekas) * feature #23834 [DI] Add "PHP fluent format" for configuring the container (nicolas-grekas) * feature #24180 [Routing] Add PHP fluent DSL for configuring routes (nicolas-grekas) * feature #24232 [Bridge\Doctrine] Add "DoctrineType::reset()" method (nicolas-grekas) * feature #24238 [DI] Turn services and aliases private by default, with BC layer (nicolas-grekas) * feature #23648 [Form] Add input + regions options to TimezoneType (ro0NL) * feature #24185 [Form] Display general forms information on debug:form (yceruto) * feature #23747 [Serializer][FrameworkBundle] Add a DateInterval normalizer (Lctrs) * feature #24193 [FrameworkBundle] Reset stopwatch between requests (derrabus) * feature #24160 [HttpKernel] Deprecate bundle inheritance (fabpot) * feature #24155 [FrameworkBundle][HttpKernel] Add DI tag for resettable services (derrabus) * feature #23625 Feature #23583 Add current and fallback locales in WDT / Profiler (nemoneph) * feature #24179 [TwigBundle] Add default templates directory and option to configure it (yceruto) * feature #24104 Make as many services private as possible (nicolas-grekas) * feature #18314 [Translation] added support for adding custom message formatter (aitboudad) * feature #24158 deprecated profiler.matcher configuration (fabpot) * feature #24131 [Console] Do not display short exception trace for common console exceptions (yceruto) * feature #24080 Deprecated the web_profiler.position option (javiereguiluz) * feature #24114 [SecurityBundle] Throw a meaningful exception when an undefined user provider is used inside a firewall (chalasr) * feature #24122 [DI] rename ResolveDefinitionTemplatesPass to ResolveChildDefinitionsPass (nicolas-grekas) * feature #23901 [DI] Allow processing env vars (nicolas-grekas) * feature #24093 [FrameworkBundle] be able to enable workflow support explicitly (xabbuh) * feature #24064 [TwigBridge] Show Twig's loader paths on debug:twig command (yceruto) * feature #23978 [Cache] Use options from Memcached DSN (Bukashk0zzz) * feature #24075 Implemented PruneableInterface on TagAwareAdapter (Toflar) * feature #21414 [Console] Display file and line on Exception (arno14) * feature #24068 [HttpKernel] Deprecate EnvParametersResource (ro0NL) * feature #22542 [Lock] Check TTL expiration in lock acquisition (jderusse) * feature #24031 [Routing] Add the possibility to define a prefix for all routes of a controller (fabpot) * feature #23967 [VarDumper] add force-collapse/expand + use it for traces (nicolas-grekas) * feature #24033 [DI] Add ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE (nicolas-grekas) * feature #24026 [Security] add impersonator_user to "User was reloaded" log message (gharlan) * feature #23603 [Cache] Add (pdo|chain) cache (adapter|simple) prune method (robfrawley) * feature #23694 [Form] Add debug:form command (yceruto) * feature #24028 [Yaml] mark some classes as final (xabbuh) * feature #22543 [Lock] Expose an expiringDate and isExpired method in Lock (jderusse) * feature #23667 [Translation] Create an TranslationReaderInterface and move TranslationLoader to TranslationComponent (Nyholm) * feature #24024 [config] Add ability to deprecate a node (sanpii) * feature #23668 [VarDumper] Add period caster (maidmaid) * feature #23991 [DI] Improve psr4-based service discovery (alternative implementation) (kbond) * feature #23947 [Translation] Adding the ability do load in xliff2.0 (Nyholm) * feature #23887 [Console] Allow commands to provide a default name for compile time registration (chalasr, nicolas-grekas) * feature #23874 [DI] Case sensitive parameter names (ro0NL) * feature #23936 Remove some sf2 references (fabpot) * feature #23680 [Webprofiler] Added blocks that allows extension of the profiler page. (Nyholm) * feature #23665 Create an interface for TranslationWriter (Nyholm) * feature #23890 [Translation] Adding the ability do dump in xliff2.0 (Nyholm) * feature #23862 [SecurityBundle] resolve class name parameter inside AddSecurityVotersPass (pjarmalavicius) * feature #23915 [DI] Allow get available services from service locator (Koc) * feature #23792 [HttpKernel][FrameworkBundle] Add RebootableInterface, fix and un-deprecate cache:clear with warmup (nicolas-grekas) * feature #23227 Add support for "controller" keyword for configuring routes controllers (voronkovich) * feature #23869 [Console] Made console command shortcuts case insensitive (thanosp) * feature #23855 [DI] Allow dumping inline services in Yaml (nicolas-grekas) * feature #23836 [FrameworkBundle] Catch Fatal errors in commands registration (chalasr) * feature #23805 [HttpKernel] Deprecated commands auto-registration (GuilhemN) * feature #23816 [Debug] Detect internal and deprecated methods (GuilhemN) * feature #23812 [FrameworkBundle] Allow micro kernel to subscribe events easily (ogizanagi) * feature #22187 [DependencyInjection] Support local binding (GuilhemN) * feature #23741 [DI] Generate one file per service factory (nicolas-grekas) * feature #23807 [Debug] Trigger a deprecation when using an internal class/trait/interface (GuilhemN) * feature #22587 [Workflow] Add transition completed event (izzyp) * feature #23624 [FrameworkBundle] Commands as a service (ro0NL) * feature #21111 [Validator] add groups support to the Valid constraint (xabbuh) * feature #20361 [Config] Enable cannotBeEmpty along with requiresAtLeastOneElement (ro0NL) * feature #23712 [DependencyInjection] Deprecate autowiring service auto-registration (GuilhemN) * feature #23719 Autoconfigure instances of ArgumentValueResolverInterface (BPScott) * feature #23706 [Webprofiler] Improve sql explain table display (mimol91) * feature #23724 [Lock] Deprecate Filesystem/LockHandler (jderusse) * feature #23593 [Workflow] Adding workflow name to the announce event (Nyholm) * feature #20496 [Form] Allow pass filter callback to delete_empty option. (Koc) * feature #23451 [Cache] Add (filesystem|phpfiles) cache (adapter|simple) prune method and prune command (robfrawley) * feature #23519 [TwigBundle] Commands as a service (ro0NL) * feature #23591 [VarDumper] Add time zone caster (maidmaid) * feature #23510 [Console] Add a factory command loader for standalone application with lazy-loading needs (ogizanagi) * feature #23357 [VarDumper] Add interval caster (maidmaid) * feature #23550 [DebugBundle] Added min_depth to Configuration (james-johnston-thumbtack) * feature #23570 [FrameworkBundle] Make RouterCacheWarmer implement ServiceSubscriberInterface (nicolas-grekas) * feature #23437 [TwigBridge] deprecate TwigRenderer (Tobion) * feature #23515 [VarDumper] Added setMinDepth to VarCloner (james-johnston-thumbtack) * feature #23404 [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement (ogizanagi) * feature #21086 [MonologBridge] Add TokenProcessor (maidmaid) * feature #22576 [Validator] Allow to use a property path to get value to compare in comparison constraints (ogizanagi) * feature #22689 [DoctrineBridge] Add support for doctrin/dbal v2.6 types (jvasseur) * feature #22734 [Console] Add support for command lazy-loading (chalasr) * feature #19034 [Security] make it possible to configure a custom access decision manager service (xabbuh) * feature #23037 [TwigBundle] Added a RuntimeExtensionInterface to take advantage of autoconfigure (lyrixx) * feature #22176 [DI] Allow imports in string format for YAML (ro0NL) * feature #23295 [Security] Lazy load user providers (chalasr) * feature #23440 [Routing] Add matched and default parameters to redirect responses (artursvonda, Tobion) * feature #22832 [Debug] Deprecate support for stacked errors (mbabker) * feature #21469 [HttpFoundation] Find the original request protocol version (thewilkybarkid) * feature #23431 [Validator] Add min/max amount of pixels to Image constraint (akeeman) * feature #23223 Add support for microseconds in Stopwatch (javiereguiluz) * feature #22341 [BrowserKit] Emulate back/forward browser navigation (e-moe) * feature #22619 [FrameworkBundle][Translation] Move translation compiler pass (lepiaf) * feature #22620 [FrameworkBundle][HttpKernel] Move httpkernel pass (lepiaf) * feature #23337 [Component][Serializer][Normalizer] : Deal it with Has Method for the Normalizer/Denormalizer (jordscream) * feature #22588 [VarDumper] Add filter in VarDumperTestTrait (maidmaid) * feature #23288 [Yaml] deprecate the !str tag (xabbuh) * feature #23039 [Validator] Support for parsing PHP constants in yaml loader (mimol91) * feature #22431 [VarDumper] Add date caster (maidmaid) * feature #23285 [Stopwatch] Add a reset method (jmgq) * feature #23320 [WebServer] Allow * to bind all interfaces (as INADDR_ANY) (jpauli, fabpot) * feature #23272 [FrameworkBundle] disable unusable fragment renderers (xabbuh) * feature #23332 [Yaml] fix the displayed line number (fabpot, xabbuh) * feature #23026 [SecurityBundle] Add user impersonation info and exit action to the profiler (yceruto) * feature #22932 [HttpFoundation] Adds support for the immutable directive in the cache-control header (twoleds) * feature #22554 [Profiler][Validator] Add a validator panel in profiler (ogizanagi) * feature #22124 Shift responsibility for keeping Date header to ResponseHeaderBag (mpdude) * feature #23122 Xml encoder optional type cast (ragboyjr) * feature #23207 [FrameworkBundle] Allow .yaml file extension everywhere (ogizanagi) * feature #23076 [Validator] Adds support to check specific DNS record type for URL (iisisrael) * feature #22629 [Security] Trigger a deprecation when a voter is missing the VoterInterface (iltar) * feature #22636 [Routing] Expose request in route conditions, if needed and possible (ro0NL) * feature #22909 [Yaml] Deprecate using the non-specific tag (GuilhemN) * feature #23042 Consistent error handling in remember me services (lstrojny) * feature #22444 [Serializer] DateTimeNormalizer: allow to provide timezone (ogizanagi) * feature #23143 [DI] Reference instead of inline for array-params (nicolas-grekas) * feature #23154 [WebProfilerBundle] Sticky ajax window (ro0NL) * feature #23161 [FrameworkBundle] Deprecate useless --no-prefix option (chalasr) * feature #23105 [SecurityBundle][Profiler] Give info about called security listeners in profiler (chalasr) * feature #23148 [FrameworkBundle] drop hard dependency on the Stopwatch component (xabbuh) * feature #23131 [FrameworkBundle] Remove dependency on Doctrine cache (fabpot) * feature #23114 [SecurityBundle] Lazy load security listeners (chalasr) * feature #23111 [Process] Deprecate ProcessBuilder (nicolas-grekas) * feature #22675 [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS (ogizanagi) * feature #22917 [VarDumper] Cycle prev/next searching in HTML dumps (ro0NL) * feature #23044 Automatically enable the routing annotation loader (GuilhemN) * feature #22696 [PropertyInfo] Made ReflectionExtractor's prefix lists instance variables (neemzy) * feature #23035 Deprecate passing a concrete service in optional cache warmers (romainneutron) * feature #23036 Implement ServiceSubscriberInterface in optional cache warmers (romainneutron) * feature #23022 [Di] Remove closure-proxy arguments (nicolas-grekas) * feature #22903 [DI] Deprecate XML services without ID (ro0NL) * feature #22597 [Lock] Re-add the Lock component in 3.4 (jderusse) * feature #22803 [DI] Deprecate Container::initialized() for privates (ro0NL) * feature #22828 [Finder] Deprecate FilterIterator (ogizanagi) * feature #22826 [Validator] improve strict option value deprecation (xabbuh) symfony-3.4.6/CONTRIBUTING.md000066400000000000000000000017671324732107100154740ustar00rootroot00000000000000Contributing ------------ Symfony is an open source, community-driven project. If you'd like to contribute, please read the following documents: * [Reviewing issues/pull requests][0] * [Reporting a Bug][1] * [Submitting a Patch][2] * [Symfony Core Team][3] * [Security Issues][4] * [Running Symfony Tests][5] * [Our Backwards Compatibility Promise][6] * [Coding Standards][7] * [Conventions][8] [0]: https://symfony.com/doc/current/contributing/community/reviews.html [1]: https://symfony.com/doc/current/contributing/code/bugs.html [2]: https://symfony.com/doc/current/contributing/code/patches.html [3]: https://symfony.com/doc/current/contributing/code/core_team.html [4]: https://symfony.com/doc/current/contributing/code/security.html [5]: https://symfony.com/doc/current/contributing/code/tests.html [6]: https://symfony.com/doc/current/contributing/code/bc.html [7]: https://symfony.com/doc/current/contributing/code/standards.html [8]: https://symfony.com/doc/current/contributing/code/conventions.html symfony-3.4.6/CONTRIBUTORS.md000066400000000000000000001241001324732107100155050ustar00rootroot00000000000000CONTRIBUTORS ============ Symfony is the result of the work of many people who made the code better (see https://symfony.com/contributors for more information): - Fabien Potencier (fabpot) - Nicolas Grekas (nicolas-grekas) - Bernhard Schussek (bschussek) - Christian Flothmann (xabbuh) - Tobias Schultze (tobion) - Christophe Coevoet (stof) - Jordi Boggiano (seldaek) - Victor Berchet (victor) - Kévin Dunglas (dunglas) - Johannes S (johannes) - Jakub Zalas (jakubzalas) - Robin Chalas (chalas_r) - Kris Wallsmith (kriswallsmith) - Ryan Weaver (weaverryan) - Javier Eguiluz (javier.eguiluz) - Maxime Steinhausser (ogizanagi) - Hugo Hamon (hhamon) - Grégoire Pineau (lyrixx) - Abdellatif Ait boudad (aitboudad) - Romain Neutron (romain) - Pascal Borreli (pborreli) - Wouter De Jong (wouterj) - Joseph Bielawski (stloyd) - Karma Dordrak (drak) - Roland Franssen (ro0) - Lukas Kahwe Smith (lsmith) - Martin Hasoň (hason) - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - Jules Pietri (heah) - Eriksen Costa (eriksencosta) - Guilhem Niot (energetick) - Sarah Khalil (saro0h) - Jonathan Wage (jwage) - Diego Saint Esteben (dosten) - Alexandre Salomé (alexandresalome) - William Durand (couac) - ornicar - Francis Besset (francisbesset) - Iltar van der Berg (kjarli) - stealth35 ‏ (stealth35) - Hamza Amrouche (simperfit) - Alexander Mols (asm89) - Yonel Ceruto (yonelceruto) - Bulat Shakirzyanov (avalanche123) - Peter Rehm (rpet) - Saša Stamenković (umpirsky) - Matthias Pigulla (mpdude) - Henrik Bjørnskov (henrikbjorn) - Miha Vrhovnik - Diego Saint Esteben (dii3g0) - Dany Maillard (maidmaid) - Pierre du Plessis (pierredup) - Konstantin Kudryashov (everzet) - Kevin Bond (kbond) - Bilal Amarni (bamarni) - Alexander M. Turek (derrabus) - Jérémy DERUSSÉ (jderusse) - Florin Patan (florinpatan) - Samuel ROZE (sroze) - Gábor Egyed (1ed) - Michel Weimerskirch (mweimerskirch) - Andrej Hudec (pulzarraider) - Eric Clemmons (ericclemmons) - Jáchym Toušek (enumag) - Charles Sarrazin (csarrazi) - Titouan Galopin (tgalopin) - Konstantin Myakshin (koc) - Christian Raue - Tobias Nyholm (tobias) - Arnout Boks (aboks) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) - Douglas Greenshields (shieldo) - Issei Murasawa (issei_m) - Lee McDermott - Brandon Turner - Luis Cordova (cordoval) - Graham Campbell (graham) - Daniel Holmes (dholmes) - Dariusz Ruminski - Toni Uebernickel (havvg) - Bart van den Burg (burgov) - Jordan Alliot (jalliot) - Jérôme Tamarelle (gromnan) - John Wards (johnwards) - Fran Moreno (franmomu) - Antoine Hérault (herzult) - Paráda József (paradajozsef) - David Maicher (dmaicher) - Arnaud Le Blanc (arnaud-lb) - Maxime STEINHAUSSER - Vladimir Reznichenko (kalessil) - Michal Piotrowski (eventhorizon) - Tim Nagel (merk) - Brice BERNARD (brikou) - Baptiste Clavié (talus) - marc.weistroff - lenar - Alexander Schwenn (xelaris) - Włodzimierz Gajda (gajdaw) - Grégoire Paris (greg0ire) - Jacob Dreesen (jdreesen) - Florian Voutzinos (florianv) - Colin Frei - Adrien Brault (adrienbrault) - Tomáš Votruba (tomas_votruba) - Joshua Thijssen - Peter Kokot (maastermedia) - David Buchmann (dbu) - excelwebzone - Fabien Pennequin (fabienpennequin) - Gordon Franke (gimler) - Eric GELOEN (gelo) - Daniel Wehner (dawehner) - Tugdual Saunier (tucksaun) - Théo FIDRY (theofidry) - Robert Schönthal (digitalkaoz) - Florian Lonqueu-Brochard (florianlb) - Sebastiaan Stok (sstok) - Stefano Sala (stefano.sala) - Evgeniy (ewgraf) - Lars Strojny (lstrojny) - Alex Pott - Javier Spagnoletti (phansys) - Vincent AUBERT (vincent) - Juti Noppornpitak (shiroyuki) - Tigran Azatyan (tigranazatyan) - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) - Guilherme Blanco (guilhermeblanco) - Pablo Godel (pgodel) - Jérôme Vasseur (jvasseur) - Jérémie Augustin (jaugustin) - Andréia Bohner (andreia) - Julien Falque (julienfalque) - Rafael Dohms (rdohms) - Arnaud Kleinpeter (nanocom) - jwdeitch - Mikael Pajunen - Joel Wurtz (brouznouf) - Chris Wilkinson (thewilkybarkid) - Oleg Voronkovich - Philipp Wahala (hifi) - Vyacheslav Pavlov - Richard van Laak (rvanlaak) - Richard Shank (iampersistent) - Thomas Rabaix (rande) - Rouven Weßling (realityking) - Teoh Han Hui (teohhanhui) - Valentin Udaltsov (vudaltsov) - Clemens Tolboom - Helmer Aaviksoo - Hiromi Hishida (77web) - Matthieu Ouellette-Vachon (maoueh) - Michał Pipa (michal.pipa) - Dawid Nowak - Amal Raghav (kertz) - Jonathan Ingram (jonathaningram) - Artur Kotyrba - GDIBass - jeremyFreeAgent (Jérémy Romey) (jeremyfreeagent) - James Halsall (jaitsu) - Gabriel Caruso - Warnar Boekkooi (boekkooi) - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) - Daniel Espendiller - Possum - Dorian Villet (gnutix) - Sergey Linnik (linniksa) - Richard Miller (mr_r_miller) - Mario A. Alvarez Garcia (nomack84) - Dennis Benkert (denderello) - SpacePossum - Matthieu Napoli (mnapoli) - Benjamin Dulau (dbenjamin) - Mathieu Lemoine (lemoinem) - Christian Schmidt - Andreas Hucks (meandmymonkey) - Noel Guilbert (noel) - Marek Štípek (maryo) - Stepan Anchugov (kix) - bronze1man - sun (sun) - Larry Garfield (crell) - Gabriel Ostrolucký - Martin Schuhfuß (usefulthink) - apetitpa - Matthieu Bontemps (mbontemps) - apetitpa - Pierre Minnieur (pminnieur) - fivestar - Dominique Bongiraud - Jeremy Livingston (jeremylivingston) - Michael Lee (zerustech) - Matthieu Auger (matthieuauger) - Leszek Prabucki (l3l0) - François Zaninotto (fzaninotto) - Dustin Whittle (dustinwhittle) - jeff - John Kary (johnkary) - Justin Hileman (bobthecow) - Blanchon Vincent (blanchonvincent) - Michele Orselli (orso) - Tom Van Looy (tvlooy) - Sven Paulus (subsven) - Rui Marinho (ruimarinho) - Niels Keurentjes (curry684) - Eugene Wissner - Julien Brochet (mewt) - Tristan Darricau (nicofuma) - Michaël Perrin (michael.perrin) - Marcel Beerta (mazen) - gadelat (gadelat) - Loïc Faugeron - Jannik Zschiesche (apfelbox) - Hidde Wieringa (hiddewie) - Marco Pivetta (ocramius) - Rob Frawley 2nd (robfrawley) - julien pauli (jpauli) - Lorenz Schori - Sébastien Lavoie (lavoiesl) - Gregor Harlan (gharlan) - Dariusz - Francois Zaninotto - Alexander Kotynia (olden) - Daniel Tschinder - Marcos Sánchez - Elnur Abdurrakhimov (elnur) - Manuel Reinhard (sprain) - Danny Berger (dpb587) - Ruben Gonzalez (rubenrua) - Adam Prager (padam87) - Roman Marintšenko (inori) - Xavier Montaña Carreras (xmontana) - Mickaël Andrieu (mickaelandrieu) - Xavier Perez - Arjen Brouwer (arjenjb) - Katsuhiro OGAWA - Thomas Calvet (fancyweb) - Patrick McDougle (patrick-mcdougle) - Alif Rachmawadi - Alessandro Chitolina - Kristen Gilden (kgilden) - Pierre-Yves LEBECQ (pylebecq) - Jordan Samouh (jordansamouh) - Jakub Kucharovic (jkucharovic) - Uwe Jäger (uwej711) - Eugene Leonovich (rybakit) - Filippo Tessarotto - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) - GordonsLondon - Jan Sorgalla (jsor) - Ray - Tyson Andre - Nikolay Labinskiy (e-moe) - Leo Feyer - Chekote - Thomas Adam - Albert Casademont (acasademont) - Viktor Bocharskyi (bocharsky_bw) - Jhonny Lidfors (jhonne) - Diego Agulló (aeoris) - Andreas Schempp (aschempp) - DQNEO - jdhoek - Pavel Batanov (scaytrase) - Bob den Otter (bopp) - Nikita Konstantinov - Wodor Wodorski - Oskar Stark (oskarstark) - Thomas Lallement (raziel057) - Giorgio Premi - Beau Simensen (simensen) - Michael Hirschler (mvhirsch) - Robert Kiss (kepten) - Roumen Damianoff (roumen) - Antonio J. García Lagar (ajgarlag) - Benoît Burnichon (bburnichon) - Kim Hemsø Rasmussen (kimhemsoe) - Wouter Van Hecke - Jérôme Parmentier (lctrs) - Michael Babker (mbabker) - Peter Kruithof (pkruithof) - Michael Holm (hollo) - Marc Weistroff (futurecat) - Christian Schmidt - Yanick Witschi (toflar) - Edi Modrić (emodric) - Chad Sikorra (chadsikorra) - Chris Smith (cs278) - Florian Klein (docteurklein) - Manuel Kiessling (manuelkiessling) - Atsuhiro KUBO (iteman) - Andrew Moore (finewolf) - Bertrand Zuchuat (garfield-fr) - Gabor Toth (tgabi333) - realmfoo - Thomas Tourlourat (armetiz) - Andrey Esaulov (andremaha) - Grégoire Passault (gregwar) - Jerzy Zawadzki (jzawadzki) - Wouter J - Ismael Ambrosi (iambrosi) - Baptiste Lafontaine - François Pluchino (francoispluchino) - Aurelijus Valeiša (aurelijus) - Jan Decavele (jandc) - Gustavo Piltcher - Stepan Tanasiychuk (stfalcon) - Tiago Ribeiro (fixe) - Hidde Boomsma (hboomsma) - John Bafford (jbafford) - Adrian Rudnik (kreischweide) - Francesc Rosàs (frosas) - Massimiliano Arione (garak) - Julien Galenski (ruian) - Bongiraud Dominique - janschoenherr - Thomas Schulz (king2500) - Dariusz Rumiński - Berny Cantos (xphere81) - Thierry Thuon (lepiaf) - Ricard Clau (ricardclau) - Mark Challoner (markchalloner) - Gennady Telegin (gtelegin) - Ben Davies (bendavies) - Erin Millard - Artur Melo (restless) - Matthew Lewinski (lewinski) - Magnus Nordlander (magnusnordlander) - alquerci - Francesco Levorato - Vitaliy Zakharov (zakharovvi) - Tobias Sjösten (tobiassjosten) - Gyula Sallai (salla) - Inal DJAFAR (inalgnu) - Christian Gärtner (dagardner) - Tomasz Kowalczyk (thunderer) - François-Xavier de Guillebon (de-gui_f) - Damien Alexandre (damienalexandre) - Felix Labrecque - Yaroslav Kiliba - Maxime Veber (nek-) - Terje Bråten - Robbert Klarenbeek (robbertkl) - JhonnyL - David Badura (davidbadura) - hossein zolfi (ocean) - Clément Gautier (clementgautier) - Sanpi - Eduardo Gulias (egulias) - giulio de donato (liuggio) - ShinDarth - Stéphane PY (steph_py) - Philipp Kräutli (pkraeutli) - Kirill chEbba Chebunin (chebba) - Greg Thornton (xdissent) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) - Marek Kalnik (marekkalnik) - Vyacheslav Salakhutdinov (megazoll) - Hassan Amouhzi - Tamas Szijarto - Pavel Volokitin (pvolok) - Arthur de Moulins (4rthem) - Nicolas Dewez (nicolas_dewez) - Endre Fejes - Tobias Naumann (tna) - Daniel Beyer - Shein Alexey - Alex Rock Ancelet (pierstoval) - Romain Gautier (mykiwi) - Joe Lencioni - Daniel Tschinder - Kai - Lee Rowlands - Krzysztof Piasecki (krzysztek) - Maximilian Reichel (phramz) - Loick Piera (pyrech) - Karoly Negyesi (chx) - Ivan Kurnosov - Xavier HAUSHERR - Albert Jessurum (ajessu) - Laszlo Korte - Miha Vrhovnik - Alessandro Desantis - hubert lecorche (hlecorche) - Marc Morales Valldepérez (kuert) - Jean-Baptiste GOMOND (mjbgo) - Vadim Kharitonov (virtuozzz) - Oscar Cubo Medina (ocubom) - Karel Souffriau - Christophe L. (christophelau) - Anthon Pang (robocoder) - Emanuele Gaspari (inmarelibero) - Sébastien Santoro (dereckson) - Brian King - Frank de Jonge (frenkynet) - Michel Salib (michelsalib) - geoffrey - Steffen Roßkamp - Alexandru Furculita (afurculita) - Valentin Jonovs (valentins-jonovs) - Jeanmonod David (jeanmonod) - Christopher Davis (chrisguitarguy) - Jan Schumann - Niklas Fiekas - Markus Bachmann (baachi) - lancergr - Mihai Stancu - Olivier Dolbeau (odolbeau) - Jan Rosier (rosier) - Thomas Royer (cydonia7) - Arturs Vonda - Josip Kruslin - Asmir Mustafic (goetas) - vagrant - EdgarPE - Florian Pfitzer (marmelatze) - Asier Illarramendi (doup) - Andreas Braun - Chris Sedlmayr (catchamonkey) - Seb Koelen - Christoph Mewes (xrstf) - Vitaliy Tverdokhlib (vitaliytv) - Ariel Ferrandini (aferrandini) - Dirk Pahl (dirkaholic) - cedric lombardot (cedriclombardot) - Jonas Flodén (flojon) - Thomas Perez (scullwm) - Marcin Sikoń (marphi) - Dominik Zogg (dominik.zogg) - Marek Pietrzak - Luc Vieillescazes (iamluc) - franek (franek) - Artur Eshenbrener - Christian Wahler - Gintautas Miselis - Rob Bast - Zander Baldwin - Adam Harvey - Anton Bakai - Alex Bakhturin - Alexander Obuhovich (aik099) - boombatower - Fabrice Bernhard (fabriceb) - Jérôme Macias (jeromemacias) - Andrey Astakhov (aast) - ReenExe - Fabian Lange (codingfabian) - Frank Neff (fneff) - Roman Lapin (memphys) - Yoshio HANAWA - Gladhon - Sebastian Bergmann - Miroslav Sustek - Sullivan SENECHAL (soullivaneuh) - Pablo Díez (pablodip) - Martin Hujer (martinhujer) - Kevin McBride - Sergio Santoro - Robin van der Vleuten (robinvdvleuten) - Philipp Rieber (bicpi) - Manuel de Ruiter (manuel) - Eduardo Oliveira (entering) - Ilya Antipenko (aivus) - Iker Ibarguren (ikerib) - Ricardo Oliveira (ricardolotr) - Roy Van Ginneken (rvanginneken) - ondrowan - Barry vd. Heuvel (barryvdh) - Florent Mata - Evan S Kaufman (evanskaufman) - mcben - Jérôme Vieilledent (lolautruche) - Maks Slesarenko - Filip Procházka (fprochazka) - mmoreram - Markus Lanthaler (lanthaler) - Remi Collet - Vicent Soria Durá (vicentgodella) - Anthony Ferrara - Ioan Negulescu - Jakub Škvára (jskvara) - Andrew Udvare (audvare) - alexpods - Arjen van der Meijden - Michele Locati - Dariusz Ruminski - Mathieu Lechat - Erik Trapman (eriktrapman) - De Cock Xavier (xdecock) - Almog Baku (almogbaku) - Scott Arciszewski - Norbert Orzechowicz (norzechowicz) - Denis Charrier (brucewouaigne) - Matthijs van den Bos (matthijs) - Lenard Palko - Nils Adermann (naderman) - Gábor Fási - DUPUCH (bdupuch) - Benjamin Leveque (benji07) - Nate (frickenate) - Timothée Barray (tyx) - jhonnyL - sasezaki - Dawid Pakuła (zulusx) - Florian Rey (nervo) - Rodrigo Borrego Bernabé (rodrigobb) - MatTheCat - Denis Gorbachev (starfall) - Peter van Dommelen - Tim van Densen - Martin Morávek (keeo) - Steven Surowiec - Kevin Saliou (kbsali) - Shawn Iwinski - NothingWeAre - Ryan - Alexander Deruwe (aderuwe) - Alain Hippolyte (aloneh) - Dave Hulbert (dave1010) - Ivan Rey (ivanrey) - Marcin Chyłek (songoq) - Ben Scott - Ned Schwartz - Ziumin - Jeremy Benoist - Lenar Lõhmus - Sander Toonen (xatoo) - Benjamin Laugueux (yzalis) - Zach Badgett (zachbadgett) - Aurélien Fredouelle - Pavel Campr (pcampr) - Johnny Robeson (johnny) - Disquedur - Michiel Boeckaert (milio) - Geoffrey Tran (geoff) - Romain Pierre (romain-pierre) - Jan Behrens - Mantas Var (mvar) - Sebastian Krebs - Jean-Christophe Cuvelier [Artack] - alcaeus - vitaliytv - Dalibor Karlović (dkarlovi) - Sebastian Blum - aubx - Marvin Butkereit - Ricky Su (ricky) - Zan Baldwin - Gildas Quéméner (gquemener) - Charles-Henri Bruyand - Max Rath (drak3) - Stéphane Escandell (sescandell) - Konstantin S. M. Möllers (ksmmoellers) - Alessandro Lai (jean85) - James Johnston - Sinan Eldem - Alexandre Dupuy (satchette) - Andre Rømcke (andrerom) - Nahuel Cuesta (ncuesta) - Chris Boden (cboden) - Stefan Gehrig (sgehrig) - Hany el-Kerdany - Wang Jingyu - Åsmund Garfors - Gunnstein Lye (glye) - Maxime Douailin - Jean Pasdeloup (pasdeloup) - Benjamin Cremer (bcremer) - Javier López (loalf) - Reinier Kip - Geoffrey Brier (geoffrey-brier) - Dustin Dobervich (dustin10) - dantleech - Anne-Sophie Bachelard (annesophie) - Sebastian Marek (proofek) - Erkhembayar Gantulga (erheme318) - Michal Trojanowski - Mateusz Sip - David Fuhr - Kamil Kokot (pamil) - Aurimas Niekis (gcds) - Max Grigorian (maxakawizard) - mcfedr (mcfedr) - Rostyslav Kinash - Maciej Malarz (malarzm) - Daisuke Ohata - Vincent Simonin - Alex Bogomazov (alebo) - maxime.steinhausser - adev - Stefan Warman - Arkadius Stefanski (arkadius) - Tristan Maindron (tmaindron) - Wesley Lancel - Ke WANG (yktd26) - Ivo Bathke (ivoba) - Strate - Anton A. Sumin - Israel J. Carberry - Miquel Rodríguez Telep (mrtorrent) - Sergey Kolodyazhnyy (skolodyazhnyy) - umpirski - Denis Brumann (dbrumann) - Quentin de Longraye (quentinus95) - Chris Heng (gigablah) - Richard Bradley - Ulumuddin Yunus (joenoez) - Johann Saunier (prophet777) - Michael Devery (mickadoo) - Antoine Corcy - Sascha Grossenbacher - Szijarto Tamas - Robin Lehrmann (robinlehrmann) - Catalin Dan - Stephan Vock - Benjamin Zikarsky (bzikarsky) - Simon Schick (simonsimcity) - redstar504 - Tristan Roussel - Cameron Porter - Hossein Bukhamsin - Oliver Hoff - Christian Sciberras (uuf6429) - Martin Auswöger - Disparity - origaminal - Matteo Beccati (matteobeccati) - Kevin (oxfouzer) - Paweł Wacławczyk (pwc) - Oleg Zinchenko (cystbear) - Baptiste Meyer (meyerbaptiste) - Johannes Klauss (cloppy) - Evan Villemez - fzerorubigd - Thomas Ploch - Benjamin Grandfond (benjamin) - Tiago Brito (blackmx) - Richard van den Brand (ricbra) - develop - Greg Anderson - VJ - Delf Tonder (leberknecht) - Mark Sonnabaum - Richard Quadling - jochenvdv - Arturas Smorgun (asarturas) - Alexander Volochnev (exelenz) - Michael Piecko - yclian - twifty - Indra Gunawan (guind) - Peter Ward - insekticid - Julien DIDIER (juliendidier) - Dominik Ritter (dritter) - Sebastian Grodzicki (sgrodzicki) - Jeroen van den Enden (stoefke) - Pascal Helfenstein - Baldur Rensch (brensch) - Vladyslav Petrovych - Alex Xandra Albert Sim - Craig Duncan (duncan3dc) - Carson Full - Trent Steel (trsteel88) - Yuen-Chi Lian - Besnik Br - Jose Gonzalez - Dariusz Ruminski - Joshua Nye - Claudio Zizza - Dave Marshall (davedevelopment) - avorobiev - Venu - Lars Vierbergen - Jonatan Männchen - Dennis Hotson - Andrew Tchircoff (andrewtch) - michaelwilliams - 1emming - Leevi Graham (leevigraham) - Nykopol (nykopol) - Jordan Deitch - Casper Valdemar Poulsen - Josiah (josiah) - Joschi Kuphal - John Bohn (jbohn) - Marc Morera (mmoreram) - Andrew Hilobok (hilobok) - Noah Heck (myesain) - Christian Soronellas (theunic) - Johann Pardanaud - Adam Szaraniec (mimol) - Yosmany Garcia (yosmanyga) - Wouter de Wild - Degory Valentine - izzyp - Benoit Lévêque (benoit_leveque) - Jeroen Fiege (fieg) - Krzysiek Łabuś - George Mponos (gmponos) - Xavier Lacot (xavier) - possum - Denis Zunke (donalberto) - Ahmed TAILOULOUTE (ahmedtai) - Olivier Maisonneuve (olineuve) - Masterklavi - Francis Turmel (fturmel) - Nikita Nefedov (nikita2206) - cgonzalez - Ben - Vincent Composieux (eko) - Jayson Xu (superjavason) - Christopher Hertel (chertel) - Hubert Lenoir (hubert_lenoir) - Jaik Dean (jaikdean) - fago - Harm van Tilborg - Jan Prieser - GDIBass - Adrien Lucas (adrienlucas) - Zhuravlev Alexander (scif) - James Michael DuPont - Tom Klingenberg - Christopher Hall (mythmakr) - Patrick Dawkins (pjcdawkins) - Paul Kamer (pkamer) - Rafał Wrzeszcz (rafalwrzeszcz) - Reen Lokum - Martin Parsiegla (spea) - Quentin Schuler - Pierre Vanliefland (pvanliefland) - Sofiane HADDAG (sofhad) - frost-nzcr4 - Bozhidar Hristov - Abhoryo - Fabian Vogler (fabian) - Korvin Szanto - Arjan Keeman - Alaattin Kahramanlar (alaattin) - Sergey Zolotov (enleur) - Maksim Kotlyar (makasim) - Neil Ferreira - Nathanael Noblet (gnat) - Dmitry Parnas (parnas) - Paul LE CORRE - Emanuele Iannone - Tony Malzhacker - Mathieu MARCHOIS - Cyril Quintin (cyqui) - Gerard van Helden (drm) - Johnny Peck (johnnypeck) - Ivan Menshykov - David Romaní - Patrick Allaert - Fabien Bourigault (fbourigault) - Gustavo Falco (gfalco) - Matt Robinson (inanimatt) - Ruud Kamphuis (ruudk) - Aleksey Podskrebyshev - Calin Mihai Pristavu - David Marín Carreño (davefx) - Fabien LUCAS (flucas2) - Jörn Lang (j.lang) - Omar Yepez (oyepez003) - Gawain Lynch (gawain) - mwsaz - Jelle Kapitein - Benoît Bourgeois - mantulo - corphi - grizlik - Derek ROTH - Dmytro Boiko (eagle) - Shin Ohno (ganchiku) - Geert De Deckere (geertdd) - Jan Kramer (jankramer) - abdul malik ikhsan (samsonasik) - Henry Snoek (snoek09) - Jérémy M (th3mouk) - Simone Di Maulo (toretto460) - Christian Morgan - Alexander Miehe (engerim) - Morgan Auchede (mauchede) - Don Pinkster - Maksim Muruev - Emil Einarsson - Thomas Landauer - 243083df - Thibault Duplessis - Marc Abramowitz - Martijn Evers - Tony Tran - Jacques Moati - Balazs Csaba (balazscsaba2006) - Douglas Reith (douglas_reith) - Forfarle (forfarle) - Harry Walter (haswalt) - Johnson Page (jwpage) - Ruben Gonzalez (rubenruateltek) - Michael Roterman (wtfzdotnet) - Arno Geurts - Adán Lobato (adanlobato) - Ian Jenkins (jenkoian) - Matthew Davis (mdavis1982) - Maks - Antoine LA - den - pawel-lewtak - omerida - Gábor Tóth - Daniel Cestari - David Lima - Brian Freytag (brianfreytag) - Brunet Laurent (lbrunet) - Mikhail Yurasov (mym) - LOUARDI Abdeltif (ouardisoft) - Robert Gruendler (pulse00) - Simon Terrien (sterrien) - Benoît Merlet (trompette) - Koen Kuipers - datibbaw - Erik Saunier (snickers) - Rootie - Raul Fraile (raulfraile) - sensio - Sebastien Morel (plopix) - Patrick Kaufmann - Piotr Stankowski - Reece Fowell (reecefowell) - Mátyás Somfai (smatyas) - stefan.r - Valérian Galliat - Rikijs Murgs - Ben Ramsey (ramsey) - Amaury Leroux de Lens (amo__) - Christian Jul Jensen - Alexandre GESLIN (alexandregeslin) - The Whole Life to Learn - ergiegonzaga - Farhad Safarov - Liverbool (liverbool) - Sam Malone - Phan Thanh Ha (haphan) - Chris Jones (leek) - Colin O'Dell (colinodell) - xaav - Mahmoud Mostafa (mahmoud) - Pieter - Michael Tibben - Billie Thompson - Sander Marechal - Radosław Benkel - jean pasqualini (darkilliant) - ttomor - Mei Gwilym (meigwilym) - Michael H. Arieli (excelwebzone) - Tom Panier (neemzy) - Fred Cox - Luciano Mammino (loige) - fabios - Sander Coolen (scoolen) - Nicolas Le Goff (nlegoff) - Ben Oman - Andreas Kleemann - Manuele Menozzi - Anton Babenko (antonbabenko) - Irmantas Šiupšinskas (irmantas) - Danilo Silva - Arnaud PETITPAS (apetitpa) - Zachary Tong (polyfractal) - Ashura - Hryhorii Hrebiniuk - Dennis Fridrich (dfridrich) - hamza - dantleech - Bastien DURAND (deamon) - Xavier Leune - Tero Alén (tero) - DerManoMann - Guillaume Royer - Artem (digi) - boite - MGDSoft - Vadim Tyukov (vatson) - David Wolter (davewww) - Sortex - chispita - Wojciech Sznapka - Gavin Staniforth - Ariel J. Birnbaum - Mathieu Santostefano - Arjan Keeman - Máximo Cuadros (mcuadros) - tamirvs - julien.galenski - Bob van de Vijver - Christian Neff - Oliver Hoff - Ole Rößner (basster) - Per Sandström (per) - Goran Juric - Laurent Ghirardotti (laurentg) - Nicolas Macherey - Guido Donnari - AKeeman (akeeman) - Lin Clark - Jeremy David (jeremy.david) - Troy McCabe - Ville Mattila - ilyes kooli - gr1ev0us - mlazovla - Boris Vujicic (boris.vujicic) - Max Beutel - Antanas Arvasevicius - Maximilian Berghoff (electricmaxxx) - nacho - Mathieu Piot - Piotr Antosik (antek88) - Artem Lopata - Sergey Novikov (s12v) - Marcos Quesada (marcos_quesada) - Matthew Vickery (mattvick) - Paul Mitchum (paul-m) - Angel Koilov (po_taka) - Dan Finnie - Ken Marfilla (marfillaster) - benatespina (benatespina) - Denis Kop - jfcixmedia - Nikita Konstantinov - Martijn Evers - Benjamin Paap (benjaminpaap) - Christian - Denis Golubovskiy (bukashk0zzz) - Sergii Smertin (nfx) - Michał Strzelecki - hugofonseca (fonsecas72) - Martynas Narbutas - Bailey Parker - Eddie Jaoude - Antanas Arvasevicius - Haritz Iturbe (hizai) - Nerijus Arlauskas (nercury) - SPolischook - Diego Sapriza - Joan Cruz - inspiran - Cristobal Dabed - Daniel Mecke (daniel_mecke) - Matteo Giachino (matteosister) - Alex Demchenko (pilot) - Tadas Gliaubicas (tadcka) - Thanos Polymeneas (thanos) - Benoit Garret - Jakub Sacha - DerManoMann - Olaf Klischat - orlovv - Peter Smeets (darkspartan) - Haralan Dobrev (hkdobrev) - Jhonny Lidfors (jhonny) - Julien Bianchi (jubianchi) - Robert Meijers - Marcin Chwedziak - hjkl - Tony Cosentino (tony-co) - Dan Wilga - Alexander Cheprasov - Rodrigo Díez Villamuera (rodrigodiez) - Malte Blättermann - e-ivanov - Jochen Bayer (jocl) - Alex Bowers - Jeremy Bush - wizhippo - Viacheslav Sychov - Matt Brunt - Carlos Ortega Huetos - rpg600 - Péter Buri (burci) - Davide Borsatto (davide.borsatto) - kaiwa - RJ Garcia - Charles Sanquer (csanquer) - Albert Ganiev (helios-ag) - Neil Katin - David Otton - Will Donohoe - peter - Jaroslav Kuba - flip111 - Jérémy Jourdin (jjk801) - BRAMILLE Sébastien (oktapodia) - Artem Kolesnikov (tyomo4ka) - Gustavo Adrian - Yannick - spdionis - rchoquet - gitlost - Taras Girnyk - Eduardo García Sanz (coma) - James Gilliland - fduch (fduch) - Rhodri Pugh (rodnaph) - David de Boer (ddeboer) - Ryan Rogers - Klaus Purer - arnaud (arnooo999) - Gilles Doge (gido) - abulford - Philipp Kretzschmar - antograssiot - Ilya Vertakov - Brooks Boyd - Roger Webb - Dmitriy Simushev - Pawel Smolinski - pkowalczyk - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) - Raul Rodriguez (raul782) - Patrick Landolt (scube) - WybrenKoelmans - Derek Lambert - MightyBranch - Kacper Gunia (cakper) - Peter Thompson (petert82) - Felicitus - Krzysztof Przybyszewski - Paul Matthews - Jakub Kisielewski - Vacheslav Silyutin - Juan Traverso - Alain Flaus (halundra) - Tarjei Huse (tarjei) - tsufeki - Philipp Strube - Clement Herreman (clemherreman) - Dan Ionut Dumitriu (danionut90) - Vladislav Rastrusny (fractalizer) - Alexander Kurilo (kamazee) - Nyro (nyro) - Marco - Marc Torres - Alberto Aldegheri - Dmitri Petmanson - heccjj - Alexandre Melard - Jay Klehr - Sergey Yuferev - Tobias Stöckler - Mario Young - Jakub Kulhan - Ilia (aliance) - Mo Di (modi) - Pablo Schläpfer - Jelte Steijaert (jelte) - Quique Porta (quiqueporta) - stoccc - Tomasz Szymczyk (karion) - Xavier Coureau - ConneXNL - Aharon Perkel - matze - Abdul.Mohsen B. A. A - Benoît Burnichon - pthompson - Malaney J. Hill - Alexandre Pavy - Christian Flach (cmfcmf) - Cédric Girard (enk_) - Lars Ambrosius Wallenborn (larsborn) - Oriol Mangas Abellan (oriolman) - Sebastian Göttschkes (sgoettschkes) - Tatsuya Tsuruoka - Ross Tuck - Kévin Gomez (kevin) - azine - Dawid Sajdak - Ludek Stepan - Aaron Stephens (astephens) - Craig Menning (cmenning) - Balázs Benyó (duplabe) - Erika Heidi Reinaldo (erikaheidi) - Pierre Tachoire (krichprollsch) - Marc J. Schmidt (marcjs) - Marco Jantke - Remon van de Kamp - Saem Ghani - Clément LEFEBVRE - Conrad Kleinespel - Sebastian Utz - Adrien Gallou (agallou) - Maks Rafalko (bornfree) - Karol Sójko (karolsojko) - Grzegorz Zdanowski (kiler129) - sl_toto (sl_toto) - Walter Dal Mut (wdalmut) - Matthieu - Albin Kerouaton - Sébastien HOUZÉ - Jingyu Wang - steveYeah - Samy Dindane (dinduks) - Keri Henare (kerihenare) - Cédric Lahouste (rapotor) - Samuel Vogel (samuelvogel) - Berat Doğan - Guillaume LECERF - Juanmi Rodriguez Cerón - Andy Raines - Anthony Ferrara - Klaas Cuvelier (kcuvelier) - markusu49 - Steve Frécinaux - Jules Lamur - Renato Mendes Figueiredo - ShiraNai7 - Antal Áron (antalaron) - Markus Fasselt (digilist) - Vašek Purchart (vasek-purchart) - Janusz Jabłoński (yanoosh) - Sandro Hopf - Łukasz Makuch - George Giannoulopoulos - Luis Ramirez (luisdeimos) - Daniel Richter (richtermeister) - ChrisC - Ilya Biryukov - Kim Laï Trinh - Jason Desrosiers - m.chwedziak - Andreas Frömer - Philip Frank - Lance McNearney - Gonzalo Vilaseca (gonzalovilaseca) - Giorgio Premi - Ian Carroll - caponica - Matt Daum (daum) - Alberto Pirovano (geezmo) - Pete Mitchell (peterjmit) - Tom Corrigan (tomcorrigan) - Luis Galeas - Martin Pärtel - Patrick Daley (padrig) - Xavier Briand (xavierbriand) - Max Summe - WedgeSama - Felds Liscia - Chihiro Adachi (chihiro-adachi) - Tadcka - Beth Binkovitz - Gonzalo Míguez - Pierre Rineau - Romain Geissler - Adrien Moiruad - Tomaz Ahlin - Marcus Stöhr (dafish) - Emmanuel Vella (emmanuel.vella) - Jonathan Johnson (jrjohnson) - Carsten Nielsen (phreaknerd) - Mathieu Rochette - Jay Severson - René Kerner - Nathaniel Catchpole - Adrien Samson (adriensamson) - Samuel Gordalina (gordalina) - Max Romanovsky (maxromanovsky) - Mathieu Morlon - Daniel Tschinder - Alexander Schranz - Arnaud CHASSEUX - Rafał Muszyński (rafmus90) - Sébastien Decrême (sebdec) - Timothy Anido (xanido) - Mara Blaga - Rick Prent - skalpa - Martin Eckhardt - Pieter Jordaan - Damien Tournoud - Jon Gotlin (jongotlin) - Michael Dowling (mtdowling) - Karlos Presumido (oneko) - Thomas Counsell - BilgeXA - r1pp3rj4ck - Robert Queck - Peter Bouwdewijn - mlively - Amine Matmati - Fabian Steiner (fabstei) - Klaus Silveira (klaussilveira) - Thomas Chmielowiec (chmielot) - Jānis Lukss - rkerner - Alex Silcock - Qingshan Luo - Ergie Gonzaga - Matthew J Mucklo - fdgdfg (psampaz) - Stéphane Seng - Maxwell Vandervelde - kaywalker - Mike Meier - Tim Jabs - Sebastian Ionescu - Thomas Ploch - Simon Neidhold - Xavier HAUSHERR - Valentin VALCIU - Jeremiah VALERIE - Kevin Dew - James Cowgill - 1ma (jautenim) - Nicolas Schwartz (nicoschwartz) - Patrik Gmitter (patie) - Jonathan Gough - Benjamin Bender - Jared Farrish - Konrad Mohrfeldt - Lance Chen - Andrew (drew) - kor3k kor3k (kor3k) - Stelian Mocanita (stelian) - Flavian (2much) - mike - Kirk Madera - Keith Maika - Mephistofeles - Hoffmann András - Olivier - pscheit - Wybren Koelmans - Zdeněk Drahoš - Dan Harper - moldcraft - Antoine Bellion (abellion) - Ramon Kleiss (akathos) - César Suárez (csuarez) - Bjorn Twachtmann (dotbjorn) - Nicolas Badey (nico-b) - Shane Preece (shane) - Johannes Goslar - Geoff - georaldc - Maarten de Boer - Malte Wunsch - wusuopu - povilas - Gavin Staniforth - Alessandro Tagliapietra (alex88) - Biji (biji) - Gunnar Lium (gunnarlium) - Tiago Garcia (tiagojsag) - Artiom - Jakub Simon - Bouke Haarsma - Martin Eckhardt - natechicago - Jonathan Poston - Adrian Olek (adrianolek) - Jody Mickey (jwmickey) - Przemysław Piechota (kibao) - Leonid Terentyev (li0n) - ryunosuke - victoria - Christian Schmidt - Francisco Facioni (fran6co) - Iwan van Staveren (istaveren) - Povilas S. (povilas) - pborreli - Boris Betzholz - Eric Caron - 2manypeople - Wing - Thomas Bibb - Matt Farmer - catch - Alexandre Segura - Josef Cech - Harold Iedema - Arnau González (arnaugm) - Simon Bouland (bouland) - Matthew Foster (mfoster) - Paul Seiffert (seiffert) - Vasily Khayrulin (sirian) - Stefan Koopmanschap (skoop) - Stefan Hüsges (tronsha) - Dan Blows - Matt Wells - Nicolas Appriou - stloyd - Chris Tickner - Andrew Coulton - Jeremy Benoist - Michal Gebauer - Gleb Sidora - David Stone - Jovan Perovic (jperovic) - Pablo Maria Martelletti (pmartelletti) - Yassine Guedidi (yguedidi) - Waqas Ahmed - Luis Muñoz - Matthew Donadio - Houziaux mike - Andreas - Thomas Chmielowiec - shdev - Andrey Ryaguzov - Stefan - Peter Bex - Manatsawin Hanmongkolchai - Gunther Konig - Maciej Schmidt - Dennis Væversted - nuncanada - flack - František Bereň - Jeremiah VALERIE - Mike Francis - Christoph Nissle (derstoffel) - Ionel Scutelnicu (ionelscutelnicu) - Nicolas Tallefourtané (nicolab) - Botond Dani (picur) - Thierry Marianne (thierrymarianne) - Nick Stemerdink - David Stone - jjanvier - Julius Beckmann - loru88 - Romain Dorgueil - Christopher Parotat - 蝦米 - Grayson Koonce (breerly) - Indra Gunawan (indragunawan) - Karim Cassam Chenaï (ka) - Michal Kurzeja (mkurzeja) - Nicolas Bastien (nicolas_bastien) - Denis (yethee) - Andrew Zhilin (zhil) - Oleksii Zhurbytskyi - Andy Stanberry - Felix Marezki - Luiz “Felds” Liscia - Thomas Rothe - nietonfir - alefranz - avi123 - alsar - Aarón Nieves Fernández - Mike Meier - Kirill Saksin - Julien Pauli - Koalabaerchen - michalmarcinkowski - Warwick - Chris - Florent Olivaud - JakeFr - Simon Sargeant - efeen - Nicolas Pion - Muhammed Akbulut - Michał Dąbrowski (defrag) - Simone Fumagalli (hpatoio) - Brian Graham (incognito) - Kevin Vergauwen (innocenzo) - Alessio Baglio (ioalessio) - Johannes Müller (johmue) - Jordi Llonch (jordillonch) - Cédric Dugat (ph3nol) - Philip Dahlstrøm (phidah) - Milos Colakovic (project2481) - Rénald Casagraude (rcasagraude) - Robin Duval (robin-duval) - rudy onfroy (ronfroy) - Grinbergs Reinis (shima5) - Artem Lopata (bumz) - Nicole Cordes - Roman Orlov - andrey1s - VolCh - Alexey Popkov - Gijs Kunze - Artyom Protaskin - Nathanael d. Noblet - helmer - ged15 - Daan van Renterghem - Nicole Cordes - Martin Kirilov - Bram Van der Sype (brammm) - Guile (guile) - Julien Moulin (lizjulien) - Mauro Foti (skler) - Yannick Warnier (ywarnier) - Kevin Decherf - Jason Woods - klemens - dened - Dmitry Korotovsky - mcorteel - Michael van Tricht - Tim Strehle - Sam Ward - Walther Lalk - Adam - Stéphan Kochen - devel - taiiiraaa - Trevor Suarez - gedrox - Alan Bondarchuk - dropfen - Andrey Chernykh - Edvinas Klovas - Drew Butler - Peter Breuls - Tischoi - J Bruni - Alexey Prilipko - Dmitriy Fedorenko - vlakoff - bertillon - Bertalan Attila - AmsTaFF (amstaff) - Yannick Bensacq (cibou) - Frédéric G. Marand (fgm) - Freek Van der Herten (freekmurze) - Luca Genuzio (genuzio) - Hans Nilsson (hansnilsson) - Andrew Marcinkevičius (ifdattic) - Ioana Hazsda (ioana-hazsda) - Jan Marek (janmarek) - Mark de Haan (markdehaan) - Dan Patrick (mdpatrick) - Pedro Magalhães (pmmaga) - Rares Vlaseanu (raresvla) - tante kinast (tante) - Vincent LEFORT (vlefort) - Sadicov Vladimir (xtech) - Kevin EMO (zarcox) - Alexander Zogheb - Rémi Blaise - Joel Marcey - David Christmann - root - James Hudson - Tom Maguire - Richard Quadling - David Zuelke - Oleg Andreyev - Pierre Rineau - Maxim Lovchikov - adenkejawen - Ari Pringle (apringle) - Dan Ordille (dordille) - Jan Eichhorn (exeu) - Grégory Pelletier (ip512) - John Nickell (jrnickell) - Martin Mayer (martin) - Grzegorz Łukaszewicz (newicz) - Jonny Schmid (schmidjon) - Götz Gottwald - Veres Lajos - grifx - Robert Campbell - Matt Lehner - Hein Zaw Htet™ - Ruben Kruiswijk - Cosmin-Romeo TANASE - Michael J - Joseph Maarek - Alexander Menk - Alex Pods - hadriengem - timaschew - Jochen Mandl - Ian Phillips - Haritz - Matthieu Prat - Ion Bazan - Grummfy - Filipe Guerra - Gerben Wijnja - Rowan Manning - Per Modin - David Windell - Gabriel Birke - skafandri - Derek Bonner - Alan Chen - Maerlyn - Even André Fiskvik - Arjan Keeman - Erik van Wingerden - Valouleloup - Dane Powell - Gerrit Drost - Linnaea Von Lavia - Simon Mönch - Javan Eskander - Lenar Lõhmus - Cristian Gonzalez - AlberT - hainey - Juan M Martínez - Gilles Gauthier - ddebree - Kuba Werłos - Tomas Liubinas - Alex - Klaas Naaijkens - Daniel González Cerviño - Rafał - Adria Lopez (adlpz) - Aaron Scherer (aequasi) - Rosio (ben-rosio) - Simon Paarlberg (blamh) - Jeroen Thora (bolle) - Brieuc THOMAS (brieucthomas) - Masao Maeda (brtriver) - Darius Leskauskas (darles) - David Joos (djoos) - Denis Klementjev (dklementjev) - Tomáš Polívka (draczris) - Dennis Smink (dsmink) - Franz Liedke (franzliedke) - Gaylord Poillon (gaylord_p) - Christophe BECKER (goabonga) - gondo (gondo) - Gusakov Nikita (hell0w0rd) - Osman Üngür (import) - Javier Núñez Berrocoso (javiernuber) - Jelle Bekker (jbekker) - Giovanni Albero (johntree) - Jorge Martin (jorgemartind) - Joeri Verdeyen (jverdeyen) - Dmitrii Poddubnyi (karser) - Kevin Verschaeve (keversc) - Kevin Herrera (kherge) - Luis Ramón López López (lrlopez) - Bart Reunes (metalarend) - Muriel (metalmumu) - Michael Pohlers (mick_the_big) - mlpo (mlpo) - Marek Šimeček (mssimi) - Cayetano Soriano Gallego (neoshadybeat) - Ondrej Machulda (ondram) - Pablo Monterde Perez (plebs) - Jimmy Leger (redpanda) - Marcin Szepczynski (szepczynski) - Cyrille Jouineau (tuxosaurus) - Vladimir Chernyshev (volch) - Yorkie Chadwick (yorkie76) - GuillaumeVerdon - Ondrej Mirtes - akimsko - Youpie - srsbiz - Taylan Kasap - Michael Orlitzky - Nicolas A. Bérard-Nault - Saem Ghani - Stefan Oderbolz - Curtis - Gabriel Moreira - Alexey Popkov - ChS - Joseph Deray - Damian Sromek - Ben - Evgeniy Tetenchuk - dasmfm - Mathias Geat - Arnaud Buathier (arnapou) - chesteroni (chesteroni) - Mauricio Lopez (diaspar) - HADJEDJ Vincent (hadjedjvincent) - Daniele Cesarini (ijanki) - Ismail Asci (ismailasci) - Simon CONSTANS (kosssi) - Kristof Van Cauwenbergh (kristofvc) - Dennis Langen (nijusan) - Paulius Jarmalavičius (pjarmalavicius) - Ramon Henrique Ornelas (ramonornela) - Ricardo de Vries (ricknox) - Markus S. (staabm) - Till Klampaeckel (till) - Tobias Weinert (tweini) - Ulf Reimers (ureimers) - Wotre - goohib - Xavier HAUSHERR - Ron Gähler - Edwin Hageman - Mantas Urnieža - Cas - Dusan Kasan - Myke79 - Brian Debuire - Piers Warmers - Guilliam Xavier - Sylvain Lorinet - klyk50 - Andreas Lutro - jc - BenjaminBeck - Aurelijus Rožėnas - Vladimir Tsykun - Jordan Hoff - znerol - Christian Eikermann - Antonio Angelino - Matt Fields - Niklas Keller - Vladimir Sazhin - Tomas Kmieliauskas - Billie Thompson - lol768 - jamogon - Vyacheslav Slinko - Jakub Chábek - Johannes - Jörg Rühl - wesleyh - sergey - Karim Miladi - Michael Genereux - patrick-mcdougle - Dariusz Czech - Jack Wright - Anonymous User - Paweł Tomulik - Eric J. Duran - Alexandru Bucur - cmfcmf - Drew Butler - Steve Müller - Andras Ratz - andreabreu98 - Michael Schneider - Cédric Bertolini - n-aleha - Anatol Belski - Şəhriyar İmanov - Kaipi Yann - Sam Williams - Guillaume Aveline - Adrian Philipp - James Michael DuPont - Kasperki - Tammy D - Ondrej Slinták - vlechemin - Brian Corrigan - Ladislav Tánczos - Skorney - fmarchalemisys - mieszko4 - Steve Preston - Kevin Frantz - Neophy7e - bokonet - Arrilot - Shaun Simmons - Markus Staab - Pierre-Louis LAUNAY - djama - Michael Gwynne - Eduardo Conceição - changmin.keum - Jon Cave - Sébastien HOUZE - Abdulkadir N. A. - Adam Klvač - Yevgen Kovalienia - Lebnik - Shude - Ondřej Führer - Sema - Michael Käfer - Elan Ruusamäe - Thorsten Hallwas - Michael Squires - Derek Stephen McLean - Norman Soetbeer - zorn - Yuriy Potemkin - Benjamin Long - Matt Janssen - Peter Gribanov - Ben Johnson - kwiateusz - David Soria Parra - Sergiy Sokolenko - dinitrol - Penny Leach - Yurii K - Richard Trebichavský - g123456789l - Jonathan Vollebregt - oscartv - DanSync - Peter Zwosta - parhs - Diego Campoy - TeLiXj - Oncle Tom - Sam Anthony - Christian Stocker - Oussama Elgoumri - Dawid Nowak - Lesnykh Ilia - darnel - Karolis Daužickas - Nicolas - Sergio Santoro - tirnanog06 - phc - Дмитрий Пацура - ilyes kooli - Matthias Althaus - Michaël VEROUX - Julia - Lin Lu - arduanov - sualko - Bilge - ADmad - Nicolas Roudaire - Alfonso (afgar) - Andreas Forsblom (aforsblo) - Alex Olmos (alexolmos) - Antonio Mansilla (amansilla) - Robin Kanters (anddarerobin) - Juan Ases García (ases) - Siragusa (asiragusa) - Daniel Basten (axhm3a) - Bill Hance (billhance) - Bernd Matzner (bmatzner) - Bram Tweedegolf (bram_tweedegolf) - Brandon Kelly (brandonkelly) - Choong Wei Tjeng (choonge) - Kousuke Ebihara (co3k) - Loïc Vernet (coil) - Christian Gripp (core23) - Christoph Schaefer (cvschaefer) - Damon Jones (damon__jones) - Łukasz Giza (destroyer) - Daniel Londero (dlondero) - Sebastian Landwehr (dword123) - Adel ELHAIBA (eadel) - Damián Nohales (eagleoneraptor) - Elliot Anderson (elliot) - Fabien D. (fabd) - Carsten Eilers (fnc) - Sorin Gitlan (forapathy) - Yohan Giarelli (frequence-web) - Gerry Vandermaesen (gerryvdm) - Ghazy Ben Ahmed (ghazy) - Arash Tabriziyan (ghost098) - ibasaw (ibasaw) - Vladislav Krupenkin (ideea) - Imangazaliev Muhammad (imangazaliev) - j0k (j0k) - joris de wit (jdewit) - Jérémy CROMBEZ (jeremy) - Jose Manuel Gonzalez (jgonzalez) - Joachim Krempel (jkrempel) - Jorge Maiden (jorgemaiden) - Justin Rainbow (jrainbow) - Juan Luis (juanlugb) - JuntaTom (juntatom) - Ismail Faizi (kanafghan) - Sébastien Armand (khepin) - Pierre-Chanel Gauthier (kmecnin) - Krzysztof Menżyk (krymen) - samuel laulhau (lalop) - Laurent Bachelier (laurentb) - Luís Cobucci (lcobucci) - Florent Viel (luxifer) - Matthieu Mota (matthieumota) - Matthieu Moquet (mattketmo) - Moritz Borgmann (mborgmann) - Michal Čihař (mcihar) - Matt Drollette (mdrollette) - Adam Monsen (meonkeys) - Ala Eddine Khefifi (nayzo) - emilienbouard (neime) - Nicholas Byfleet (nickbyfleet) - Tomas Norkūnas (norkunas) - ollie harridge (ollietb) - Paul Andrieux (paulandrieux) - Paweł Szczepanek (pauluz) - Philippe Degeeter (pdegeeter) - Pedro Miguel Maymone de Resende (pedroresende) - Christian López Espínola (penyaskito) - Petr Jaroš (petajaros) - Philipp Hoffmann (philipphoffmann) - Alex Carol (picard89) - Daniel Perez Pinazo (pitiflautico) - Phil Taylor (prazgod) - Brayden Williams (redstar504) - Rich Sage (richsage) - Rokas Mikalkėnas (rokasm) - Bart Ruysseveldt (ruyss) - Sascha Dens (saschadens) - scourgen hung (scourgen) - Sébastien Alfaiate (seb33300) - Sebastian Busch (sebu) - André Filipe Gonçalves Neves (seven) - Bruno Ziegler (sfcoder) - Andrea Giuliano (shark) - Schuyler Jager (sjager) - Pascal Luna (skalpa) - Volker (skydiablo) - Serkan Yildiz (srknyldz) - Julien Sanchez (sumbobyboys) - Guillermo Gisinger (t3chn0r) - Markus Tacker (tacker) - Tyler Stroud (tystr) - Moritz Kraft (userfriendly) - Víctor Mateo (victormateo) - Vincent (vincent1870) - Vincent CHALAMON (vincentchalamon) - Eugene Babushkin (warl) - Wouter Sioen (wouter_sioen) - Xavier Amado (xamado) - Jesper Søndergaard Pedersen (zerrvox) - Florent Cailhol - szymek - Kovacs Nicolas - craigmarvelley - Stano Turza - simpson - drublic - Andreas Streichardt - Pascal Hofmann - smokeybear87 - Gustavo Adrian - Kevin Weber - Ben Scott - Dionysis Arvanitis - Sergey Fedotov - Michael - fh-github@fholzhauer.de - AbdElKader Bouadjadja - DSeemiller - Jan Emrich - Mark Topper - Xavier REN - Zander Baldwin - Philipp Scheit - max - Mohamed Karnichi (amiral) - Andrew Carter (andrewcarteruk) - Adam Elsodaney (archfizz) - Daniel Kolvik (dkvk) - Marc Lemay (flug) - Henne Van Och (hennevo) - Jeroen De Dauw (jeroendedauw) - Daniel Alejandro Castro Arellano (lexcast) - Maxime COLIN (maximecolin) - Muharrem Demirci (mdemirci) - Evgeny Z (meze) - Nicolas de Marqué (nicola) - Pierre Geyer (ptheg) - Sam Fleming (sam_fleming) - Thomas BERTRAND (sevrahk) - Matej Žilák (teo_sk) - Vladislav Vlastovskiy (vlastv) - RENAUDIN Xavier (xorrox) symfony-3.4.6/LICENSE000066400000000000000000000020511324732107100142330ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/README.md000066400000000000000000000053121324732107100145100ustar00rootroot00000000000000

[Symfony][1] is a **PHP framework** for web applications and a set of reusable **PHP components**. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the [popular PHP projects][2] (including Drupal and Magento). Installation ------------ * [Install Symfony][4] with Composer (see [requirements details][3]). * Symfony follows the [semantic versioning][5] strictly, publishes "Long Term Support" (LTS) versions and has a [release process][6] that is predictable and business-friendly. Documentation ------------- * Read the [Getting Started guide][7] if you are new to Symfony. * Try the [Symfony Demo application][23] to learn Symfony in practice. * Master Symfony with the [Guides and Tutorials][8], the [Components docs][9] and the [Best Practices][10] reference. Community --------- * [Join the Symfony Community][11] and meet other members at the [Symfony events][12]. * [Get Symfony support][13] on Stack Overflow, Slack, IRC, etc. * Follow us on [GitHub][14], [Twitter][15] and [Facebook][16]. Contributing ------------ Symfony is an Open Source, community-driven project with thousands of [contributors][19]. Join them [contributing code][17] or [contributing documentation][18]. Security Issues --------------- If you discover a security vulnerability within Symfony, please follow our [disclosure procedure][20]. About Us -------- Symfony development is sponsored by [SensioLabs][21], led by the [Symfony Core Team][22] and supported by [Symfony contributors][19]. [1]: https://symfony.com [2]: https://symfony.com/projects [3]: https://symfony.com/doc/current/reference/requirements.html [4]: https://symfony.com/doc/current/setup.html [5]: http://semver.org [6]: https://symfony.com/doc/current/contributing/community/releases.html [7]: https://symfony.com/doc/current/page_creation.html [8]: https://symfony.com/doc/current/index.html [9]: https://symfony.com/doc/current/components/index.html [10]: https://symfony.com/doc/current/best_practices/index.html [11]: https://symfony.com/community [12]: https://symfony.com/events/ [13]: https://symfony.com/support [14]: https://github.com/symfony [15]: https://twitter.com/symfony [16]: https://www.facebook.com/SymfonyFramework/ [17]: https://symfony.com/doc/current/contributing/code/index.html [18]: https://symfony.com/doc/current/contributing/documentation/index.html [19]: https://symfony.com/contributors [20]: https://symfony.com/security [21]: https://sensiolabs.com [22]: https://symfony.com/doc/current/contributing/code/core_team.html [23]: https://github.com/symfony/symfony-demo symfony-3.4.6/UPGRADE-3.0.md000066400000000000000000001460411324732107100151450ustar00rootroot00000000000000UPGRADE FROM 2.x to 3.0 ======================= # Table of Contents - [ClassLoader](#classloader) - [Config](#config) - [Console](#console) - [DependencyInjection](#dependencyinjection) - [DoctrineBridge](#doctrinebridge) - [DomCrawler](#domcrawler) - [EventDispatcher](#eventdispatcher) - [Form](#form) - [FrameworkBundle](#frameworkbundle) - [HttpFoundation](#httpfoundation) - [HttpKernel](#httpkernel) - [Locale](#locale) - [Monolog Bridge](#monolog-bridge) - [Process](#process) - [PropertyAccess](#propertyaccess) - [Routing](#routing) - [Security](#security) - [SecurityBundle](#securitybundle) - [Serializer](#serializer) - [Swiftmailer Bridge](#swiftmailer-bridge) - [Translator](#translator) - [Twig Bridge](#twig-bridge) - [TwigBundle](#twigbundle) - [Validator](#validator) - [WebProfiler](#webprofiler) - [Yaml](#yaml) ### ClassLoader * The `UniversalClassLoader` class has been removed in favor of `ClassLoader`. The only difference is that some method names are different: | Old name | New name | -------- | --- | `registerNamespaces()` | `addPrefixes()` | `registerPrefixes()` | `addPrefixes()` | `registerNamespace()` | `addPrefix()` | `registerPrefix()` | `addPrefix()` | `getNamespaces()` | `getPrefixes()` | `getNamespaceFallbacks()` | `getFallbackDirs()` | `getPrefixFallbacks()` | `getFallbackDirs()` * The `DebugUniversalClassLoader` class has been removed in favor of `DebugClassLoader`. The difference is that the constructor now takes a loader to wrap. ### Config * `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` has been removed. Also, cache validation through this method (which was still supported in 2.8 for BC) does no longer work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class has been removed as well. * The `__toString()` method of the `\Symfony\Component\Config\ConfigCache` class was removed in favor of the new `getPath()` method. ### Console * The `dialog` helper has been removed in favor of the `question` helper. * The methods `isQuiet`, `isVerbose`, `isVeryVerbose` and `isDebug` were added to `Symfony\Component\Console\Output\OutputInterface`. * `ProgressHelper` has been removed in favor of `ProgressBar`. Before: ```php $h = new ProgressHelper(); $h->start($output, 10); for ($i = 1; $i < 5; $i++) { usleep(200000); $h->advance(); } $h->finish(); ``` After: ```php $bar = new ProgressBar($output, 10); $bar->start(); for ($i = 1; $i < 5; $i++) { usleep(200000); $bar->advance(); } ``` * `TableHelper` has been removed in favor of `Table`. Before: ```php $table = $app->getHelperSet()->get('table'); $table ->setHeaders(array('ISBN', 'Title', 'Author')) ->setRows(array( array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), )) ; $table->render($output); ``` After: ```php use Symfony\Component\Console\Helper\Table; $table = new Table($output); $table ->setHeaders(array('ISBN', 'Title', 'Author')) ->setRows(array( array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), )) ; $table->render(); ``` * Parameters of `renderException()` method of the `Symfony\Component\Console\Application` are type hinted. You must add the type hint to your implementations. ### DependencyInjection * The method `remove` was added to `Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface`. * The concept of scopes was removed, the removed methods are: - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()` - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopeChildren()` - `Symfony\Component\DependencyInjection\ContainerInterface::enterScope()` - `Symfony\Component\DependencyInjection\ContainerInterface::leaveScope()` - `Symfony\Component\DependencyInjection\ContainerInterface::addScope()` - `Symfony\Component\DependencyInjection\ContainerInterface::hasScope()` - `Symfony\Component\DependencyInjection\ContainerInterface::isScopeActive()` - `Symfony\Component\DependencyInjection\Definition::setScope()` - `Symfony\Component\DependencyInjection\Definition::getScope()` - `Symfony\Component\DependencyInjection\Reference::isStrict()` Also, the `$scope` and `$strict` parameters of `Symfony\Component\DependencyInjection\ContainerInterface::set()` and `Symfony\Component\DependencyInjection\Reference` respectively were removed. * A new `shared` flag has been added to the service definition in replacement of the `prototype` scope. Before: ```php use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $container ->register('foo', 'stdClass') ->setScope(ContainerBuilder::SCOPE_PROTOTYPE) ; ``` ```yml services: foo: class: stdClass scope: prototype ``` ```xml ``` After: ```php use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $container ->register('foo', 'stdClass') ->setShared(false) ; ``` ```yml services: foo: class: stdClass shared: false ``` ```xml ``` * `Symfony\Component\DependencyInjection\ContainerAware` was removed, use `Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement `Symfony\Component\DependencyInjection\ContainerAwareInterface` manually * The methods `Definition::setFactoryClass()`, `Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have been removed in favor of `Definition::setFactory()`. Services defined using YAML or XML use the same syntax as configurators. * Synchronized services are deprecated and the following methods have been removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`, and `Definition::setSynchronized()`. ### DomCrawler * The interface of the `Symfony\Component\DomCrawler\Crawler` changed. It does no longer implement `\Iterator` but `\IteratorAggregate`. If you rely on methods of the `\Iterator` interface, call the `getIterator` method of the `\IteratorAggregate` interface before. No changes are required in a `\Traversable`-aware control structure, such as `foreach`. Before: ```php $crawler->current(); ``` After: ```php $crawler->getIterator()->current(); ``` ### DoctrineBridge * The `property` option of `DoctrineType` was removed in favor of the `choice_label` option. * The `loader` option of `DoctrineType` was removed. You now have to override the `getLoader()` method in your custom type. * The `Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList` was removed in favor of `Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader`. * Passing a query builder closure to `ORMQueryBuilderLoader` is not supported anymore. You should pass resolved query builders only. Consequently, the arguments `$manager` and `$class` of `ORMQueryBuilderLoader` have been removed as well. Note that the `query_builder` option of `DoctrineType` *does* support closures, but the closure is now resolved in the type instead of in the loader. * Using the entity provider with a Doctrine repository implementing `UserProviderInterface` is not supported anymore. You should make the repository implement `UserLoaderInterface` instead. ### EventDispatcher * The method `getListenerPriority($eventName, $listener)` has been added to the `EventDispatcherInterface`. * The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface` extends `Symfony\Component\EventDispatcher\EventDispatcherInterface`. ### Form * The `getBlockPrefix()` method was added to the `FormTypeInterface` in replacement of the `getName()` method which has been removed. * The `configureOptions()` method was added to the `FormTypeInterface` in replacement of the `setDefaultOptions()` method which has been removed. * The `getBlockPrefix()` method was added to the `ResolvedFormTypeInterface` in replacement of the `getName()` method which has been removed. * The option `options` of the `CollectionType` has been removed in favor of the `entry_options` option. * The `cascade_validation` option was removed. Use the `constraints` option together with the `Valid` constraint instead. * Type names were removed. Instead of referencing types by name, you must reference them by their fully-qualified class name (FQCN) instead: Before: ```php $form = $this->createFormBuilder() ->add('name', 'text') ->add('age', 'integer') ->getForm(); ``` After: ```php use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\TextType; $form = $this->createFormBuilder() ->add('name', TextType::class) ->add('age', IntegerType::class) ->getForm(); ``` If you want to customize the block prefix of a type in Twig, you must now implement `FormTypeInterface::getBlockPrefix()`: Before: ```php class UserProfileType extends AbstractType { public function getName() { return 'profile'; } } ``` After: ```php class UserProfileType extends AbstractType { public function getBlockPrefix() { return 'profile'; } } ``` If you don't customize `getBlockPrefix()`, it defaults to the class name without "Type" suffix in underscore notation (here: "user_profile"). Type extension must return the fully-qualified class name of the extended type from `FormTypeExtensionInterface::getExtendedType()` now. Before: ```php class MyTypeExtension extends AbstractTypeExtension { public function getExtendedType() { return 'form'; } } ``` After: ```php use Symfony\Component\Form\Extension\Core\Type\FormType; class MyTypeExtension extends AbstractTypeExtension { public function getExtendedType() { return FormType::class; } } ``` * The `FormTypeInterface::getName()` method was removed. * Returning type instances from `FormTypeInterface::getParent()` is not supported anymore. Return the fully-qualified class name of the parent type class instead. Before: ```php class MyType { public function getParent() { return new ParentType(); } } ``` After: ```php class MyType { public function getParent() { return ParentType::class; } } ``` * The option `type` of the `CollectionType` has been removed in favor of the `entry_type` option. The value for the `entry_type` option must be the fully-qualified class name (FQCN). * Passing type instances to `Form::add()`, `FormBuilder::add()` and the `FormFactory::create*()` methods is not supported anymore. Pass the fully-qualified class name of the type instead. Before: ```php $form = $this->createForm(new MyType()); ``` After: ```php $form = $this->createForm(MyType::class); ``` * Passing custom data to forms now needs to be done through the options resolver. In the controller: Before: ```php $form = $this->createForm(new MyType($variable), $entity, array( 'action' => $this->generateUrl('action_route'), 'method' => 'PUT', )); ``` After: ```php $form = $this->createForm(MyType::class, $entity, array( 'action' => $this->generateUrl('action_route'), 'method' => 'PUT', 'custom_value' => $variable, )); ``` In the form type: Before: ```php class MyType extends AbstractType { private $value; public function __construct($variableValue) { $this->value = $value; } // ... } ``` After: ```php public function buildForm(FormBuilderInterface $builder, array $options) { $value = $options['custom_value']; // ... } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'custom_value' => null, )); } ``` * The alias option of the `form.type_extension` tag was removed in favor of the `extended_type`/`extended-type` option. Before: ```xml ``` After: ```xml ``` * The `max_length` option was removed. Use the `attr` option instead by setting it to an `array` with a `maxlength` key. * The `ChoiceToBooleanArrayTransformer`, `ChoicesToBooleanArrayTransformer`, `FixRadioInputListener`, and `FixCheckboxInputListener` classes were removed. * The `choice_list` option of `ChoiceType` was removed. * The option "precision" was renamed to "scale". Before: ```php use Symfony\Component\Form\Extension\Core\Type\NumberType; $builder->add('length', NumberType::class, array( 'precision' => 3, )); ``` After: ```php use Symfony\Component\Form\Extension\Core\Type\NumberType; $builder->add('length', NumberType::class, array( 'scale' => 3, )); ``` * The option "`virtual`" was renamed to "`inherit_data`". Before: ```php use Symfony\Component\Form\Extension\Core\Type\FormType; $builder->add('address', FormType::class, array( 'virtual' => true, )); ``` After: ```php use Symfony\Component\Form\Extension\Core\Type\FormType; $builder->add('address', FormType::class, array( 'inherit_data' => true, )); ``` * The method `AbstractType::setDefaultOptions(OptionsResolverInterface $resolver)` and `AbstractTypeExtension::setDefaultOptions(OptionsResolverInterface $resolver)` have been renamed. You should use `AbstractType::configureOptions(OptionsResolver $resolver)` and `AbstractTypeExtension::configureOptions(OptionsResolver $resolver)` instead. * The methods `Form::bind()` and `Form::isBound()` were removed. You should use `Form::submit()` and `Form::isSubmitted()` instead. Before: ```php $form->bind(array(...)); ``` After: ```php $form->submit(array(...)); ``` * Passing a `Symfony\Component\HttpFoundation\Request` instance, as was supported by `FormInterface::bind()`, is not possible with `FormInterface::submit()` anymore. You should use `FormInterface::handleRequest()` instead. Before: ```php if ('POST' === $request->getMethod()) { $form->bind($request); if ($form->isValid()) { // ... } } ``` After: ```php $form->handleRequest($request); if ($form->isValid()) { // ... } ``` If you want to test whether the form was submitted separately, you can use the method `isSubmitted()`: ```php $form->handleRequest($request); if ($form->isSubmitted()) { // ... if ($form->isValid()) { // ... } } ``` * The events `PRE_BIND`, `BIND` and `POST_BIND` were renamed to `PRE_SUBMIT`, `SUBMIT` and `POST_SUBMIT`. Before: ```php $builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) { // ... }); ``` After: ```php $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { // ... }); ``` * The class `VirtualFormAwareIterator` was renamed to `InheritDataAwareIterator`. Before: ```php use Symfony\Component\Form\Util\VirtualFormAwareIterator; $iterator = new VirtualFormAwareIterator($forms); ``` After: ```php use Symfony\Component\Form\Util\InheritDataAwareIterator; $iterator = new InheritDataAwareIterator($forms); ``` * The `TypeTestCase` class was moved from the `Symfony\Component\Form\Tests\Extension\Core\Type` namespace to the `Symfony\Component\Form\Test` namespace. Before: ```php use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase class MyTypeTest extends TypeTestCase { // ... } ``` After: ```php use Symfony\Component\Form\Test\TypeTestCase; class MyTypeTest extends TypeTestCase { // ... } ``` * The option "options" of the CollectionType has been renamed to "entry_options". * The option "type" of the CollectionType has been renamed to "entry_type". As a value for the option you must provide the fully-qualified class name (FQCN) now as well. * The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. * The constants `ROUND_HALFEVEN`, `ROUND_HALFUP` and `ROUND_HALFDOWN` in class `NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`, `ROUND_HALF_UP` and `ROUND_HALF_DOWN`. * The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface` was removed in favor of `Symfony\Component\Form\ChoiceList\ChoiceListInterface`. * `Symfony\Component\Form\Extension\Core\View\ChoiceView` was removed in favor of `Symfony\Component\Form\ChoiceList\View\ChoiceView`. * The interface `Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface` and all of its implementations were removed. Use the new interface `Symfony\Component\Security\Csrf\CsrfTokenManagerInterface` instead. * The options "`csrf_provider`" and "`intention`" were renamed to "`csrf_token_generator`" and "`csrf_token_id`". * The method `Form::getErrorsAsString()` was removed. Use `Form::getErrors()` instead with the argument `$deep` set to true and `$flatten` set to false and cast the returned iterator to a string (if not done implicitly by PHP). Before: ```php echo $form->getErrorsAsString(); ``` After: ```php echo $form->getErrors(true, false); ``` * The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. * The `Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\LazyChoiceList`. * The `Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. * The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. * The `TimezoneType::getTimezones()` method was removed. You should not use this method. * The `Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. ### FrameworkBundle * The `config:debug`, `container:debug`, `router:debug`, `translation:debug` and `yaml:lint` commands have been deprecated since Symfony 2.7 and will be removed in Symfony 3.0. Use the `debug:config`, `debug:container`, `debug:router`, `debug:translation` and `lint:yaml` commands instead. * The base `Controller`class is now abstract. * The visibility of all methods of the base `Controller` class has been changed from `public` to `protected`. * The `getRequest` method of the base `Controller` class has been deprecated since Symfony 2.4 and must be therefore removed in 3.0. The only reliable way to get the `Request` object is to inject it in the action method. Before: ```php namespace Acme\FooBundle\Controller; class DemoController { public function showAction() { $request = $this->getRequest(); // ... } } ``` After: ```php namespace Acme\FooBundle\Controller; use Symfony\Component\HttpFoundation\Request; class DemoController { public function showAction(Request $request) { // ... } } ``` * In Symfony 2.7 a small BC break was introduced with the new choices_as_values option. In order to have the choice values populated to the html value attribute you had to define the choice_value option. This is now not any more needed. Before: ```php $form->add('status', 'choice', array( 'choices' => array( 'Enabled' => Status::ENABLED, 'Disabled' => Status::DISABLED, 'Ignored' => Status::IGNORED, ), // choices_as_values defaults to true in Symfony 3.0 // and setting it to anything else is deprecated as of 3.0 'choices_as_values' => true, // important if you rely on your option value attribute (e.g. for JavaScript) // this will keep the same functionality as before 'choice_value' => function ($choice) { return $choice; }, )); ``` After: ```php $form->add('status', ChoiceType::class, array( 'choices' => array( 'Enabled' => Status::ENABLED, 'Disabled' => Status::DISABLED, 'Ignored' => Status::IGNORED, ) )); ``` * The `request` service was removed. You must inject the `request_stack` service instead. * The `enctype` method of the `form` helper was removed. You should use the new method `start` instead. Before: ```php
enctype($form) ?>> ...
``` After: ```php start($form) ?> ... end($form) ?> ``` The method and action of the form default to "POST" and the current document. If you want to change these values, you can set them explicitly in the controller. Alternative 1: ```php $form = $this->createForm('my_form', $formData, array( 'method' => 'PUT', 'action' => $this->generateUrl('target_route'), )); ``` Alternative 2: ```php $form = $this->createFormBuilder($formData) // ... ->setMethod('PUT') ->setAction($this->generateUrl('target_route')) ->getForm(); ``` It is also possible to override the method and the action in the template: ```php start($form, array('method' => 'GET', 'action' => 'http://example.com')) ?> ... end($form) ?> ``` * The `RouterApacheDumperCommand` was removed. * The `createEsi` method of `Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache` was removed. Use `createSurrogate` instead. * The `templating.helper.router` service was moved to `templating_php.xml`. You have to ensure that the PHP templating engine is enabled to be able to use it: ```yaml framework: templating: engines: ['php'] ``` * The `form.csrf_provider` service is removed as it implements an adapter for the new token manager to the deprecated `Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface` interface. The `security.csrf.token_manager` should be used instead. * The `validator.mapping.cache.apc` service has been removed in favor of the `validator.mapping.cache.doctrine.apc` one. * The ability to pass `apc` as the `framework.validation.cache` configuration key value has been removed. Use `validator.mapping.cache.doctrine.apc` instead: Before: ```yaml framework: validation: cache: apc ``` After: ```yaml framework: validation: cache: validator.mapping.cache.doctrine.apc ``` ### HttpKernel * The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in favor of `Psr\Log\LoggerInterface`. The only difference is that some method names are different: | Old name | New name | -------- | --- | `emerg()` | `emergency()` | `crit()` | `critical()` | `err()` | `error()` | `warn()` | `warning()` The previous method renames also happened to the following classes: * `Symfony\Bridge\Monolog\Logger` * `Symfony\Component\HttpKernel\Log\NullLogger` * The `Symfony\Component\HttpKernel\Kernel::init()` method has been removed. * The following classes have been renamed as they have been moved to the Debug component: | Old name | New name | -------- | --- | `Symfony\Component\HttpKernel\Debug\ErrorHandler` | `Symfony\Component\Debug\ErrorHandler` | `Symfony\Component\HttpKernel\Debug\ExceptionHandler` | `Symfony\Component\Debug\ExceptionHandler` | `Symfony\Component\HttpKernel\Exception\FatalErrorException` | `Symfony\Component\Debug\Exception\FatalErrorException` | `Symfony\Component\HttpKernel\Exception\FlattenException` | `Symfony\Component\Debug\Exception\FlattenException` * The `Symfony\Component\HttpKernel\EventListener\ExceptionListener` now passes the Request format as the `_format` argument instead of `format`. * The `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass` has been renamed to `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` and moved to the EventDispatcher component. ### Locale * The Locale component was removed and replaced by the Intl component. Instead of the methods in `Symfony\Component\Locale\Locale`, you should use these equivalent methods in `Symfony\Component\Intl\Intl` now: | Old way | New way | ------- | --- | `Locale::getDisplayCountries()` | `Intl::getRegionBundle()->getCountryNames()` | `Locale::getCountries()` | `array_keys(Intl::getRegionBundle()->getCountryNames())` | `Locale::getDisplayLanguages()` | `Intl::getLanguageBundle()->getLanguageNames()` | `Locale::getLanguages()` | `array_keys(Intl::getLanguageBundle()->getLanguageNames())` | `Locale::getDisplayLocales()` | `Intl::getLocaleBundle()->getLocaleNames()` | `Locale::getLocales()` | `array_keys(Intl::getLocaleBundle()->getLocaleNames())` ### PropertyAccess * Renamed `PropertyAccess::getPropertyAccessor` to `createPropertyAccessor`. Before: ```php use Symfony\Component\PropertyAccess\PropertyAccess; $accessor = PropertyAccess::getPropertyAccessor(); ``` After: ```php use Symfony\Component\PropertyAccess\PropertyAccess; $accessor = PropertyAccess::createPropertyAccessor(); ``` ### Routing * Some route settings have been renamed: * The `pattern` setting has been removed in favor of `path` * The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings Before: ```yaml article_edit: pattern: /article/{id} requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' } ``` ```xml POST|PUT https \d+ ``` ```php $route = new Route(); $route->setPattern('/article/{id}'); $route->setRequirement('_method', 'POST|PUT'); $route->setRequirement('_scheme', 'https'); ``` After: ```yaml article_edit: path: /article/{id} methods: [POST, PUT] schemes: https requirements: { 'id': '\d+' } ``` ```xml \d+ ``` ```php $route = new Route(); $route->setPath('/article/{id}'); $route->setMethods(array('POST', 'PUT')); $route->setSchemes('https'); ``` * The `ApacheMatcherDumper` and `ApacheUrlMatcher` were removed since the performance gains were minimal and it's hard to replicate the behaviour of PHP implementation. * The `getMatcherDumperInstance()` and `getGeneratorDumperInstance()` methods in the `Symfony\Component\Routing\Router` have been changed from `public` to `protected`. * Use the constants defined in the UrlGeneratorInterface for the $referenceType argument of the UrlGeneratorInterface::generate method. Before: ```php // url generated in controller $this->generateUrl('blog_show', array('slug' => 'my-blog-post'), true); // url generated in @router service $router->generate('blog_show', array('slug' => 'my-blog-post'), true); ``` After: ```php use Symfony\Component\Routing\Generator\UrlGeneratorInterface; // url generated in controller $this->generateUrl('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL); // url generated in @router service $router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL); ``` ### Security * The `vote()` method from the `VoterInterface` was changed to now accept arbitrary types and not only objects. You can rely on the new abstract `Voter` class introduced in 2.8 to ease integrating your own voters. * The `AbstractVoter` class was removed in favor of the new `Voter` class. * The `Resources/` directory was moved to `Core/Resources/` * The `key` settings of `anonymous`, `remember_me` and `http_digest` are renamed to `secret`. Before: ```yaml security: # ... firewalls: default: # ... anonymous: { key: "%secret%" } remember_me: key: "%secret%" http_digest: key: "%secret%" ``` ```xml ``` ```php // ... $container->loadFromExtension('security', array( // ... 'firewalls' => array( // ... 'anonymous' => array('key' => '%secret%'), 'remember_me' => array('key' => '%secret%'), 'http_digest' => array('key' => '%secret%'), ), )); ``` After: ```yaml security: # ... firewalls: default: # ... anonymous: { secret: "%secret%" } remember_me: secret: "%secret%" http_digest: secret: "%secret%" ``` ```xml ``` ```php // ... $container->loadFromExtension('security', array( // ... 'firewalls' => array( // ... 'anonymous' => array('secret' => '%secret%'), 'remember_me' => array('secret' => '%secret%'), 'http_digest' => array('secret' => '%secret%'), ), )); ``` * The `AbstractVoter` class was removed. Instead, extend the new `Voter` class, introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)` and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods. * The `vote()` method from the `VoterInterface` was changed to now accept arbitrary types, and not only objects. * The `supportsClass` and `supportsAttribute` methods were removed from the `VoterInterface` interface. Before: ```php class MyVoter extends AbstractVoter { protected function getSupportedAttributes() { return array('CREATE', 'EDIT'); } protected function getSupportedClasses() { return array('AppBundle\Entity\Post'); } // ... } ``` After: ```php use Symfony\Component\Security\Core\Authorization\Voter\Voter; class MyVoter extends Voter { protected function supports($attribute, $object) { return $object instanceof Post && in_array($attribute, array('CREATE', 'EDIT')); } protected function voteOnAttribute($attribute, $object, TokenInterface $token) { // Return true or false } } ``` * The `AbstractVoter::isGranted()` method has been replaced by `Voter::voteOnAttribute()`. Before: ```php class MyVoter extends AbstractVoter { protected function isGranted($attribute, $object, $user = null) { return 'EDIT' === $attribute && $user === $object->getAuthor(); } // ... } ``` After: ```php class MyVoter extends Voter { protected function voteOnAttribute($attribute, $object, TokenInterface $token) { return 'EDIT' === $attribute && $token->getUser() === $object->getAuthor(); } // ... } ``` * The `supportsAttribute()` and `supportsClass()` methods of the `AuthenticatedVoter`, `ExpressionVoter`, and `RoleVoter` classes have been removed. * The `intention` option was renamed to `csrf_token_id` for all the authentication listeners. * The `csrf_provider` option was renamed to `csrf_token_generator` for all the authentication listeners. ### SecurityBundle * The `intention` firewall listener setting was renamed to `csrf_token_id`. * The `csrf_provider` firewall listener setting was renamed to `csrf_token_generator`. ### Serializer * The `setCamelizedAttributes()` method of the `Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer` and `Symfony\Component\Serializer\Normalizer\PropertyNormalizer` classes was removed. * The `Symfony\Component\Serializer\Exception\Exception` interface was removed in favor of the new `Symfony\Component\Serializer\Exception\ExceptionInterface`. ### Translator * The `Translator::setFallbackLocale()` method has been removed in favor of `Translator::setFallbackLocales()`. * The visibility of the `locale` property has been changed from protected to private. Rely on `getLocale` and `setLocale` instead. Before: ```php class CustomTranslator extends Translator { public function fooMethod() { // get locale $locale = $this->locale; // update locale $this->locale = $locale; } } ``` After: ```php class CustomTranslator extends Translator { public function fooMethod() { // get locale $locale = $this->getLocale(); // update locale $this->setLocale($locale); } } ``` * The method `FileDumper::format()` was removed. You should use `FileDumper::formatCatalogue()` instead. Before: ```php class CustomDumper extends FileDumper { protected function format(MessageCatalogue $messages, $domain) { ... } } ``` After: ```php class CustomDumper extends FileDumper { public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) { ... } } ``` * The `getMessages()` method of the `Symfony\Component\Translation\Translator` class was removed. You should use the `getCatalogue()` method of the `Symfony\Component\Translation\TranslatorBagInterface`. ### Twig Bridge * The `twig:lint` command has been deprecated since Symfony 2.7 and will be removed in Symfony 3.0. Use the `lint:twig` command instead. * The `render` tag is deprecated in favor of the `render` function. * The `form_enctype` helper was removed. You should use the new `form_start` function instead. Before: ```php
...
``` After: ```jinja {{ form_start(form) }} ... {{ form_end(form) }} ``` The method and action of the form default to "POST" and the current document. If you want to change these values, you can set them explicitly in the controller. Alternative 1: ```php $form = $this->createForm('my_form', $formData, array( 'method' => 'PUT', 'action' => $this->generateUrl('target_route'), )); ``` Alternative 2: ```php $form = $this->createFormBuilder($formData) // ... ->setMethod('PUT') ->setAction($this->generateUrl('target_route')) ->getForm(); ``` It is also possible to override the method and the action in the template: ```jinja {{ form_start(form, {'method': 'GET', 'action': 'http://example.com'}) }} ... {{ form_end(form) }} ``` ### TwigBundle * The `Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy` was removed in favor of `Twig_FileExtensionEscapingStrategy`. * The `twig:debug` command has been deprecated since Symfony 2.7 and will be removed in Symfony 3.0. Use the `debug:twig` command instead. ### Validator * The PHP7-incompatible constraints (`Null`, `True`, `False`) and their related validators (`NullValidator`, `TrueValidator`, `FalseValidator`) have been removed in favor of their `Is`-prefixed equivalent. * The class `Symfony\Component\Validator\Mapping\Cache\ApcCache` has been removed in favor of `Symfony\Component\Validator\Mapping\Cache\DoctrineCache`. Before: ```php use Symfony\Component\Validator\Mapping\Cache\ApcCache; $cache = new ApcCache('symfony.validator'); ``` After: ```php use Symfony\Component\Validator\Mapping\Cache\DoctrineCache; use Doctrine\Common\Cache\ApcCache; $apcCache = new ApcCache(); $apcCache->setNamespace('symfony.validator'); $cache = new DoctrineCache($apcCache); ``` * The constraints `Optional` and `Required` were moved to the `Symfony\Component\Validator\Constraints\` namespace. You should adapt the path wherever you used them. Before: ```php use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\Collection({ * "foo" = @Assert\Collection\Required(), * "bar" = @Assert\Collection\Optional(), * }) */ private $property; ``` After: ```php use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\Collection({ * "foo" = @Assert\Required(), * "bar" = @Assert\Optional(), * }) */ private $property; ``` * The option "`methods`" of the `Callback` constraint was removed. You should use the option "`callback`" instead. If you have multiple callbacks, add multiple callback constraints instead. Before (YAML): ```yaml constraints: - Callback: [firstCallback, secondCallback] ``` After (YAML): ```yaml constraints: - Callback: firstCallback - Callback: secondCallback ``` When using annotations, you can now put the `Callback` constraint directly on the method that should be executed. Before (Annotations): ```php use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\ExecutionContextInterface; /** * @Assert\Callback({"callback"}) */ class MyClass { public function callback(ExecutionContextInterface $context) { // ... } } ``` After (Annotations): ```php use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\ExecutionContextInterface; class MyClass { /** * @Assert\Callback */ public function callback(ExecutionContextInterface $context) { // ... } } ``` * The interface `ValidatorInterface` was replaced by the more powerful interface `Validator\ValidatorInterface`. The signature of the `validate()` method is slightly different in that interface and accepts a value, zero or more constraints and validation group. It replaces both `validate()` and `validateValue()` in the previous interface. Before: ```php $validator->validate($object, 'Strict'); $validator->validateValue($value, new NotNull()); ``` After: ```php $validator->validate($object, null, 'Strict'); $validator->validate($value, new NotNull()); ``` Apart from this change, the new methods `startContext()` and `inContext()` were added. The first of them allows to run multiple validations in the same context and aggregate their violations: ```php $violations = $validator->startContext() ->atPath('firstName')->validate($firstName, new NotNull()) ->atPath('age')->validate($age, new Type('integer')) ->getViolations(); ``` The second allows to run validation in an existing context. This is especially useful when calling the validator from within constraint validators: ```php $validator->inContext($context)->validate($object); ``` Instead of a `Validator`, the validator builder now returns a `Validator\RecursiveValidator` instead. * The interface `ValidationVisitorInterface` and its implementation `ValidationVisitor` were removed. The implementation of the visitor pattern was flawed. Fixing that implementation would have drastically slowed down the validator execution, so the visitor was removed completely instead. Along with the visitor, the method `accept()` was removed from `MetadataInterface`. * The interface `MetadataInterface` was moved to the `Mapping` namespace. Before: ```php use Symfony\Component\Validator\MetadataInterface; ``` After: ```php use Symfony\Component\Validator\Mapping\MetadataInterface; ``` The methods `getCascadingStrategy()` and `getTraversalStrategy()` were added to the interface. The first method should return a bit mask of the constants in class `CascadingStrategy`. The second should return a bit mask of the constants in `TraversalStrategy`. Example: ```php use Symfony\Component\Validator\Mapping\TraversalStrategy; public function getTraversalStrategy() { return TraversalStrategy::TRAVERSE; } ``` * The interface `PropertyMetadataInterface` was moved to the `Mapping` namespace. Before: ```php use Symfony\Component\Validator\PropertyMetadataInterface; ``` After: ```php use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; ``` * The interface `PropertyMetadataContainerInterface` was moved to the `Mapping` namespace and renamed to `ClassMetadataInterface`. Before: ```php use Symfony\Component\Validator\PropertyMetadataContainerInterface; ``` After: ```php use Symfony\Component\Validator\Mapping\ClassMetadataInterface; ``` The interface now contains four additional methods: * `getConstrainedProperties()` * `hasGroupSequence()` * `getGroupSequence()` * `isGroupSequenceProvider()` See the inline documentation of these methods for more information. * The interface `ClassBasedInterface` was removed. You should use `Mapping\ClassMetadataInterface` instead: Before: ```php use Symfony\Component\Validator\ClassBasedInterface; class MyClassMetadata implements ClassBasedInterface { // ... } ``` After: ```php use Symfony\Component\Validator\Mapping\ClassMetadataInterface; class MyClassMetadata implements ClassMetadataInterface { // ... } ``` * The class `ElementMetadata` was renamed to `GenericMetadata`. Before: ```php use Symfony\Component\Validator\Mapping\ElementMetadata; class MyMetadata extends ElementMetadata { } ``` After: ```php use Symfony\Component\Validator\Mapping\GenericMetadata; class MyMetadata extends GenericMetadata { } ``` * The interface `ExecutionContextInterface` and its implementation `ExecutionContext` were moved to the `Context` namespace. Before: ```php use Symfony\Component\Validator\ExecutionContextInterface; ``` After: ```php use Symfony\Component\Validator\Context\ExecutionContextInterface; ``` The interface now contains the following additional methods: * `getValidator()` * `getObject()` * `setNode()` * `setGroup()` * `markGroupAsValidated()` * `isGroupValidated()` * `markConstraintAsValidated()` * `isConstraintValidated()` See the inline documentation of these methods for more information. The method `addViolationAt()` was removed. You should use `buildViolation()` instead. Before: ```php $context->addViolationAt('property', 'The value {{ value }} is invalid.', array( '{{ value }}' => $invalidValue, )); ``` After: ```php $context->buildViolation('The value {{ value }} is invalid.') ->atPath('property') ->setParameter('{{ value }}', $invalidValue) ->addViolation(); ``` The methods `validate()` and `validateValue()` were removed. You should use `getValidator()` together with `inContext()` instead. Before: ```php $context->validate($object); ``` After: ```php $context->getValidator() ->inContext($context) ->validate($object); ``` The parameters `$invalidValue`, `$plural` and `$code` were removed from `addViolation()`. You should use `buildViolation()` instead. See above for an example. The method `getMetadataFactory()` was removed. You can use `getValidator()` instead and use the methods `getMetadataFor()` or `hasMetadataFor()` on the validator instance. Before: ```php $metadata = $context->getMetadataFactory()->getMetadataFor($myClass); ``` After: ```php $metadata = $context->getValidator()->getMetadataFor($myClass); ``` * The interface `GlobalExecutionContextInterface` was removed. Most of the information provided by that interface can be queried from `Context\ExecutionContextInterface` instead. * The interface `MetadataFactoryInterface` was moved to the `Mapping\Factory` namespace along with its implementations `BlackholeMetadataFactory` and `ClassMetadataFactory`. These classes were furthermore renamed to `BlackHoleMetadataFactory` and `LazyLoadingMetadataFactory`. Before: ```php use Symfony\Component\Validator\Mapping\ClassMetadataFactory; $factory = new ClassMetadataFactory($loader); ``` After: ```php use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; $factory = new LazyLoadingMetadataFactory($loader); ``` * The option `$deep` was removed from the constraint `Valid`. When traversing arrays, nested arrays are always traversed (same behavior as before). When traversing nested objects, their traversal strategy is used. * The method `ValidatorBuilder::setPropertyAccessor()` was removed. The validator now functions without a property accessor. * The methods `getMessageParameters()` and `getMessagePluralization()` in `ConstraintViolation` were renamed to `getParameters()` and `getPlural()`. Before: ```php $parameters = $violation->getMessageParameters(); $plural = $violation->getMessagePluralization(); ``` After: ```php $parameters = $violation->getParameters(); $plural = $violation->getPlural(); ``` * The class `Symfony\Component\Validator\DefaultTranslator` was removed. You should use `Symfony\Component\Translation\IdentityTranslator` instead. Before: ```php $translator = new \Symfony\Component\Validator\DefaultTranslator(); ``` After: ```php $translator = new \Symfony\Component\Translation\IdentityTranslator(); $translator->setLocale('en'); ``` ### Yaml * Using a colon in an unquoted mapping value leads to a `ParseException`. * Starting an unquoted string with `@`, `` ` ``, `|`, or `>` leads to a `ParseException`. * When surrounding strings with double-quotes, you must now escape `\` characters. Not escaping those characters (when surrounded by double-quotes) leads to a `ParseException`. Before: ```yml class: "Foo\Var" ``` After: ```yml class: "Foo\\Var" ``` * The ability to pass file names to `Yaml::parse()` has been removed. Before: ```php Yaml::parse($fileName); ``` After: ```php Yaml::parse(file_get_contents($fileName)); ``` ### WebProfiler * The `profiler:import` and `profiler:export` commands have been removed. * All the profiler storages different than `FileProfilerStorage` have been removed. The removed classes are: - `Symfony\Component\HttpKernel\Profiler\BaseMemcacheProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\PdoProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage` - `Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage` ### Process * `Process::setStdin()` and `Process::getStdin()` have been removed. Use `Process::setInput()` and `Process::getInput()` that works the same way. * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. ### Monolog Bridge * `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible. ### Swiftmailer Bridge * `Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector` was removed. Use the `Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector` class instead. ### HttpFoundation * The precedence of parameters returned from `Request::get()` changed from "GET, PATH, BODY" to "PATH, GET, BODY" * `Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface` no longer implements the `IteratorAggregate` interface. Use the `all()` method instead of iterating over the flash bag. * Removed the feature that allowed finding deep items in `ParameterBag::get()`. This may affect you when getting parameters from the `Request` class: Before: ```php $request->query->get('foo[bar]', null, true); ``` After: ```php $request->query->get('foo')['bar']; ``` ### Monolog Bridge * `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible. symfony-3.4.6/UPGRADE-3.1.md000066400000000000000000000142311324732107100151410ustar00rootroot00000000000000UPGRADE FROM 3.0 to 3.1 ======================= DependencyInjection ------------------- * Using unsupported configuration keys in YAML configuration files has been deprecated and will raise an exception in Symfony 4.0. * Using unsupported options to configure service aliases has been deprecated and will raise an exception in Symfony 4.0. Form ---- * The `choices_as_values` option of the `ChoiceType` has been deprecated and will be removed in Symfony 4.0. * Support for data objects that implements both `Traversable` and `ArrayAccess` in `ResizeFormListener::preSubmit` method has been deprecated and will be removed in Symfony 4.0. * `TextType` now implements `DataTransformerInterface` and will always return an empty string when `empty_data` option is explicitly assigned to it. * Using callable strings as choice options in ChoiceType has been deprecated in favor of `PropertyPath` in Symfony 4.0 use a "\Closure" instead. Before: ```php 'choice_value' => new PropertyPath('range'), 'choice_label' => 'strtoupper', ``` After: ```php 'choice_value' => 'range', 'choice_label' => function ($choice) { return strtoupper($choice); }, ``` * Caching of the loaded `ChoiceListInterface` in the `LazyChoiceList` has been deprecated, it must be cached in the `ChoiceLoaderInterface` implementation instead. FrameworkBundle --------------- * As it was never an officially supported feature, the support for absolute template paths has been deprecated and will be removed in Symfony 4.0. * The abstract `Controller` class now has a `json()` helper method that creates a `JsonResponse`. If you have existing controllers extending `Controller` that contain a method with this name, you need to rename that method to avoid conflicts. * The following form types registered as services have been deprecated and will be removed in Symfony 4.0; use their fully-qualified class name instead: - `"form.type.birthday"` - `"form.type.checkbox"` - `"form.type.collection"` - `"form.type.country"` - `"form.type.currency"` - `"form.type.date"` - `"form.type.datetime"` - `"form.type.email"` - `"form.type.file"` - `"form.type.hidden"` - `"form.type.integer"` - `"form.type.language"` - `"form.type.locale"` - `"form.type.money"` - `"form.type.number"` - `"form.type.password"` - `"form.type.percent"` - `"form.type.radio"` - `"form.type.range"` - `"form.type.repeated"` - `"form.type.search"` - `"form.type.textarea"` - `"form.type.text"` - `"form.type.time"` - `"form.type.timezone"` - `"form.type.url"` - `"form.type.button"` - `"form.type.submit"` - `"form.type.reset"` * The `framework.serializer.cache` option and the service `serializer.mapping.cache.apc` have been deprecated. APCu should now be automatically used when available. HttpKernel ---------- * Passing non-scalar values as URI attributes to the ESI and SSI renderers has been deprecated and will be removed in Symfony 4.0. The inline fragment renderer should be used with non-scalar attributes. * The `ControllerResolver::getArguments()` method has been deprecated and will be removed in 4.0. If you have your own `ControllerResolverInterface` implementation, you should inject either an `ArgumentResolverInterface` instance or the new `ArgumentResolver` in the `HttpKernel`. Serializer ---------- * Passing a Doctrine `Cache` instance to the `ClassMetadataFactory` has been deprecated and will not be supported in Symfony 4.0. You should use the `CacheClassMetadataFactory` class instead. * The `AbstractObjectNormalizer::isAttributeToNormalize()` method has been removed because it was initially added by mistake, has never been used and is not tested nor documented. Translation ----------- * Deprecated the backup feature of the file dumper classes. It will be removed in Symfony 4.0. Yaml ---- * Usage of `%` at the beginning of an unquoted string has been deprecated and will lead to a `ParseException` in Symfony 4.0. * The `Dumper::setIndentation()` method is deprecated and will be removed in Symfony 4.0. Pass the indentation level to the constructor instead. * Deprecated support for passing `true`/`false` as the second argument to the `parse()` method to trigger exceptions when an invalid type was passed. Before: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', true); ``` After: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); ``` * Deprecated support for passing `true`/`false` as the third argument to the `parse()` method to toggle object support. Before: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', false, true); ``` After: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_OBJECT); ``` * Deprecated support for passing `true`/`false` as the fourth argument to the `parse()` method to parse objects as maps. Before: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', false, false, true); ``` After: ```php Yaml::parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_OBJECT_FOR_MAP); ``` * Deprecated support for passing `true`/`false` as the fourth argument to the `dump()` method to trigger exceptions when an invalid type was passed. Before: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, true); ``` After: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); ``` * Deprecated support for passing `true`/`false` as the fifth argument to the `dump()` method to toggle object support. Before: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); ``` After: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_OBJECT); ``` * The `!!php/object` tag to indicate dumped PHP objects has been deprecated and will be removed in Symfony 4.0. Use the `!php/object` tag instead. Validator --------- * The `DateTimeValidator::PATTERN` constant has been deprecated and will be removed in Symfony 4.0. symfony-3.4.6/UPGRADE-3.2.md000066400000000000000000000173771324732107100151600ustar00rootroot00000000000000UPGRADE FROM 3.1 to 3.2 ======================= BrowserKit ---------- * Client HTTP user agent has been changed to 'Symfony BrowserKit' (was 'Symfony2 BrowserKit' before). Console ------- * Setting unknown style options is deprecated and will throw an exception in Symfony 4.0. * The `QuestionHelper::setInputStream()` method is deprecated and will be removed in Symfony 4.0. Use `StreamableInputInterface::setStream()` or `CommandTester::setInputs()` instead. Before: ```php $input = new ArrayInput(); $questionHelper->setInputStream($stream); $questionHelper->ask($input, $output, $question); ``` After: ```php $input = new ArrayInput(); $input->setStream($stream); $questionHelper->ask($input, $output, $question); ``` Before: ```php $commandTester = new CommandTester($command); $stream = fopen('php://memory', 'r+', false); fputs($stream, "AppBundle\nYes"); rewind($stream); $command->getHelper('question')->setInputStream($stream); $commandTester->execute(); ``` After: ```php $commandTester = new CommandTester($command); $commandTester->setInputs(array('AppBundle', 'Yes')); $commandTester->execute(); ``` DependencyInjection ------------------- * Calling `get()` on a `ContainerBuilder` instance before compiling the container is deprecated and will throw an exception in Symfony 4.0. * Setting or unsetting a private service with the `Container::set()` method is deprecated. Only public services can be set or unset in Symfony 4.0. * Checking the existence of a private service with the `Container::has()` method is deprecated and will return `false` in Symfony 4.0. * Requesting a private service with the `Container::get()` method is deprecated and will no longer be supported in Symfony 4.0. ExpressionLanguage ------------------- * Passing a `ParserCacheInterface` instance to the `ExpressionLanguage` has been deprecated and will not be supported in Symfony 4.0. You should use the `CacheItemPoolInterface` interface instead. Form ---- * Calling `isValid()` on a `Form` instance before submitting it is deprecated and will throw an exception in Symfony 4.0. Before: ```php if ($form->isValid()) { // ... } ``` After: ```php if ($form->isSubmitted() && $form->isValid()) { // ... } ``` FrameworkBundle --------------- * The `doctrine/annotations` dependency has been removed; require it via `composer require doctrine/annotations` if you are using annotations in your project * The `symfony/security-core` and `symfony/security-csrf` dependencies have been removed; require them via `composer require symfony/security-core symfony/security-csrf` if you depend on them and don't already depend on `symfony/symfony` * The `symfony/templating` dependency has been removed; require it via `composer require symfony/templating` if you depend on it and don't already depend on `symfony/symfony` * The `symfony/translation` dependency has been removed; require it via `composer require symfony/translation` if you depend on it and don't already depend on `symfony/symfony` * The `symfony/asset` dependency has been removed; require it via `composer require symfony/asset` if you depend on it and don't already depend on `symfony/symfony` * The `Resources/public/images/*` files have been removed. * The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle). * The service `serializer.mapping.cache.doctrine.apc` is deprecated. APCu should now be automatically used when available. HttpFoundation --------------- * Extending the following methods of `Response` is deprecated (these methods will be `final` in 4.0): - `setDate`/`getDate` - `setExpires`/`getExpires` - `setLastModified`/`getLastModified` - `setProtocolVersion`/`getProtocolVersion` - `setStatusCode`/`getStatusCode` - `setCharset`/`getCharset` - `setPrivate`/`setPublic` - `getAge` - `getMaxAge`/`setMaxAge` - `setSharedMaxAge` - `getTtl`/`setTtl` - `setClientTtl` - `getEtag`/`setEtag` - `hasVary`/`getVary`/`setVary` - `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError` - `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty` * Checking only for cacheable HTTP methods with `Request::isMethodSafe()` is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use `Request::isMethodCacheable()` instead. HttpKernel ---------- * `DataCollector::varToString()` is deprecated and will be removed in Symfony 4.0. Use the `cloneVar()` method instead. * Surrogate name in a `Surrogate-Capability` HTTP request header has been changed to 'symfony'. Before: ``` Surrogate-Capability: symfony2="ESI/1.0" ``` After: ``` Surrogate-Capability: symfony="ESI/1.0" ``` Router ------ * `UrlGenerator` now generates URLs in compliance with [`RFC 3986`](https://www.ietf.org/rfc/rfc3986.txt), which means spaces will be percent encoded (%20) inside query strings. Serializer ---------- * Method `AbstractNormalizer::instantiateObject()` will have a 6th `$format = null` argument in Symfony 4.0. Not defining it when overriding the method is deprecated. TwigBridge ---------- * Injecting the Form `TwigRenderer` into the `FormExtension` is deprecated and has no more effect. Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead. Before: ```php use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRenderer; use Symfony\Bridge\Twig\Form\TwigRendererEngine; // ... $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig')); $rendererEngine->setEnvironment($twig); $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager))); ``` After: ```php $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig); $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array( TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) { return new TwigRenderer($rendererEngine, $csrfTokenManager); }, ))); $twig->addExtension(new FormExtension()); ``` * Deprecated the `TwigRendererEngineInterface` interface, it will be removed in 4.0. Validator --------- * `Tests\Constraints\AbstractConstraintValidatorTest` has been deprecated in favor of `Test\ConstraintValidatorTestCase`. Before: ```php // ... use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; class MyCustomValidatorTest extends AbstractConstraintValidatorTest { // ... } ``` After: ```php // ... use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class MyCustomValidatorTest extends ConstraintValidatorTestCase { // ... } ``` * Setting the strict option of the `Choice` Constraint to `false` has been deprecated and the option will be changed to `true` as of 4.0. ```php // ... use Symfony\Component\Validator\Constraints as Assert; class MyEntity { /** * @Assert\Choice(choices={"MR", "MRS"}, strict=true) */ private $salutation; } ``` Yaml ---- * Support for silently ignoring duplicate mapping keys in YAML has been deprecated and will lead to a `ParseException` in Symfony 4.0. * Mappings with a colon (`:`) that is not followed by a whitespace are deprecated and will lead to a `ParseException` in Symfony 4.0 (e.g. `foo:bar` must be `foo: bar`). symfony-3.4.6/UPGRADE-3.3.md000066400000000000000000000333511324732107100151470ustar00rootroot00000000000000UPGRADE FROM 3.2 to 3.3 ======================= BrowserKit ---------- * The request method is dropped from POST to GET when the response status code is 301. ClassLoader ----------- * The component is deprecated and will be removed in 4.0. Use Composer instead. Console ------- * `Input::getOption()` no longer returns the default value for options with value optional explicitly passed empty. For: ```php protected function configure() { $this // ... ->setName('command') ->addOption('foo', null, InputOption::VALUE_OPTIONAL, '', 'default') ; } protected function execute(InputInterface $input, OutputInterface $output) { var_dump($input->getOption('foo')); } ``` Before: ``` $ php console.php command "default" $ php console.php command --foo "default" $ php console.php command --foo "" "default" $ php console.php command --foo= "default" ``` After: ``` $ php console.php command "default" $ php console.php command --foo NULL $ php console.php command --foo "" "" $ php console.php command --foo= "" ``` * The `console.exception` event and the related `ConsoleExceptionEvent` class have been deprecated in favor of the `console.error` event and the `ConsoleErrorEvent` class. The deprecated event and class will be removed in 4.0. * The `SymfonyQuestionHelper::ask` default validation has been deprecated and will be removed in 4.0. Apply validation using `Question::setValidator` instead. Debug ----- * The `ContextErrorException` class is deprecated. `\ErrorException` will be used instead in 4.0. DependencyInjection ------------------- * Autowiring services based on the types they implement is deprecated and won't be supported in version 4.0. Rename (or alias) your services to their FQCN id to make them autowirable. * The `NullDumper` class has been made final * [BC BREAK] `_defaults` and `_instanceof` are now reserved service names in Yaml configurations. Please rename any services with that names. * [BC BREAK] non-numeric keys in methods and constructors arguments have never been supported and are now forbidden. Please remove them if you happen to have one. * Service names that start with an underscore are deprecated in Yaml files and will be reserved in 4.0. Please rename any services with such names. * Autowiring-types have been deprecated, use aliases instead. Before: ```xml Doctrine\Common\Annotations\Reader ``` After: ```xml ``` * The `Reference` and `Alias` classes do not make service identifiers lowercase anymore. * Case insensitivity of service identifiers is deprecated and will be removed in 4.0. * Using the `PhpDumper` with an uncompiled `ContainerBuilder` is deprecated and will not be supported anymore in 4.0. * Extending the containers generated by `PhpDumper` is deprecated and won't be supported in 4.0. * The `DefinitionDecorator` class is deprecated and will be removed in 4.0, use the `ChildDefinition` class instead. * The ``strict`` attribute in service arguments has been deprecated and will be removed in 4.0. The attribute is ignored since 3.0, so you can simply remove it. EventDispatcher --------------- * The `ContainerAwareEventDispatcher` class has been deprecated. Use `EventDispatcher` with closure factories instead. Finder ------ * The `ExceptionInterface` has been deprecated and will be removed in 4.0. Form ---- * Using the "choices" option in ``CountryType``, ``CurrencyType``, ``LanguageType``, ``LocaleType``, and ``TimezoneType`` without overriding the ``choice_loader`` option has been deprecated and will be ignored in 4.0. Before: ```php $builder->add('custom_locales', LocaleType::class, array( 'choices' => $availableLocales, )); ``` After: ```php $builder->add('custom_locales', LocaleType::class, array( 'choices' => $availableLocales, 'choice_loader' => null, )); // or $builder->add('custom_locales', LocaleType::class, array( 'choice_loader' => new CallbackChoiceLoader(function () { return $this->getAvailableLocales(); }), )); ``` FrameworkBundle --------------- * [BC BREAK] The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been removed. Use the Request::setTrustedProxies() method in your front controller instead. * Not defining the `type` option of the `framework.workflows.*` configuration entries is deprecated. The default value will be `state_machine` in Symfony 4.0. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been deprecated. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Serializer\DependencyInjection\SerializerPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Form\DependencyInjection\FormPass` class instead. * The `Symfony\Bundle\FrameworkBundle\EventListener\SessionListener` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\SessionListener` class instead. * The `Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been deprecated and will be removed in 4.0. Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` class instead. * Class parameters related to routing have been deprecated and will be removed in 4.0. * router.options.generator_class * router.options.generator_base_class * router.options.generator_dumper_class * router.options.matcher_class * router.options.matcher_base_class * router.options.matcher_dumper_class * router.options.matcher.cache_class * router.options.generator.cache_class * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead. * The `server:run`, `server:start`, `server:stop` and `server:status` console commands have been moved to a dedicated bundle. Require `symfony/web-server-bundle` in your composer.json and register `Symfony\Bundle\WebServerBundle\WebServerBundle` in your AppKernel to use them. * The `Symfony\Bundle\FrameworkBundle\Translation\Translator` constructor now takes the default locale as 3rd argument. Not passing it will trigger an error in 4.0. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddValidatorInitializersPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass` class instead. * The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been deprecated and will be removed in 4.0. Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead. HttpFoundation -------------- * [BC BREAK] The `Request::setTrustedProxies()` method takes a new `$trustedHeaderSet` argument. See http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html for more info. * The `Request::setTrustedHeaderName()` and `Request::getTrustedHeaderName()` methods are deprecated, use the RFC7239 `Forwarded` header, or the `X-Forwarded-*` headers instead. HttpKernel ----------- * The `Extension::addClassesToCompile()` and `Extension::getClassesToCompile()` methods have been deprecated and will be removed in 4.0. * The `Psr6CacheClearer::addPool()` method has been deprecated. Pass an array of pools indexed by name to the constructor instead. * The `LazyLoadingFragmentHandler::addRendererService()` method has been deprecated and will be removed in 4.0. * The `X-Status-Code` header method of setting a custom status code in the response when handling exceptions has been removed. There is now a new `GetResponseForExceptionEvent::allowCustomResponseCode()` method instead, which will tell the Kernel to use the response code set on the event's response object. * The `Kernel::getEnvParameters()` method has been deprecated and will be removed in 4.0. * The `SYMFONY__` environment variables have been deprecated and they will be no longer processed automatically by Symfony in 4.0. Use the `%env()%` syntax to get the value of any environment variable from configuration files instead. Process ------- * The `ProcessUtils::escapeArgument()` method has been deprecated, use a command line array or give env vars to the `Process::start/run()` method instead. * Not inheriting environment variables is deprecated. * Configuring `proc_open()` options is deprecated. * Configuring Windows and sigchild compatibility is deprecated - they will be always enabled in 4.0. * Extending `Process::run()`, `Process::mustRun()` and `Process::restart()` is deprecated and won't be supported in 4.0. ProxyManager ------------ * [BC BREAK] The `ProxyDumper` class has been made final Security -------- * The `RoleInterface` has been deprecated. Extend the `Symfony\Component\Security\Core\Role\Role` class in your custom role implementations instead. * The `LogoutUrlGenerator::registerListener()` method will expect a 6th `string $context = null` argument in 4.0. Define the argument when overriding this method. * The `AccessDecisionManager::setVoters()` method has been deprecated. Pass the voters to the constructor instead. SecurityBundle -------------- * The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0. Use the `getListeners()` and/or `getExceptionListener()` method instead. * The `FirewallMap::$map` and `$container` properties have been deprecated and will be removed in 4.0. * The `UserPasswordEncoderCommand` command expects to be registered as a service and its constructor arguments fully provided. Registering by convention the command or commands extending it is deprecated and will not be allowed anymore in 4.0. * `UserPasswordEncoderCommand::getContainer()` is deprecated, and this class won't extend `ContainerAwareCommand` nor implement `ContainerAwareInterface` anymore in 4.0. * [BC BREAK] Keys of the `users` node for `in_memory` user provider are no longer normalized. Serializer ---------- * Extending `ChainDecoder`, `ChainEncoder`, `ArrayDenormalizer` is deprecated and won't be supported in 4.0. TwigBridge ---------- * The `TwigRendererEngine::setEnvironment()` method has been deprecated and will be removed in 4.0. Pass the Twig Environment as second argument of the constructor instead. TwigBundle ---------- * The `ContainerAwareRuntimeLoader` class has been deprecated and will be removed in 4.0. Use the Twig `Twig_ContainerRuntimeLoader` class instead. Workflow -------- * Deprecated class name support in `WorkflowRegistry::add()` as second parameter. Wrap the class name in an instance of ClassInstanceSupportStrategy instead. Yaml ---- * Starting an unquoted string with a question mark followed by a space is deprecated and will throw a `ParseException` in Symfony 4.0. * Deprecated support for implicitly parsing non-string mapping keys as strings. Mapping keys that are no strings will lead to a `ParseException` in Symfony 4.0. Use quotes to opt-in for keys to be parsed as strings. Before: ```php $yaml = <<setDefault('choice_loader', ...); // override the option instead } } ``` FrameworkBundle --------------- * The `session.use_strict_mode` option has been deprecated and is enabled by default. * The `cache:clear` command doesn't clear "app" PSR-6 cache pools anymore, but still clears "system" ones. Use the `cache:pool:clear` command to clear "app" pools instead. * The `doctrine/cache` dependency has been removed; require it via `composer require doctrine/cache` if you are using Doctrine cache in your project. * The `validator.mapping.cache.doctrine.apc` service has been deprecated. * The `symfony/stopwatch` dependency has been removed, require it via `composer require symfony/stopwatch` in your `dev` environment. * Using the `KERNEL_DIR` environment variable or the automatic guessing based on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4. Set the `KERNEL_CLASS` environment variable to the fully-qualified class name of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()` or `KernelTestCase::getKernelClass()` method. * The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods are deprecated since 3.4 and will be removed in 4.0. * The `--no-prefix` option of the `translation:update` command is deprecated and will be removed in 4.0. Use the `--prefix` option with an empty string as value instead (e.g. `--prefix=""`) * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been deprecated and will be removed in 4.0. Use tagged iterator arguments instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been deprecated and will be removed in 4.0. Use tagged iterator arguments instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead. * The `Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Reader\TranslationReader` class instead. * The `translation.loader` service has been deprecated and will be removed in 4.0. Use the `translation.reader` service instead.. * `AssetsInstallCommand::__construct()` now takes an instance of `Symfony\Component\Filesystem\Filesystem` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `CacheClearCommand::__construct()` now takes an instance of `Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `CachePoolClearCommand::__construct()` now takes an instance of `Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `EventDispatcherDebugCommand::__construct()` now takes an instance of `Symfony\Component\EventDispatcher\EventDispatcherInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `RouterDebugCommand::__construct()` now takes an instance of `Symfony\Component\Routing\RouterInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `RouterMatchCommand::__construct()` now takes an instance of `Symfony\Component\Routing\RouterInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `TranslationDebugCommand::__construct()` now takes an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `TranslationUpdateCommand::__construct()` now takes an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * `AssetsInstallCommand`, `CacheClearCommand`, `CachePoolClearCommand`, `EventDispatcherDebugCommand`, `RouterDebugCommand`, `RouterMatchCommand`, `TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand` and `YamlLintCommand` classes have been marked as final * The `Symfony\Bundle\FrameworkBundle\Translation\PhpExtractor` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Extractor\PhpExtractor` class instead. * The `Symfony\Bundle\FrameworkBundle\Translation\PhpStringTokenParser` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Extractor\PhpStringTokenParser` class instead. HttpFoundation -------------- * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler` class has been deprecated and will be removed in 4.0. Use the `\SessionHandler` class instead. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler` class has been deprecated and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead. * The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` class has been deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly. * Using `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` with the legacy mongo extension has been deprecated and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler` class has been deprecated and will be removed in 4.0. Use `Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler` instead. HttpKernel ---------- * Bundle inheritance has been deprecated. * Relying on convention-based commands discovery has been deprecated and won't be supported in 4.0. Use PSR-4 based service discovery instead. Before: ```yml # app/config/services.yml services: # ... # implicit registration of all commands in the `Command` folder ``` After: ```yml # app/config/services.yml services: # ... # explicit commands registration AppBundle\Command\: resource: '../../src/AppBundle/Command/*' tags: ['console.command'] ``` * The `getCacheDir()` method of your kernel should not be called while building the container. Use the `%kernel.cache_dir%` parameter instead. Not doing so may break the `cache:clear` command. * The `Symfony\Component\HttpKernel\Config\EnvParametersResource` class has been deprecated and will be removed in 4.0. * Implementing `DataCollectorInterface` without a `reset()` method has been deprecated and will be unsupported in 4.0. * Implementing `DebugLoggerInterface` without a `clear()` method has been deprecated and will be unsupported in 4.0. * The `ChainCacheClearer::add()` method has been deprecated and will be removed in 4.0, inject the list of clearers as a constructor argument instead. * The `CacheWarmerAggregate::add()` and `setWarmers()` methods have been deprecated and will be removed in 4.0, inject the list of clearers as a constructor argument instead. * The `CacheWarmerAggregate` and `ChainCacheClearer` classes have been made final. Process ------- * The `Symfony\Component\Process\ProcessBuilder` class has been deprecated, use the `Symfony\Component\Process\Process` class directly instead. * Calling `Process::start()` without setting a valid working directory (via `setWorkingDirectory()` or constructor) beforehand is deprecated and will throw an exception in 4.0. Profiler -------- * The `profiler.matcher` option has been deprecated. Security -------- * Deprecated the HTTP digest authentication: `NonceExpiredException`, `DigestAuthenticationListener` and `DigestAuthenticationEntryPoint` will be removed in 4.0. Use another authentication system like `http_basic` instead. * The `GuardAuthenticatorInterface` has been deprecated and will be removed in 4.0. Use `AuthenticatorInterface` instead. SecurityBundle -------------- * Using voters that do not implement the `VoterInterface`is now deprecated in the `AccessDecisionManager` and this functionality will be removed in 4.0. * `FirewallContext::getListeners()` now returns `\Traversable|array` * `InitAclCommand::__construct()` now takes an instance of `Doctrine\DBAL\Connection` as first argument. Not passing it is deprecated and will throw a `TypeError` in 4.0. * The `acl:set` command has been deprecated along with the `SetAclCommand` class, both will be removed in 4.0. Install symfony/acl-bundle instead * The `init:acl` command has been deprecated along with the `InitAclCommand` class, both will be removed in 4.0. Install symfony/acl-bundle and use `acl:init` instead * Added `logout_on_user_change` to the firewall options. This config item will trigger a logout when the user has changed. Should be set to true to avoid deprecations in the configuration. * Deprecated the HTTP digest authentication: `HttpDigestFactory` will be removed in 4.0. Use another authentication system like `http_basic` instead. * Deprecated setting the `switch_user.stateless` option to false when the firewall is `stateless`. Setting it to false will have no effect in 4.0. * Not configuring explicitly the provider on a firewall is ambiguous when there is more than one registered provider. Using the first configured provider is deprecated since 3.4 and will throw an exception on 4.0. Explicitly configure the provider to use on your firewalls. Translation ----------- * `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations` has been deprecated and will be removed in 4.0, use `Symfony\Component\Translation\Writer\TranslationWriter::write` instead. * Passing a `Symfony\Component\Translation\MessageSelector` to `Translator` has been deprecated. You should pass a message formatter instead Before: ```php use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\MessageSelector; $translator = new Translator('fr_FR', new MessageSelector()); ``` After: ```php use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Formatter\MessageFormatter; $translator = new Translator('fr_FR', new MessageFormatter()); ``` TwigBridge ---------- * deprecated the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer` class from the Form component instead * deprecated `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability to pass a command name as first argument * deprecated `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability to pass a command name as first argument TwigBundle ---------- * deprecated the `Symfony\Bundle\TwigBundle\Command\DebugCommand` class, use the `DebugCommand` class from the Twig bridge instead * deprecated relying on the `ContainerAwareInterface` implementation for `Symfony\Bundle\TwigBundle\Command\LintCommand` Validator --------- * Not setting the `strict` option of the `Choice` constraint to `true` is deprecated and will throw an exception in Symfony 4.0. Yaml ---- * the `Dumper`, `Parser`, and `Yaml` classes are marked as final * using the `!php/object:` tag is deprecated and won't be supported in 4.0. Use the `!php/object` tag (without the colon) instead. * using the `!php/const:` tag is deprecated and won't be supported in 4.0. Use the `!php/const` tag (without the colon) instead. Before: ```yml !php/const:PHP_INT_MAX ``` After: ```yml !php/const PHP_INT_MAX ``` * Support for the `!str` tag is deprecated, use the `!!str` tag instead. * Using the non-specific tag `!` is deprecated and will have a different behavior in 4.0. Use a plain integer or `!!float` instead. * Using the `Yaml::PARSE_KEYS_AS_STRINGS` flag is deprecated as it will be removed in 4.0. Before: ```php $yaml = <</views/` | `templates/bundles//` | `app/Resources/` | `src/Resources/` | `app/Resources/assets/` | `assets/` | `app/Resources/translations/` | `translations/` | `app/Resources/views/` | `templates/` | `src/AppBundle/` | `src/` | `var/logs/` | `var/log/` | `web/` | `public/` | `web/app.php` | `public/index.php` | `web/app_dev.php` | `public/index.php` Then, upgrade the contents of your console script and your front controller: * `bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console * `public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php Lastly, read the following article to add Symfony Flex to your application and upgrade the configuration files: https://symfony.com/doc/current/setup/flex.html If you use Symfony components instead of the whole framework, you can find below the upgrading instructions for each individual bundle and component. ClassLoader ----------- * The component has been removed. Use Composer instead. Config ------ * The protected `TreeBuilder::$builder` property has been removed. Console ------- * Setting unknown style options is not supported anymore and throws an exception. * The `QuestionHelper::setInputStream()` method is removed. Use `StreamableInputInterface::setStream()` or `CommandTester::setInputs()` instead. Before: ```php $input = new ArrayInput(); $questionHelper->setInputStream($stream); $questionHelper->ask($input, $output, $question); ``` After: ```php $input = new ArrayInput(); $input->setStream($stream); $questionHelper->ask($input, $output, $question); ``` Before: ```php $commandTester = new CommandTester($command); $stream = fopen('php://memory', 'r+', false); fputs($stream, "AppBundle\nYes"); rewind($stream); $command->getHelper('question')->setInputStream($stream); $commandTester->execute(); ``` After: ```php $commandTester = new CommandTester($command); $commandTester->setInputs(array('AppBundle', 'Yes')); $commandTester->execute(); ``` * The `console.exception` event and the related `ConsoleExceptionEvent` class have been removed in favor of the `console.error` event and the `ConsoleErrorEvent` class. * The `SymfonyQuestionHelper::ask` default validation has been removed in favor of `Question::setValidator`. Debug ----- * The `ContextErrorException` class has been removed. Use `\ErrorException` instead. * `FlattenException::getTrace()` now returns additional type descriptions `integer` and `float`. * Support for stacked errors in the `ErrorHandler` has been removed DependencyInjection ------------------- * Definitions and aliases are now private by default in 4.0. You should either use service injection or explicitly define your services as public if you really need to inject the container. * Relying on service auto-registration while autowiring is not supported anymore. Explicitly inject your dependencies or create services whose ids are their fully-qualified class name. Before: ```php namespace App\Controller; use App\Mailer; class DefaultController { public function __construct(Mailer $mailer) { // ... } // ... } ``` ```yml services: App\Controller\DefaultController: autowire: true ``` After: ```php // same PHP code ``` ```yml services: App\Controller\DefaultController: autowire: true # or # App\Controller\DefaultController: # arguments: { $mailer: "@App\Mailer" } App\Mailer: autowire: true ``` * Autowiring services based on the types they implement is not supported anymore. It will only look for an alias or a service id that matches a given FQCN. Rename (or alias) your services to their FQCN id to make them autowirable. In 3.4, you can activate this behavior instead of having deprecation messages by setting the following parameter: ```yml parameters: container.autowiring.strict_mode: true ``` From 4.0, you can remove it as it's the default behavior and the parameter is not handled anymore. * `_defaults` and `_instanceof` are now reserved service names in Yaml configurations. Please rename any services with that names. * Non-numeric keys in methods and constructors arguments have never been supported and are now forbidden. Please remove them if you happen to have one. * Service names that start with an underscore are now reserved in Yaml files. Please rename any services with such names. * Autowiring-types have been removed, use aliases instead. Before: ```xml Doctrine\Common\Annotations\Reader ``` After: ```xml ``` * Service identifiers and parameter names are now case sensitive. * The `Reference` and `Alias` classes do not make service identifiers lowercase anymore. * Using the `PhpDumper` with an uncompiled `ContainerBuilder` is not supported anymore. * Extending the containers generated by `PhpDumper` is not supported anymore. * The `DefinitionDecorator` class has been removed. Use the `ChildDefinition` class instead. * The `ResolveDefinitionTemplatesPass` class has been removed. Use the `ResolveChildDefinitionsPass` class instead. * Using unsupported configuration keys in YAML configuration files raises an exception. * Using unsupported options to configure service aliases raises an exception. * Setting or unsetting a service with the `Container::set()` method is no longer supported. Only synthetic services can be set or unset. * Checking the existence of a private service with the `Container::has()` method is no longer supported and will return `false`. * Requesting a private service with the `Container::get()` method is no longer supported. * The ``strict`` attribute in service arguments has been removed. The attribute is ignored since 3.0, so you can simply remove it. * Top-level anonymous services in XML are no longer supported. * The `ExtensionCompilerPass` has been moved to before-optimization passes with priority -1000. * In 3.4, parameter `container.dumper.inline_class_loader` was introduced. Unless you're using a custom autoloader, you should enable this parameter. This can drastically improve DX by reducing the time to load classes when the `DebugClassLoader` is enabled. If you're using `FrameworkBundle`, this performance improvement will also impact the "dev" environment: ```yml parameters: container.dumper.inline_class_loader: true ``` DoctrineBridge -------------- * The `Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler` and `Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandlerSchema` have been removed. Use `Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` instead. EventDispatcher --------------- * The `ContainerAwareEventDispatcher` class has been removed. Use `EventDispatcher` with closure factories instead. * The `reset()` method has been added to `TraceableEventDispatcherInterface`. ExpressionLanguage ------------------ * The ability to pass a `ParserCacheInterface` instance to the `ExpressionLanguage` class has been removed. You should use the `CacheItemPoolInterface` interface instead. Filesystem ---------- * The `Symfony\Component\Filesystem\LockHandler` has been removed, use the `Symfony\Component\Lock\Store\FlockStore` class or the `Symfony\Component\Lock\Store\FlockStore\SemaphoreStore` class directly instead. * Support for passing relative paths to `Filesystem::makePathRelative()` has been removed. Finder ------ * The `ExceptionInterface` has been removed. * The `Symfony\Component\Finder\Iterator\FilterIterator` class has been removed as it used to fix a bug which existed before version 5.5.23/5.6.7 Form ---- * The values of the `FormEvents::*` constants have been updated to match the constant names. You should only update your application if you relied on the constant values instead of their names. * The `choices_as_values` option of the `ChoiceType` has been removed. * Support for data objects that implements both `Traversable` and `ArrayAccess` in `ResizeFormListener::preSubmit` method has been removed. * Using callable strings as choice options in ChoiceType is not supported anymore in favor of passing PropertyPath instances. Before: ```php 'choice_value' => new PropertyPath('range'), 'choice_label' => 'strtoupper', ``` After: ```php 'choice_value' => 'range', 'choice_label' => function ($choice) { return strtoupper($choice); }, ``` * Caching of the loaded `ChoiceListInterface` in the `LazyChoiceList` has been removed, it must be cached in the `ChoiceLoaderInterface` implementation instead. * Calling `isValid()` on a `Form` instance before submitting it is not supported anymore and raises an exception. Before: ```php if ($form->isValid()) { // ... } ``` After: ```php if ($form->isSubmitted() && $form->isValid()) { // ... } ``` * Using the "choices" option in ``CountryType``, ``CurrencyType``, ``LanguageType``, ``LocaleType``, and ``TimezoneType`` without overriding the ``choice_loader`` option is now ignored. Before: ```php $builder->add('custom_locales', LocaleType::class, array( 'choices' => $availableLocales, )); ``` After: ```php $builder->add('custom_locales', LocaleType::class, array( 'choices' => $availableLocales, 'choice_loader' => null, )); // or $builder->add('custom_locales', LocaleType::class, array( 'choice_loader' => new CallbackChoiceLoader(function () { return $this->getAvailableLocales(); }), )); ``` * Removed `ChoiceLoaderInterface` implementation in `TimezoneType`. Use the "choice_loader" option instead. Before: ```php class MyTimezoneType extends TimezoneType { public function loadChoices() { // override the method } } ``` After: ```php class MyTimezoneType extends AbstractType { public function getParent() { return TimezoneType::class; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefault('choice_loader', ...); // override the option instead } } ``` * `FormRendererInterface::setTheme` and `FormRendererEngineInterface::setTheme` have a new optional argument `$useDefaultThemes` with a default value set to `true`. FrameworkBundle --------------- * The `session.use_strict_mode` option has been removed and strict mode is always enabled. * The `validator.mapping.cache.doctrine.apc` service has been removed. * The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been removed. Use the `Request::setTrustedProxies()` method in your front controller instead. * The default value of the `framework.workflows.[name].type` configuration options is now `state_machine`. * Support for absolute template paths has been removed. * The following form types registered as services have been removed; use their fully-qualified class name instead: - `"form.type.birthday"` - `"form.type.checkbox"` - `"form.type.collection"` - `"form.type.country"` - `"form.type.currency"` - `"form.type.date"` - `"form.type.datetime"` - `"form.type.email"` - `"form.type.file"` - `"form.type.hidden"` - `"form.type.integer"` - `"form.type.language"` - `"form.type.locale"` - `"form.type.money"` - `"form.type.number"` - `"form.type.password"` - `"form.type.percent"` - `"form.type.radio"` - `"form.type.range"` - `"form.type.repeated"` - `"form.type.search"` - `"form.type.textarea"` - `"form.type.text"` - `"form.type.time"` - `"form.type.timezone"` - `"form.type.url"` - `"form.type.button"` - `"form.type.submit"` - `"form.type.reset"` * The `framework.serializer.cache` option and the services `serializer.mapping.cache.apc` and `serializer.mapping.cache.doctrine.apc` have been removed. APCu should now be automatically used when available. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been removed. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been removed. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been removed. Use the `Symfony\Component\Serializer\DependencyInjection\SerializerPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass` class has been removed. Use the `Symfony\Component\Form\DependencyInjection\FormPass` class instead. * The `Symfony\Bundle\FrameworkBundle\EventListener\SessionListener` class has been removed. Use the `Symfony\Component\HttpKernel\EventListener\SessionListener` class instead. * The `Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener` class has been removed. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been removed. Use tagged iterator arguments instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass` class has been removed. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` class instead. * Class parameters related to routing have been removed * router.options.generator_class * router.options.generator_base_class * router.options.generator_dumper_class * router.options.matcher_class * router.options.matcher_base_class * router.options.matcher_dumper_class * router.options.matcher.cache_class * router.options.generator.cache_class * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class has been removed. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass` class has been removed. Use the `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead. * The `Symfony\Bundle\FrameworkBundle\Translation\Translator` constructor now takes the default locale as mandatory 3rd argument. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddValidatorInitializersPass` class has been removed. Use the `Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass` class has been removed. Use the `Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass` class instead. * Using the `KERNEL_DIR` environment variable and the automatic guessing based on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()` method implementation. Set the `KERNEL_CLASS` environment variable to the fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()` or `KernelTestCase::getKernelClass()` method instead. * The methods `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` have been removed. * The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed. Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead. * The `--no-prefix` option of the `translation:update` command has been removed. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been removed. Use tagged iterator arguments instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been removed. Use tagged iterator arguments instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass` class has been removed. Use the `Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass` class has been removed. Use the `Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` class instead. * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass` class has been removed. Use the `Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead. * The `Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Reader\TranslationReader` class instead. * The `translation.loader` service has been removed. Use the `translation.reader` service instead. * `AssetsInstallCommand::__construct()` now requires an instance of `Symfony\Component\Filesystem\Filesystem` as first argument. * `CacheClearCommand::__construct()` now requires an instance of `Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface` as first argument. * `CachePoolClearCommand::__construct()` now requires an instance of `Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer` as first argument. * `EventDispatcherDebugCommand::__construct()` now requires an instance of `Symfony\Component\EventDispatcher\EventDispatcherInterface` as first argument. * `RouterDebugCommand::__construct()` now requires an instance of `Symfony\Component\Routing\RouterInterface` as first argument. * `RouterMatchCommand::__construct()` now requires an instance of `Symfony\Component\Routing\RouterInterface` as first argument. * `TranslationDebugCommand::__construct()` now requires an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument. * `TranslationUpdateCommand::__construct()` now requires an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument. * The `Symfony\Bundle\FrameworkBundle\Translation\PhpExtractor` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Extractor\PhpExtractor` class instead. * The `Symfony\Bundle\FrameworkBundle\Translation\PhpStringTokenParser` class has been deprecated and will be removed in 4.0. Use the `Symfony\Component\Translation\Extractor\PhpStringTokenParser` class instead. HttpFoundation -------------- * The `Request::setTrustedProxies()` method takes a new `$trustedHeaderSet` argument. See http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html for more info. * The `Request::setTrustedHeaderName()` and `Request::getTrustedHeaderName()` methods have been removed. * Extending the following methods of `Response` is no longer possible (these methods are now `final`): - `setDate`/`getDate` - `setExpires`/`getExpires` - `setLastModified`/`getLastModified` - `setProtocolVersion`/`getProtocolVersion` - `setStatusCode`/`getStatusCode` - `setCharset`/`getCharset` - `setPrivate`/`setPublic` - `getAge` - `getMaxAge`/`setMaxAge` - `setSharedMaxAge` - `getTtl`/`setTtl` - `setClientTtl` - `getEtag`/`setEtag` - `hasVary`/`getVary`/`setVary` - `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError` - `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty` * The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is not supported anymore, use `Request::isMethodCacheable()` instead. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler` class has been removed. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler` and `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` classes have been removed. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` does not work with the legacy mongo extension anymore. It requires mongodb/mongodb package and ext-mongodb. * The `Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler` class has been removed. Use `Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler` instead. HttpKernel ---------- * Bundle inheritance has been removed. * Relying on convention-based commands discovery is not supported anymore. Use PSR-4 based service discovery instead. Before: ```yml # app/config/services.yml services: # ... # implicit registration of all commands in the `Command` folder ``` After: ```yml # app/config/services.yml services: # ... # explicit commands registration AppBundle\Command\: resource: '../../src/AppBundle/Command/*' tags: ['console.command'] ``` * The `Extension::addClassesToCompile()` and `Extension::getClassesToCompile()` methods have been removed. * Possibility to pass non-scalar values as URI attributes to the ESI and SSI renderers has been removed. The inline fragment renderer should be used with non-scalar attributes. * The `ControllerResolver::getArguments()` method has been removed. If you have your own `ControllerResolverInterface` implementation, you should inject an `ArgumentResolverInterface` instance. * The `DataCollector::varToString()` method has been removed in favor of `cloneVar()`. * The `Psr6CacheClearer::addPool()` method has been removed. Pass an array of pools indexed by name to the constructor instead. * The `LazyLoadingFragmentHandler::addRendererService()` method has been removed. * The `X-Status-Code` header method of setting a custom status code in the response when handling exceptions has been removed. There is now a new `GetResponseForExceptionEvent::allowCustomResponseCode()` method instead, which will tell the Kernel to use the response code set on the event's response object. * The `Kernel::getEnvParameters()` method has been removed. * The `SYMFONY__` environment variables are no longer processed automatically by Symfony. Use the `%env()%` syntax to get the value of any environment variable from configuration files instead. * The `getCacheDir()` method of your kernel should not be called while building the container. Use the `%kernel.cache_dir%` parameter instead. Not doing so may break the `cache:clear` command. * The `Symfony\Component\HttpKernel\Config\EnvParametersResource` class has been removed. * The `reset()` method has been added to `Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface`. * The `clear()` method has been added to `Symfony\Component\HttpKernel\Log\DebugLoggerInterface`. * The `ChainCacheClearer::add()` method has been removed, inject the list of clearers as a constructor argument instead. * The `CacheWarmerAggregate::add()` and `setWarmers()` methods have been removed, inject the list of clearers as a constructor argument instead. * The `CacheWarmerAggregate` and `ChainCacheClearer` classes have been made final. Ldap ---- * The `RenameEntryInterface` has been removed, and merged with `EntryManagerInterface` Process ------- * Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not supported anymore. * The `Symfony\Component\Process\ProcessBuilder` class has been removed, use the `Symfony\Component\Process\Process` class directly instead. * The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead. * Environment variables are always inherited in sub-processes. * Configuring `proc_open()` options has been removed. * Configuring Windows and sigchild compatibility is not possible anymore - they are always enabled. * Extending `Process::run()`, `Process::mustRun()` and `Process::restart()` is not supported anymore. * The `getEnhanceWindowsCompatibility()` and `setEnhanceWindowsCompatibility()` methods of the `Process` class have been removed. Profiler -------- * The `profiler.matcher` option has been removed. ProxyManager ------------ * The `ProxyDumper` class has been made final Security -------- * The `RoleInterface` has been removed. Extend the `Symfony\Component\Security\Core\Role\Role` class instead. * The `LogoutUrlGenerator::registerListener()` method expects a 6th `string $context = null` argument. * The `AccessDecisionManager::setVoters()` method has been removed. Pass the voters to the constructor instead. * Support for defining voters that don't implement the `VoterInterface` has been removed. * Calling `ContextListener::setLogoutOnUserChange(false)` won't have any effect anymore. * Removed the HTTP digest authentication system. The `NonceExpiredException`, `DigestAuthenticationListener` and `DigestAuthenticationEntryPoint` classes have been removed. Use another authentication system like `http_basic` instead. * The `GuardAuthenticatorInterface` interface has been removed. Use `AuthenticatorInterface` instead. SecurityBundle -------------- * The `FirewallContext::getContext()` method has been removed, use the `getListeners()` and/or `getExceptionListener()` method instead. * The `FirewallMap::$map` and `$container` properties have been removed. * The `UserPasswordEncoderCommand` class does not allow `null` as the first argument anymore. * `UserPasswordEncoderCommand` does not extend `ContainerAwareCommand` nor implement `ContainerAwareInterface` anymore. * `InitAclCommand` has been removed. Use `Symfony\Bundle\AclBundle\Command\InitAclCommand` instead * `SetAclCommand` has been removed. Use `Symfony\Bundle\AclBundle\Command\SetAclCommand` instead * The firewall option `logout_on_user_change` is now always true, which will trigger a logout if the user changes between requests. * Removed the HTTP digest authentication system. The `HttpDigestFactory` class has been removed. Use another authentication system like `http_basic` instead. * The `switch_user.stateless` option is now always true if the firewall is stateless. * Not configuring explicitly the provider on a firewall is ambiguous when there is more than one registered provider. The first configured provider is not used anymore and an exception is thrown instead. Explicitly configure the provider to use on your firewalls. Serializer ---------- * The ability to pass a Doctrine `Cache` instance to the `ClassMetadataFactory` class has been removed. You should use the `CacheClassMetadataFactory` class instead. * Not defining the 6th argument `$format = null` of the `AbstractNormalizer::instantiateObject()` method when overriding it is not supported anymore. * Extending `ChainDecoder`, `ChainEncoder`, `ArrayDenormalizer` is not supported anymore. Translation ----------- * Removed the backup feature from the file dumper classes. * The default value of the `$readerServiceId` argument of `TranslatorPass::__construct()` has been changed to `"translation.reader"`. * Removed `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations`, use `Symfony\Component\Translation\Writer\TranslationWriter::write` instead. * Removed support for passing `Symfony\Component\Translation\MessageSelector` as a second argument to the `Translator::__construct()`. You should pass an instance of `Symfony\Component\Translation\Formatter\MessageFormatterInterface` instead. TwigBundle ---------- * The `ContainerAwareRuntimeLoader` class has been removed. Use the Twig `Twig_ContainerRuntimeLoader` class instead. * Removed `DebugCommand` in favor of `Symfony\Bridge\Twig\Command\DebugCommand`. * Removed `ContainerAwareInterface` implementation in `Symfony\Bundle\TwigBundle\Command\LintCommand`. TwigBridge ---------- * removed the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer` class from the Form component instead * Removed the possibility to inject the Form `TwigRenderer` into the `FormExtension`. Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead. Before: ```php use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRenderer; use Symfony\Bridge\Twig\Form\TwigRendererEngine; // ... $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig')); $rendererEngine->setEnvironment($twig); $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager))); ``` After: ```php $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig); $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array( TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) { return new TwigRenderer($rendererEngine, $csrfTokenManager); }, ))); $twig->addExtension(new FormExtension()); ``` * Removed the `TwigRendererEngineInterface` interface. * The `TwigRendererEngine::setEnvironment()` method has been removed. Pass the Twig Environment as second argument of the constructor instead. * Removed `DebugCommand::set/getTwigEnvironment`. Pass an instance of `Twig\Environment` as first argument of the constructor instead. * Removed `LintCommand::set/getTwigEnvironment`. Pass an instance of `Twig\Environment` as first argument of the constructor instead. Validator --------- * The default value of the `strict` option of the `Choice` constraint was changed to `true`. Using any other value will throw an exception. * The `DateTimeValidator::PATTERN` constant was removed. * `Tests\Constraints\AbstractConstraintValidatorTest` has been removed in favor of `Test\ConstraintValidatorTestCase`. Before: ```php // ... use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; class MyCustomValidatorTest extends AbstractConstraintValidatorTest { // ... } ``` After: ```php // ... use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class MyCustomValidatorTest extends ConstraintValidatorTestCase { // ... } ``` * Setting the `checkDNS` option of the `Url` constraint to `true` is dropped in favor of `Url::CHECK_DNS_TYPE_*` constants values. Before: ```php $constraint = new Url(['checkDNS' => true]); ``` After: ```php $constraint = new Url(['checkDNS' => Url::CHECK_DNS_TYPE_ANY]); ``` VarDumper --------- * The `VarDumperTestTrait::assertDumpEquals()` method expects a 3rd `$context = null` argument and moves `$message = ''` argument at 4th position. Before: ```php VarDumperTestTrait::assertDumpEquals($dump, $data, $message = ''); ``` After: ```php VarDumperTestTrait::assertDumpEquals($dump, $data, $filter = 0, $message = ''); ``` * The `VarDumperTestTrait::assertDumpMatchesFormat()` method expects a 3rd `$context = null` argument and moves `$message = ''` argument at 4th position. Before: ```php VarDumperTestTrait::assertDumpMatchesFormat($dump, $data, $message = ''); ``` After: ```php VarDumperTestTrait::assertDumpMatchesFormat($dump, $data, $filter = 0, $message = ''); ``` WebProfilerBundle ----------------- * Removed the `getTemplates()` method of the `TemplateManager` class in favor of the `getNames()` method Workflow -------- * Removed class name support in `WorkflowRegistry::add()` as second parameter. Yaml ---- * Support for the `!str` tag was removed, use the `!!str` tag instead. * Starting an unquoted string with a question mark followed by a space throws a `ParseException`. * Removed support for implicitly parsing non-string mapping keys as strings. Mapping keys that are no strings will result in a `ParseException`. Use quotes to opt-in for keys to be parsed as strings. Before: ```php $yaml = << new A(), 'bar' => 1), 0, 0, true); ``` After: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); ``` * Removed support for passing `true`/`false` as the fifth argument to the `dump()` method to toggle object support. Before: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); ``` After: ```php Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, Yaml::DUMP_OBJECT); ``` * The `!!php/object` tag to indicate dumped PHP objects was removed in favor of the `!php/object` tag. * Duplicate mapping keys lead to a `ParseException`. * The constructor arguments `$offset`, `$totalNumberOfLines` and `$skippedLineNumbers` of the `Parser` class were removed. * The behavior of the non-specific tag `!` is changed and now forces non-evaluating your values. * The `!php/object:` tag was removed in favor of the `!php/object` tag (without the colon). * The `!php/const:` tag was removed in favor of the `!php/const` tag (without the colon). Before: ```yml !php/const:PHP_INT_MAX ``` After: ```yml !php/const PHP_INT_MAX ``` symfony-3.4.6/appveyor.yml000066400000000000000000000065541324732107100156320ustar00rootroot00000000000000build: false clone_depth: 1 clone_folder: c:\projects\symfony cache: - composer.phar - .phpunit -> phpunit init: - SET PATH=c:\php;%PATH% - SET COMPOSER_NO_INTERACTION=1 - SET SYMFONY_DEPRECATIONS_HELPER=strict - SET ANSICON=121x90 (121x90) - SET SYMFONY_PHPUNIT_VERSION=4.8 - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f install: - mkdir c:\php && cd c:\php - appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/cacert.pem - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-5.5.9-nts-Win32-VC11-x86.zip - 7z x php-5.5.9-nts-Win32-VC11-x86.zip -y >nul - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.1.3-Win32-VC14-x86.zip - cd ext - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-4.0.10-5.5-nts-vc11-x86.zip - 7z x php_apcu-4.0.10-5.5-nts-vc11-x86.zip -y >nul - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_memcache-3.0.8-5.5-nts-vc11-x86.zip - 7z x php_memcache-3.0.8-5.5-nts-vc11-x86.zip -y >nul - cd .. - copy /Y php.ini-development php.ini-min - echo memory_limit=-1 >> php.ini-min - echo serialize_precision=14 >> php.ini-min - echo max_execution_time=1200 >> php.ini-min - echo date.timezone="America/Los_Angeles" >> php.ini-min - echo extension_dir=ext >> php.ini-min - copy /Y php.ini-min php.ini-max - echo zend_extension=php_opcache.dll >> php.ini-max - echo opcache.enable_cli=1 >> php.ini-max - echo extension=php_openssl.dll >> php.ini-max - echo extension=php_apcu.dll >> php.ini-max - echo apc.enable_cli=1 >> php.ini-max - echo extension=php_memcache.dll >> php.ini-max - echo extension=php_intl.dll >> php.ini-max - echo extension=php_mbstring.dll >> php.ini-max - echo extension=php_fileinfo.dll >> php.ini-max - echo extension=php_pdo_sqlite.dll >> php.ini-max - echo extension=php_curl.dll >> php.ini-max - echo curl.cainfo=c:\php\cacert.pem >> php.ini-max - copy /Y php.ini-max php.ini - cd c:\projects\symfony - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar) - php composer.phar self-update - copy /Y .composer\* %APPDATA%\Composer\ - php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - php -dmemory_limit=-1 composer.phar update --no-progress --no-suggest --ansi - php phpunit install test_script: - SET X=0 - cd c:\php && 7z x php-7.1.3-Win32-VC14-x86.zip -y >nul && copy /Y php.ini-min php.ini - cd c:\projects\symfony - php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! - cd c:\php && 7z x php-5.5.9-nts-Win32-VC11-x86.zip -y >nul && copy /Y php.ini-min php.ini - cd c:\projects\symfony - SET SYMFONY_PHPUNIT_SKIPPED_TESTS=phpunit.skipped - php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! - copy /Y c:\php\php.ini-max c:\php\php.ini - php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! - exit %X% symfony-3.4.6/composer.json000066400000000000000000000122741324732107100157600ustar00rootroot00000000000000{ "name": "symfony/symfony", "type": "library", "description": "The Symfony PHP framework", "keywords": ["framework"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "ext-xml": "*", "doctrine/common": "~2.4", "fig/link-util": "^1.0", "twig/twig": "^1.35|^2.4.4", "psr/cache": "~1.0", "psr/container": "^1.0", "psr/link": "^1.0", "psr/log": "~1.0", "psr/simple-cache": "^1.0", "symfony/polyfill-apcu": "~1.1", "symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php56": "~1.0", "symfony/polyfill-php70": "~1.6" }, "replace": { "symfony/asset": "self.version", "symfony/browser-kit": "self.version", "symfony/cache": "self.version", "symfony/class-loader": "self.version", "symfony/config": "self.version", "symfony/console": "self.version", "symfony/css-selector": "self.version", "symfony/dependency-injection": "self.version", "symfony/debug": "self.version", "symfony/debug-bundle": "self.version", "symfony/doctrine-bridge": "self.version", "symfony/dom-crawler": "self.version", "symfony/dotenv": "self.version", "symfony/event-dispatcher": "self.version", "symfony/expression-language": "self.version", "symfony/filesystem": "self.version", "symfony/finder": "self.version", "symfony/form": "self.version", "symfony/framework-bundle": "self.version", "symfony/http-foundation": "self.version", "symfony/http-kernel": "self.version", "symfony/inflector": "self.version", "symfony/intl": "self.version", "symfony/ldap": "self.version", "symfony/lock": "self.version", "symfony/monolog-bridge": "self.version", "symfony/options-resolver": "self.version", "symfony/process": "self.version", "symfony/property-access": "self.version", "symfony/property-info": "self.version", "symfony/proxy-manager-bridge": "self.version", "symfony/routing": "self.version", "symfony/security": "self.version", "symfony/security-core": "self.version", "symfony/security-csrf": "self.version", "symfony/security-guard": "self.version", "symfony/security-http": "self.version", "symfony/security-bundle": "self.version", "symfony/serializer": "self.version", "symfony/stopwatch": "self.version", "symfony/templating": "self.version", "symfony/translation": "self.version", "symfony/twig-bridge": "self.version", "symfony/twig-bundle": "self.version", "symfony/validator": "self.version", "symfony/var-dumper": "self.version", "symfony/web-link": "self.version", "symfony/web-profiler-bundle": "self.version", "symfony/web-server-bundle": "self.version", "symfony/workflow": "self.version", "symfony/yaml": "self.version" }, "require-dev": { "cache/integration-tests": "dev-master", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.6", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.4", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/doctrine-bundle": "~1.4", "monolog/monolog": "~1.11", "ocramius/proxy-manager": "~0.4|~1.0|~2.0", "predis/predis": "~1.0", "egulias/email-validator": "~1.2,>=1.2.8|~2.0", "symfony/phpunit-bridge": "~3.4|~4.0", "symfony/security-acl": "~2.8|~3.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2", "phpdocumentor/type-resolver": "<0.2.1", "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" }, "provide": { "psr/cache-implementation": "1.0", "psr/container-implementation": "1.0", "psr/log-implementation": "1.0", "psr/simple-cache-implementation": "1.0" }, "autoload": { "psr-4": { "Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/", "Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/", "Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/", "Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/", "Symfony\\Bundle\\": "src/Symfony/Bundle/", "Symfony\\Component\\": "src/Symfony/Component/" }, "classmap": [ "src/Symfony/Component/Intl/Resources/stubs" ], "exclude-from-classmap": [ "**/Tests/" ] }, "autoload-dev": { "files": [ "src/Symfony/Component/VarDumper/Resources/functions/dump.php" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/link000077500000000000000000000046131324732107100141170ustar00rootroot00000000000000#!/usr/bin/env php * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require __DIR__.'/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php'; require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php'; require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOException.php'; require __DIR__.'/src/Symfony/Component/Filesystem/Filesystem.php'; use Symfony\Component\Filesystem\Filesystem; /** * Links dependencies to components to a local clone of the main symfony/symfony GitHub repository. * * @author Kévin Dunglas */ if (2 !== $argc) { echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL; echo "Usage: $argv[0] /path/to/the/project".PHP_EOL; exit(1); } if (!is_dir("$argv[1]/vendor/symfony")) { echo "The directory \"$argv[1]\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL; exit(1); } $sfPackages = array('symfony/symfony' => __DIR__); $filesystem = new Filesystem(); $braces = array('Bundle', 'Bridge', 'Component', 'Component/Security'); $directories = call_user_func_array('array_merge', array_values(array_map(function ($part) { return glob(__DIR__.'/src/Symfony/'.$part.'/*', GLOB_ONLYDIR | GLOB_NOSORT); }, $braces))); foreach ($directories as $dir) { if ($filesystem->exists($composer = "$dir/composer.json")) { $sfPackages[json_decode(file_get_contents($composer))->name] = $dir; } } foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { $package = 'symfony/'.basename($dir); if (is_link($dir)) { echo "\"$package\" is already a symlink, skipping.".PHP_EOL; continue; } if (!isset($sfPackages[$package])) { continue; } $sfDir = '\\' === DIRECTORY_SEPARATOR ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir))); $filesystem->remove($dir); $filesystem->symlink($sfDir, $dir); echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL; } foreach (glob("$argv[1]/var/cache/*") as $cacheDir) { $filesystem->remove($cacheDir); } symfony-3.4.6/phpunit000077500000000000000000000011531324732107100146450ustar00rootroot00000000000000#!/usr/bin/env php = 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) { putenv('SYMFONY_PHPUNIT_VERSION=6.0'); } putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit'); require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit'; symfony-3.4.6/phpunit.xml.dist000066400000000000000000000062651324732107100164140ustar00rootroot00000000000000 ./src/Symfony/Bridge/*/Tests/ ./src/Symfony/Component/*/Tests/ ./src/Symfony/Component/*/*/Tests/ ./src/Symfony/Bundle/*/Tests/ benchmark intl-data ./src/Symfony/ ./src/Symfony/Bridge/*/Tests ./src/Symfony/Component/*/Tests ./src/Symfony/Component/*/*/Tests ./src/Symfony/Bundle/*/Tests ./src/Symfony/Bundle/*/Resources ./src/Symfony/Component/*/Resources ./src/Symfony/Component/*/*/Resources ./src/Symfony/Bridge/*/vendor ./src/Symfony/Bundle/*/vendor ./src/Symfony/Component/*/vendor ./src/Symfony/Component/*/*/vendor Cache\IntegrationTests Doctrine\Common\Cache Symfony\Component\Cache Symfony\Component\Cache\Traits Symfony\Component\Console Symfony\Component\HttpFoundation symfony-3.4.6/src/000077500000000000000000000000001324732107100140175ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/000077500000000000000000000000001324732107100154635ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/000077500000000000000000000000001324732107100166575ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/000077500000000000000000000000001324732107100204265ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/.gitignore000066400000000000000000000000421324732107100224120ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Bridge/Doctrine/CHANGELOG.md000066400000000000000000000042331324732107100222410ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added support for doctrine/dbal v2.6 types * added cause of UniqueEntity constraint violation * deprecated `DbalSessionHandler` and `DbalSessionHandlerSchema` in favor of `Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` 3.1.0 ----- * added "{{ value }}" message placeholder to UniqueEntityValidator * deprecated `MergeDoctrineCollectionListener::onBind` in favor of `MergeDoctrineCollectionListener::onSubmit` * deprecated passing `ChoiceListFactoryInterface` as first argument of `DoctrineChoiceLoader`'s constructor 3.0.0 ----- * removed `EntityChoiceList` * removed `$manager` (2nd) and `$class` (3th) arguments of `ORMQueryBuilderLoader` * removed passing a query builder closure to `ORMQueryBuilderLoader` * removed `loader` and `property` options of the `DoctrineType` 2.8.0 ----- * deprecated using the entity provider with a Doctrine repository implementing UserProviderInterface * added UserLoaderInterface for loading users through Doctrine. 2.7.0 ----- * added DoctrineChoiceLoader * deprecated EntityChoiceList * deprecated passing a query builder closure to ORMQueryBuilderLoader * deprecated $manager and $em arguments of ORMQueryBuilderLoader * added optional arguments $propertyAccessor and $choiceListFactory to DoctrineOrmExtension constructor * deprecated "loader" and "property" options of DoctrineType 2.4.0 ----- * deprecated DoctrineOrmTestCase class 2.2.0 ----- * added an optional PropertyAccessorInterface parameter to DoctrineType, EntityType and EntityChoiceList 2.1.0 ----- * added a default implementation of the ManagerRegistry * added a session storage for Doctrine DBAL * DoctrineOrmTypeGuesser now guesses "collection" for array Doctrine type * DoctrineType now caches its choice lists in order to improve performance * DoctrineType now uses ManagerRegistry::getManagerForClass() if the option "em" is not set * UniqueEntity validation constraint now accepts a "repositoryMethod" option that will be used to check for uniqueness instead of the default "findBy" * [BC BREAK] the DbalLogger::log() visibility has been changed from public to protected symfony-3.4.6/src/Symfony/Bridge/Doctrine/CacheWarmer/000077500000000000000000000000001324732107100226075ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php000066400000000000000000000042141324732107100265440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\CacheWarmer; use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; /** * The proxy generator cache warmer generates all entity proxies. * * In the process of generating proxies the cache for all the metadata is primed also, * since this information is necessary to build the proxies in the first place. * * @author Benjamin Eberlei */ class ProxyCacheWarmer implements CacheWarmerInterface { private $registry; public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } /** * This cache warmer is not optional, without proxies fatal error occurs! * * @return false */ public function isOptional() { return false; } /** * {@inheritdoc} */ public function warmUp($cacheDir) { foreach ($this->registry->getManagers() as $em) { // we need the directory no matter the proxy cache generation strategy if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) { if (false === @mkdir($proxyCacheDir, 0777, true)) { throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir)); } } elseif (!is_writable($proxyCacheDir)) { throw new \RuntimeException(sprintf('The Doctrine Proxy directory "%s" is not writeable for the current system user.', $proxyCacheDir)); } // if proxies are autogenerated we don't need to generate them in the cache warmer if ($em->getConfiguration()->getAutoGenerateProxyClasses()) { continue; } $classes = $em->getMetadataFactory()->getAllMetadata(); $em->getProxyFactory()->generateProxyClasses($classes); } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php000066400000000000000000000104211324732107100263340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine; use Doctrine\Common\EventArgs; use Doctrine\Common\EventManager; use Psr\Container\ContainerInterface; /** * Allows lazy loading of listener services. * * @author Johannes M. Schmitt */ class ContainerAwareEventManager extends EventManager { /** * Map of registered listeners. * * => */ private $listeners = array(); private $initialized = array(); private $container; public function __construct(ContainerInterface $container) { $this->container = $container; } /** * Dispatches an event to all registered listeners. * * @param string $eventName The name of the event to dispatch. The name of the event is * the name of the method that is invoked on listeners. * @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners. * If not supplied, the single empty EventArgs instance is used. * * @return bool */ public function dispatchEvent($eventName, EventArgs $eventArgs = null) { if (isset($this->listeners[$eventName])) { $eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs; $initialized = isset($this->initialized[$eventName]); foreach ($this->listeners[$eventName] as $hash => $listener) { if (!$initialized && is_string($listener)) { $this->listeners[$eventName][$hash] = $listener = $this->container->get($listener); } $listener->$eventName($eventArgs); } $this->initialized[$eventName] = true; } } /** * Gets the listeners of a specific event or all listeners. * * @param string $event The name of the event * * @return array The event listeners for the specified event, or all event listeners */ public function getListeners($event = null) { return $event ? $this->listeners[$event] : $this->listeners; } /** * Checks whether an event has any registered listeners. * * @param string $event * * @return bool TRUE if the specified event has any listeners, FALSE otherwise */ public function hasListeners($event) { return isset($this->listeners[$event]) && $this->listeners[$event]; } /** * Adds an event listener that listens on the specified events. * * @param string|array $events The event(s) to listen on * @param object|string $listener The listener object * * @throws \RuntimeException */ public function addEventListener($events, $listener) { if (is_string($listener)) { if ($this->initialized) { throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.'); } $hash = '_service_'.$listener; } else { // Picks the hash code related to that listener $hash = spl_object_hash($listener); } foreach ((array) $events as $event) { // Overrides listener if a previous one was associated already // Prevents duplicate listeners on same event (same instance only) $this->listeners[$event][$hash] = $listener; } } /** * Removes an event listener from the specified events. * * @param string|array $events * @param object|string $listener */ public function removeEventListener($events, $listener) { if (is_string($listener)) { $hash = '_service_'.$listener; } else { // Picks the hash code related to that listener $hash = spl_object_hash($listener); } foreach ((array) $events as $event) { // Check if actually have this listener associated if (isset($this->listeners[$event][$hash])) { unset($this->listeners[$event][$hash]); } } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DataCollector/000077500000000000000000000000001324732107100231465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php000066400000000000000000000122121324732107100300650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DataCollector; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Types\Type; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * DoctrineDataCollector. * * @author Fabien Potencier */ class DoctrineDataCollector extends DataCollector { private $registry; private $connections; private $managers; /** * @var DebugStack[] */ private $loggers = array(); public function __construct(ManagerRegistry $registry) { $this->registry = $registry; $this->connections = $registry->getConnectionNames(); $this->managers = $registry->getManagerNames(); } /** * Adds the stack logger for a connection. * * @param string $name * @param DebugStack $logger */ public function addLogger($name, DebugStack $logger) { $this->loggers[$name] = $logger; } /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { $queries = array(); foreach ($this->loggers as $name => $logger) { $queries[$name] = $this->sanitizeQueries($name, $logger->queries); } $this->data = array( 'queries' => $queries, 'connections' => $this->connections, 'managers' => $this->managers, ); } public function reset() { $this->data = array(); foreach ($this->loggers as $logger) { $logger->queries = array(); $logger->currentQuery = 0; } } public function getManagers() { return $this->data['managers']; } public function getConnections() { return $this->data['connections']; } public function getQueryCount() { return array_sum(array_map('count', $this->data['queries'])); } public function getQueries() { return $this->data['queries']; } public function getTime() { $time = 0; foreach ($this->data['queries'] as $queries) { foreach ($queries as $query) { $time += $query['executionMS']; } } return $time; } /** * {@inheritdoc} */ public function getName() { return 'db'; } private function sanitizeQueries($connectionName, $queries) { foreach ($queries as $i => $query) { $queries[$i] = $this->sanitizeQuery($connectionName, $query); } return $queries; } private function sanitizeQuery($connectionName, $query) { $query['explainable'] = true; if (null === $query['params']) { $query['params'] = array(); } if (!is_array($query['params'])) { $query['params'] = array($query['params']); } foreach ($query['params'] as $j => $param) { if (isset($query['types'][$j])) { // Transform the param according to the type $type = $query['types'][$j]; if (is_string($type)) { $type = Type::getType($type); } if ($type instanceof Type) { $query['types'][$j] = $type->getBindingType(); $param = $type->convertToDatabaseValue($param, $this->registry->getConnection($connectionName)->getDatabasePlatform()); } } list($query['params'][$j], $explainable) = $this->sanitizeParam($param); if (!$explainable) { $query['explainable'] = false; } } return $query; } /** * Sanitizes a param. * * The return value is an array with the sanitized value and a boolean * indicating if the original value was kept (allowing to use the sanitized * value to explain the query). * * @param mixed $var * * @return array */ private function sanitizeParam($var) { if (is_object($var)) { $className = get_class($var); return method_exists($var, '__toString') ? array(sprintf('Object(%s): "%s"', $className, $var->__toString()), false) : array(sprintf('Object(%s)', $className), false); } if (is_array($var)) { $a = array(); $original = true; foreach ($var as $k => $v) { list($value, $orig) = $this->sanitizeParam($v); $original = $original && $orig; $a[$k] = $value; } return array($a, $original); } if (is_resource($var)) { return array(sprintf('Resource(%s)', get_resource_type($var)), false); } return array($var, true); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DataFixtures/000077500000000000000000000000001324732107100230315ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php000066400000000000000000000023151324732107100275740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DataFixtures; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\DataFixtures\Loader; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Doctrine data fixtures loader that injects the service container into * fixture objects that implement ContainerAwareInterface. * * Note: Use of this class requires the Doctrine data fixtures extension, which * is a suggested dependency for Symfony. */ class ContainerAwareLoader extends Loader { private $container; public function __construct(ContainerInterface $container) { $this->container = $container; } /** * {@inheritdoc} */ public function addFixture(FixtureInterface $fixture) { if ($fixture instanceof ContainerAwareInterface) { $fixture->setContainer($this->container); } parent::addFixture($fixture); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/000077500000000000000000000000001324732107100243475ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php000066400000000000000000000525211324732107100322150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DependencyInjection; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** * This abstract classes groups common code that Doctrine Object Manager extensions (ORM, MongoDB, CouchDB) need. * * @author Benjamin Eberlei */ abstract class AbstractDoctrineExtension extends Extension { /** * Used inside metadata driver method to simplify aggregation of data. */ protected $aliasMap = array(); /** * Used inside metadata driver method to simplify aggregation of data. */ protected $drivers = array(); /** * @param array $objectManager A configured object manager * @param ContainerBuilder $container A ContainerBuilder instance * * @throws \InvalidArgumentException */ protected function loadMappingInformation(array $objectManager, ContainerBuilder $container) { if ($objectManager['auto_mapping']) { // automatically register bundle mappings foreach (array_keys($container->getParameter('kernel.bundles')) as $bundle) { if (!isset($objectManager['mappings'][$bundle])) { $objectManager['mappings'][$bundle] = array( 'mapping' => true, 'is_bundle' => true, ); } } } foreach ($objectManager['mappings'] as $mappingName => $mappingConfig) { if (null !== $mappingConfig && false === $mappingConfig['mapping']) { continue; } $mappingConfig = array_replace(array( 'dir' => false, 'type' => false, 'prefix' => false, ), (array) $mappingConfig); $mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']); // a bundle configuration is detected by realizing that the specified dir is not absolute and existing if (!isset($mappingConfig['is_bundle'])) { $mappingConfig['is_bundle'] = !is_dir($mappingConfig['dir']); } if ($mappingConfig['is_bundle']) { $bundle = null; foreach ($container->getParameter('kernel.bundles') as $name => $class) { if ($mappingName === $name) { $bundle = new \ReflectionClass($class); break; } } if (null === $bundle) { throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName)); } $mappingConfig = $this->getMappingDriverBundleConfigDefaults($mappingConfig, $bundle, $container); if (!$mappingConfig) { continue; } } $this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']); $this->setMappingDriverConfig($mappingConfig, $mappingName); $this->setMappingDriverAlias($mappingConfig, $mappingName); } } /** * Register the alias for this mapping driver. * * Aliases can be used in the Query languages of all the Doctrine object managers to simplify writing tasks. * * @param array $mappingConfig * @param string $mappingName */ protected function setMappingDriverAlias($mappingConfig, $mappingName) { if (isset($mappingConfig['alias'])) { $this->aliasMap[$mappingConfig['alias']] = $mappingConfig['prefix']; } else { $this->aliasMap[$mappingName] = $mappingConfig['prefix']; } } /** * Register the mapping driver configuration for later use with the object managers metadata driver chain. * * @param array $mappingConfig * @param string $mappingName * * @throws \InvalidArgumentException */ protected function setMappingDriverConfig(array $mappingConfig, $mappingName) { $mappingDirectory = $mappingConfig['dir']; if (!is_dir($mappingDirectory)) { throw new \InvalidArgumentException(sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName)); } $this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingDirectory) ?: $mappingDirectory; } /** * If this is a bundle controlled mapping all the missing information can be autodetected by this method. * * Returns false when autodetection failed, an array of the completed information otherwise. * * @return array|false */ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container) { $bundleDir = dirname($bundle->getFileName()); if (!$bundleConfig['type']) { $bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container); } if (!$bundleConfig['type']) { // skip this bundle, no mapping information was found. return false; } if (!$bundleConfig['dir']) { if (in_array($bundleConfig['type'], array('annotation', 'staticphp'))) { $bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName(); } else { $bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory(); } } else { $bundleConfig['dir'] = $bundleDir.'/'.$bundleConfig['dir']; } if (!$bundleConfig['prefix']) { $bundleConfig['prefix'] = $bundle->getNamespaceName().'\\'.$this->getMappingObjectDefaultName(); } return $bundleConfig; } /** * Register all the collected mapping information with the object manager by registering the appropriate mapping drivers. * * @param array $objectManager * @param ContainerBuilder $container A ContainerBuilder instance */ protected function registerMappingDrivers($objectManager, ContainerBuilder $container) { // configure metadata driver for each bundle based on the type of mapping files found if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) { $chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver')); } else { $chainDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.driver_chain.class%')); $chainDriverDef->setPublic(false); } foreach ($this->drivers as $driverType => $driverPaths) { $mappingService = $this->getObjectManagerElementName($objectManager['name'].'_'.$driverType.'_metadata_driver'); if ($container->hasDefinition($mappingService)) { $mappingDriverDef = $container->getDefinition($mappingService); $args = $mappingDriverDef->getArguments(); if ('annotation' == $driverType) { $args[1] = array_merge(array_values($driverPaths), $args[1]); } else { $args[0] = array_merge(array_values($driverPaths), $args[0]); } $mappingDriverDef->setArguments($args); } elseif ('annotation' == $driverType) { $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( new Reference($this->getObjectManagerElementName('metadata.annotation_reader')), array_values($driverPaths), )); } else { $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( array_values($driverPaths), )); } $mappingDriverDef->setPublic(false); if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) { $mappingDriverDef->setArguments(array(array_flip($driverPaths))); $mappingDriverDef->addMethodCall('setGlobalBasename', array('mapping')); } $container->setDefinition($mappingService, $mappingDriverDef); foreach ($driverPaths as $prefix => $driverPath) { $chainDriverDef->addMethodCall('addDriver', array(new Reference($mappingService), $prefix)); } } $container->setDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'), $chainDriverDef); } /** * Assertion if the specified mapping information is valid. * * @param array $mappingConfig * @param string $objectManagerName * * @throws \InvalidArgumentException */ protected function assertValidMappingConfiguration(array $mappingConfig, $objectManagerName) { if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) { throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName)); } if (!is_dir($mappingConfig['dir'])) { throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir'])); } if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) { throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '. '"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '. 'You can register them by adding a new driver to the '. '"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver') )); } } /** * Detects what metadata driver to use for the supplied directory. * * @param string $dir A directory path * @param ContainerBuilder $container A ContainerBuilder instance * * @return string|null A metadata driver short name, if one can be detected */ protected function detectMetadataDriver($dir, ContainerBuilder $container) { $configPath = $this->getMappingResourceConfigDirectory(); $extension = $this->getMappingResourceExtension(); if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) { $driver = 'xml'; } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) { $driver = 'yml'; } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) { $driver = 'php'; } else { // add the closest existing directory as a resource $resource = $dir.'/'.$configPath; while (!is_dir($resource)) { $resource = dirname($resource); } $container->fileExists($resource, false); return $container->fileExists($dir.'/'.$this->getMappingObjectDefaultName(), false) ? 'annotation' : null; } $container->fileExists($dir.'/'.$configPath, false); return $driver; } /** * Loads a configured object manager metadata, query or result cache driver. * * @param array $objectManager A configured object manager * @param ContainerBuilder $container A ContainerBuilder instance * @param string $cacheName * * @throws \InvalidArgumentException in case of unknown driver type */ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, $cacheName) { $this->loadCacheDriver($cacheName, $objectManager['name'], $objectManager[$cacheName.'_driver'], $container); } /** * Loads a cache driver. * * @param string $cacheName The cache driver name * @param string $objectManagerName The object manager name * @param array $cacheDriver The cache driver mapping * @param ContainerBuilder $container The ContainerBuilder instance * * @return string * * @throws \InvalidArgumentException */ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheDriver, ContainerBuilder $container) { $cacheDriverServiceId = $this->getObjectManagerElementName($objectManagerName.'_'.$cacheName); switch ($cacheDriver['type']) { case 'service': $container->setAlias($cacheDriverServiceId, new Alias($cacheDriver['id'], false)); return $cacheDriverServiceId; case 'memcache': $memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%'; $memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%'; $memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%'; $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && 0 === $cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; $cacheDef = new Definition($memcacheClass); $memcacheInstance = new Definition($memcacheInstanceClass); $memcacheInstance->setPrivate(true); $memcacheInstance->addMethodCall('connect', array( $memcacheHost, $memcachePort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)), $memcacheInstance); $cacheDef->addMethodCall('setMemcache', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName))))); break; case 'memcached': $memcachedClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcached.class').'%'; $memcachedInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcached_instance.class').'%'; $memcachedHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcached_host').'%'; $memcachedPort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcached_port').'%'; $cacheDef = new Definition($memcachedClass); $memcachedInstance = new Definition($memcachedInstanceClass); $memcachedInstance->setPrivate(true); $memcachedInstance->addMethodCall('addServer', array( $memcachedHost, $memcachedPort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance); $cacheDef->addMethodCall('setMemcached', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName))))); break; case 'redis': $redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%'; $redisInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.redis_instance.class').'%'; $redisHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.redis_host').'%'; $redisPort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.redis_port').'%'; $cacheDef = new Definition($redisClass); $redisInstance = new Definition($redisInstanceClass); $redisInstance->setPrivate(true); $redisInstance->addMethodCall('connect', array( $redisHost, $redisPort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)), $redisInstance); $cacheDef->addMethodCall('setRedis', array(new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName))))); break; case 'apc': case 'apcu': case 'array': case 'xcache': case 'wincache': case 'zenddata': $cacheDef = new Definition('%'.$this->getObjectManagerElementName(sprintf('cache.%s.class', $cacheDriver['type'])).'%'); break; default: throw new \InvalidArgumentException(sprintf('"%s" is an unrecognized Doctrine cache driver.', $cacheDriver['type'])); } $cacheDef->setPublic(false); if (!isset($cacheDriver['namespace'])) { // generate a unique namespace for the given application if ($container->hasParameter('cache.prefix.seed')) { $seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed')); } else { $seed = '_'.$container->getParameter('kernel.root_dir'); } $seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug'); $namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed); $cacheDriver['namespace'] = $namespace; } $cacheDef->addMethodCall('setNamespace', array($cacheDriver['namespace'])); $container->setDefinition($cacheDriverServiceId, $cacheDef); return $cacheDriverServiceId; } /** * Returns a modified version of $managerConfigs. * * The manager called $autoMappedManager will map all bundles that are not mapped by other managers. * * @return array The modified version of $managerConfigs */ protected function fixManagersAutoMappings(array $managerConfigs, array $bundles) { if ($autoMappedManager = $this->validateAutoMapping($managerConfigs)) { foreach (array_keys($bundles) as $bundle) { foreach ($managerConfigs as $manager) { if (isset($manager['mappings'][$bundle])) { continue 2; } } $managerConfigs[$autoMappedManager]['mappings'][$bundle] = array( 'mapping' => true, 'is_bundle' => true, ); } $managerConfigs[$autoMappedManager]['auto_mapping'] = false; } return $managerConfigs; } /** * Prefixes the relative dependency injection container path with the object manager prefix. * * @example $name is 'entity_manager' then the result would be 'doctrine.orm.entity_manager' * * @param string $name * * @return string */ abstract protected function getObjectManagerElementName($name); /** * Noun that describes the mapped objects such as Entity or Document. * * Will be used for autodetection of persistent objects directory. * * @return string */ abstract protected function getMappingObjectDefaultName(); /** * Relative path from the bundle root to the directory where mapping files reside. * * @return string */ abstract protected function getMappingResourceConfigDirectory(); /** * Extension used by the mapping files. * * @return string */ abstract protected function getMappingResourceExtension(); /** * Search for a manager that is declared as 'auto_mapping' = true. * * @return null|string The name of the manager. If no one manager is found, returns null * * @throws \LogicException */ private function validateAutoMapping(array $managerConfigs) { $autoMappedManager = null; foreach ($managerConfigs as $name => $manager) { if (!$manager['auto_mapping']) { continue; } if (null !== $autoMappedManager) { throw new \LogicException(sprintf('You cannot enable "auto_mapping" on more than one manager at the same time (found in "%s" and %s").', $autoMappedManager, $name)); } $autoMappedManager = $name; } return $autoMappedManager; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/000077500000000000000000000000001324732107100267505ustar00rootroot00000000000000DoctrineValidationPass.php000066400000000000000000000042371324732107100340210ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Registers additional validators. * * @author Benjamin Eberlei */ class DoctrineValidationPass implements CompilerPassInterface { private $managerType; /** * @param string $managerType */ public function __construct($managerType) { $this->managerType = $managerType; } /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { $this->updateValidatorMappingFiles($container, 'xml', 'xml'); $this->updateValidatorMappingFiles($container, 'yaml', 'yml'); } /** * Gets the validation mapping files for the format and extends them with * files matching a doctrine search pattern (Resources/config/validation.orm.xml). * * @param ContainerBuilder $container * @param string $mapping * @param string $extension */ private function updateValidatorMappingFiles(ContainerBuilder $container, $mapping, $extension) { if (!$container->hasParameter('validator.mapping.loader.'.$mapping.'_files_loader.mapping_files')) { return; } $files = $container->getParameter('validator.mapping.loader.'.$mapping.'_files_loader.mapping_files'); $validationPath = 'Resources/config/validation.'.$this->managerType.'.'.$extension; foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); if ($container->fileExists($file = dirname($reflection->getFileName()).'/'.$validationPath)) { $files[] = $file; } } $container->setParameter('validator.mapping.loader.'.$mapping.'_files_loader.mapping_files', $files); } } RegisterEventListenersAndSubscribersPass.php000066400000000000000000000126651324732107100375540ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** * Registers event listeners and subscribers to the available doctrine connections. * * @author Jeremy Mikola * @author Alexander */ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface { private $connections; private $container; private $eventManagers; private $managerTemplate; private $tagPrefix; /** * @param string $connections Parameter ID for connections * @param string $managerTemplate sprintf() template for generating the event * manager's service ID for a connection name * @param string $tagPrefix Tag prefix for listeners and subscribers */ public function __construct($connections, $managerTemplate, $tagPrefix) { $this->connections = $connections; $this->managerTemplate = $managerTemplate; $this->tagPrefix = $tagPrefix; } /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasParameter($this->connections)) { return; } $taggedSubscribers = $container->findTaggedServiceIds($this->tagPrefix.'.event_subscriber', true); $taggedListeners = $container->findTaggedServiceIds($this->tagPrefix.'.event_listener', true); if (empty($taggedSubscribers) && empty($taggedListeners)) { return; } $this->container = $container; $this->connections = $container->getParameter($this->connections); $sortFunc = function ($a, $b) { $a = isset($a['priority']) ? $a['priority'] : 0; $b = isset($b['priority']) ? $b['priority'] : 0; return $a > $b ? -1 : 1; }; if (!empty($taggedSubscribers)) { $subscribersPerCon = $this->groupByConnection($taggedSubscribers); foreach ($subscribersPerCon as $con => $subscribers) { $em = $this->getEventManager($con); uasort($subscribers, $sortFunc); foreach ($subscribers as $id => $instance) { $em->addMethodCall('addEventSubscriber', array(new Reference($id))); } } } if (!empty($taggedListeners)) { $listenersPerCon = $this->groupByConnection($taggedListeners, true); foreach ($listenersPerCon as $con => $listeners) { $em = $this->getEventManager($con); uasort($listeners, $sortFunc); foreach ($listeners as $id => $instance) { $em->addMethodCall('addEventListener', array( array_unique($instance['event']), isset($instance['lazy']) && $instance['lazy'] ? $id : new Reference($id), )); } } } } private function groupByConnection(array $services, $isListener = false) { $grouped = array(); foreach ($allCons = array_keys($this->connections) as $con) { $grouped[$con] = array(); } foreach ($services as $id => $instances) { foreach ($instances as $instance) { if ($isListener) { if (!isset($instance['event'])) { throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id)); } $instance['event'] = array($instance['event']); if (!empty($instance['lazy'])) { $this->container->getDefinition($id)->setPublic(true); } } $cons = isset($instance['connection']) ? array($instance['connection']) : $allCons; foreach ($cons as $con) { if (!isset($grouped[$con])) { throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections)))); } if ($isListener && isset($grouped[$con][$id])) { $grouped[$con][$id]['event'] = array_merge($grouped[$con][$id]['event'], $instance['event']); } else { $grouped[$con][$id] = $instance; } } } } return $grouped; } private function getEventManager($name) { if (null === $this->eventManagers) { $this->eventManagers = array(); foreach ($this->connections as $n => $id) { $this->eventManagers[$n] = $this->container->getDefinition(sprintf($this->managerTemplate, $n)); } } return $this->eventManagers[$name]; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php000066400000000000000000000222521324732107100335760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; /** * Base class for the doctrine bundles to provide a compiler pass class that * helps to register doctrine mappings. * * The compiler pass is meant to register the mappings with the metadata * chain driver corresponding to one of the object managers. * * For concrete implementations that are easy to use, see the * RegisterXyMappingsPass classes in the DoctrineBundle resp. * DoctrineMongodbBundle, DoctrineCouchdbBundle and DoctrinePhpcrBundle. * * @author David Buchmann */ abstract class RegisterMappingsPass implements CompilerPassInterface { /** * DI object for the driver to use, either a service definition for a * private service or a reference for a public service. * * @var Definition|Reference */ protected $driver; /** * List of namespaces handled by the driver. * * @var string[] */ protected $namespaces; /** * List of potential container parameters that hold the object manager name * to register the mappings with the correct metadata driver, for example * array('acme.manager', 'doctrine.default_entity_manager'). * * @var string[] */ protected $managerParameters; /** * Naming pattern of the metadata chain driver service ids, for example * 'doctrine.orm.%s_metadata_driver'. * * @var string */ protected $driverPattern; /** * A name for a parameter in the container. If set, this compiler pass will * only do anything if the parameter is present. (But regardless of the * value of that parameter. * * @var string|false */ protected $enabledParameter; /** * Naming pattern for the configuration service id, for example * 'doctrine.orm.%s_configuration'. * * @var string */ private $configurationPattern; /** * Method name to call on the configuration service. This depends on the * Doctrine implementation. For example addEntityNamespace. * * @var string */ private $registerAliasMethodName; /** * Map of alias to namespace. * * @var string[] */ private $aliasMap; /** * The $managerParameters is an ordered list of container parameters that could provide the * name of the manager to register these namespaces and alias on. The first non-empty name * is used, the others skipped. * * The $aliasMap parameter can be used to define bundle namespace shortcuts like the * DoctrineBundle provides automatically for objects in the default Entity/Document folder. * * @param Definition|Reference $driver Driver DI definition or reference * @param string[] $namespaces List of namespaces handled by $driver * @param string[] $managerParameters list of container parameters that could * hold the manager name * @param string $driverPattern Pattern for the metadata driver service name * @param string|false $enabledParameter Service container parameter that must be * present to enable the mapping. Set to false * to not do any check, optional. * @param string $configurationPattern Pattern for the Configuration service name * @param string $registerAliasMethodName Name of Configuration class method to * register alias * @param string[] $aliasMap Map of alias to namespace */ public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = array()) { $this->driver = $driver; $this->namespaces = $namespaces; $this->managerParameters = $managerParameters; $this->driverPattern = $driverPattern; $this->enabledParameter = $enabledParameter; if (count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) { throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias'); } $this->configurationPattern = $configurationPattern; $this->registerAliasMethodName = $registerAliasMethodName; $this->aliasMap = $aliasMap; } /** * Register mappings and alias with the metadata drivers. */ public function process(ContainerBuilder $container) { if (!$this->enabled($container)) { return; } $mappingDriverDef = $this->getDriver($container); $chainDriverDefService = $this->getChainDriverServiceName($container); // Definition for a Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain $chainDriverDef = $container->getDefinition($chainDriverDefService); foreach ($this->namespaces as $namespace) { $chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace)); } if (!count($this->aliasMap)) { return; } $configurationServiceName = $this->getConfigurationServiceName($container); // Definition of the Doctrine\...\Configuration class specific to the Doctrine flavour. $configurationServiceDefinition = $container->getDefinition($configurationServiceName); foreach ($this->aliasMap as $alias => $namespace) { $configurationServiceDefinition->addMethodCall($this->registerAliasMethodName, array($alias, $namespace)); } } /** * Get the service name of the metadata chain driver that the mappings * should be registered with. * * @return string The name of the chain driver service * * @throws InvalidArgumentException if non of the managerParameters has a * non-empty value */ protected function getChainDriverServiceName(ContainerBuilder $container) { return sprintf($this->driverPattern, $this->getManagerName($container)); } /** * Create the service definition for the metadata driver. * * @param ContainerBuilder $container Passed on in case an extending class * needs access to the container * * @return Definition|Reference the metadata driver to add to all chain drivers */ protected function getDriver(ContainerBuilder $container) { return $this->driver; } /** * Get the service name from the pattern and the configured manager name. * * @return string a service definition name * * @throws InvalidArgumentException if none of the managerParameters has a * non-empty value */ private function getConfigurationServiceName(ContainerBuilder $container) { return sprintf($this->configurationPattern, $this->getManagerName($container)); } /** * Determine the manager name. * * The default implementation loops over the managerParameters and returns * the first non-empty parameter. * * @return string The name of the active manager * * @throws InvalidArgumentException if none of the managerParameters is found in the container */ private function getManagerName(ContainerBuilder $container) { foreach ($this->managerParameters as $param) { if ($container->hasParameter($param)) { $name = $container->getParameter($param); if ($name) { return $name; } } } throw new InvalidArgumentException(sprintf( 'Could not find the manager name parameter in the container. Tried the following parameter names: "%s"', implode('", "', $this->managerParameters) )); } /** * Determine whether this mapping should be activated or not. This allows * to take this decision with the container builder available. * * This default implementation checks if the class has the enabledParameter * configured and if so if that parameter is present in the container. * * @return bool whether this compiler pass really should register the mappings */ protected function enabled(ContainerBuilder $container) { return !$this->enabledParameter || $container->hasParameter($this->enabledParameter); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/000077500000000000000000000000001324732107100261565ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/000077500000000000000000000000001324732107100306075ustar00rootroot00000000000000EntityFactory.php000066400000000000000000000033341324732107100340500ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\DependencyInjection\Security\UserProvider; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * EntityFactory creates services for Doctrine user provider. * * @author Fabien Potencier * @author Christophe Coevoet */ class EntityFactory implements UserProviderFactoryInterface { private $key; private $providerId; public function __construct($key, $providerId) { $this->key = $key; $this->providerId = $providerId; } public function create(ContainerBuilder $container, $id, $config) { $container ->setDefinition($id, new ChildDefinition($this->providerId)) ->addArgument($config['class']) ->addArgument($config['property']) ->addArgument($config['manager_name']) ; } public function getKey() { return $this->key; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('class')->isRequired()->cannotBeEmpty()->end() ->scalarNode('property')->defaultNull()->end() ->scalarNode('manager_name')->defaultNull()->end() ->end() ; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/ExpressionLanguage/000077500000000000000000000000001324732107100242315ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/ExpressionLanguage/DoctrineParserCache.php000066400000000000000000000026371324732107100306220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\ExpressionLanguage; @trigger_error('The '.__NAMESPACE__.'\DoctrineParserCache class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\DoctrineAdapter class instead.', E_USER_DEPRECATED); use Doctrine\Common\Cache\Cache; use Symfony\Component\ExpressionLanguage\ParsedExpression; use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface; /** * @author Adrien Brault * * @deprecated DoctrineParserCache class is deprecated since version 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\DoctrineAdapter class instead. */ class DoctrineParserCache implements ParserCacheInterface { private $cache; public function __construct(Cache $cache) { $this->cache = $cache; } /** * {@inheritdoc} */ public function fetch($key) { if (false === $value = $this->cache->fetch($key)) { return; } return $value; } /** * {@inheritdoc} */ public function save($key, ParsedExpression $expression) { $this->cache->save($key, $expression); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/000077500000000000000000000000001324732107100213315ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/ChoiceList/000077500000000000000000000000001324732107100233575ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php000066400000000000000000000135761324732107100301150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; /** * Loads choices using a Doctrine object manager. * * @author Bernhard Schussek */ class DoctrineChoiceLoader implements ChoiceLoaderInterface { private $manager; private $class; private $idReader; private $objectLoader; /** * @var ChoiceListInterface */ private $choiceList; /** * Creates a new choice loader. * * Optionally, an implementation of {@link EntityLoaderInterface} can be * passed which optimizes the object loading for one of the Doctrine * mapper implementations. * * @param ObjectManager $manager The object manager * @param string $class The class name of the loaded objects * @param IdReader $idReader The reader for the object IDs * @param null|EntityLoaderInterface $objectLoader The objects loader * @param ChoiceListFactoryInterface $factory The factory for creating the loaded choice list */ public function __construct($manager, $class, $idReader = null, $objectLoader = null, $factory = null) { // BC to be removed and replace with type hints in 4.0 if ($manager instanceof ChoiceListFactoryInterface) { @trigger_error(sprintf('Passing a ChoiceListFactoryInterface to %s is deprecated since Symfony 3.1 and will no longer be supported in 4.0. You should either call "%s::loadChoiceList" or override it to return a ChoiceListInterface.', __CLASS__, __CLASS__), E_USER_DEPRECATED); // Provide a BC layer since $factory has changed // form first to last argument as of 3.1 $manager = $class; $class = $idReader; $idReader = $objectLoader; $objectLoader = $factory; } $classMetadata = $manager->getClassMetadata($class); $this->manager = $manager; $this->class = $classMetadata->getName(); $this->idReader = $idReader ?: new IdReader($manager, $classMetadata); $this->objectLoader = $objectLoader; } /** * {@inheritdoc} */ public function loadChoiceList($value = null) { if ($this->choiceList) { return $this->choiceList; } $objects = $this->objectLoader ? $this->objectLoader->getEntities() : $this->manager->getRepository($this->class)->findAll(); return $this->choiceList = new ArrayChoiceList($objects, $value); } /** * {@inheritdoc} */ public function loadValuesForChoices(array $choices, $value = null) { // Performance optimization if (empty($choices)) { return array(); } // Optimize performance for single-field identifiers. We already // know that the IDs are used as values $optimize = null === $value || is_array($value) && $value[0] === $this->idReader; // Attention: This optimization does not check choices for existence if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) { $values = array(); // Maintain order and indices of the given objects foreach ($choices as $i => $object) { if ($object instanceof $this->class) { // Make sure to convert to the right format $values[$i] = (string) $this->idReader->getIdValue($object); } } return $values; } return $this->loadChoiceList($value)->getValuesForChoices($choices); } /** * {@inheritdoc} */ public function loadChoicesForValues(array $values, $value = null) { // Performance optimization // Also prevents the generation of "WHERE id IN ()" queries through the // object loader. At least with MySQL and on the development machine // this was tested on, no exception was thrown for such invalid // statements, consequently no test fails when this code is removed. // https://github.com/symfony/symfony/pull/8981#issuecomment-24230557 if (empty($values)) { return array(); } // Optimize performance in case we have an object loader and // a single-field identifier $optimize = null === $value || is_array($value) && $this->idReader === $value[0]; if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) { $unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values); $objectsById = array(); $objects = array(); // Maintain order and indices from the given $values // An alternative approach to the following loop is to add the // "INDEX BY" clause to the Doctrine query in the loader, // but I'm not sure whether that's doable in a generic fashion. foreach ($unorderedObjects as $object) { $objectsById[(string) $this->idReader->getIdValue($object)] = $object; } foreach ($values as $i => $id) { if (isset($objectsById[$id])) { $objects[$i] = $objectsById[$id]; } } return $objects; } return $this->loadChoiceList($value)->getChoicesForValues($values); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityLoaderInterface.php000066400000000000000000000020771324732107100303220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; /** * Custom loader for entities in the choice list. * * @author Benjamin Eberlei */ interface EntityLoaderInterface { /** * Returns an array of entities that are valid choices in the corresponding choice list. * * @return array The entities */ public function getEntities(); /** * Returns an array of entities matching the given identifiers. * * @param string $identifier The identifier field of the object. This method * is not applicable for fields with multiple * identifiers. * @param array $values The values of the identifiers * * @return array The entities */ public function getEntitiesByIds($identifier, array $values); } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php000066400000000000000000000065101324732107100255510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\Exception\RuntimeException; /** * A utility for reading object IDs. * * @author Bernhard Schussek * * @internal */ class IdReader { private $om; private $classMetadata; private $singleId; private $intId; private $idField; /** * @var IdReader|null */ private $associationIdReader; public function __construct(ObjectManager $om, ClassMetadata $classMetadata) { $ids = $classMetadata->getIdentifierFieldNames(); $idType = $classMetadata->getTypeOfField(current($ids)); $this->om = $om; $this->classMetadata = $classMetadata; $this->singleId = 1 === count($ids); $this->intId = $this->singleId && in_array($idType, array('integer', 'smallint', 'bigint')); $this->idField = current($ids); // single field association are resolved, since the schema column could be an int if ($this->singleId && $classMetadata->hasAssociation($this->idField)) { $this->associationIdReader = new self($om, $om->getClassMetadata( $classMetadata->getAssociationTargetClass($this->idField) )); $this->singleId = $this->associationIdReader->isSingleId(); $this->intId = $this->associationIdReader->isIntId(); } } /** * Returns whether the class has a single-column ID. * * @return bool returns `true` if the class has a single-column ID and * `false` otherwise */ public function isSingleId() { return $this->singleId; } /** * Returns whether the class has a single-column integer ID. * * @return bool returns `true` if the class has a single-column integer ID * and `false` otherwise */ public function isIntId() { return $this->intId; } /** * Returns the ID value for an object. * * This method assumes that the object has a single-column ID. * * @param object $object The object * * @return mixed The ID value */ public function getIdValue($object) { if (!$object) { return; } if (!$this->om->contains($object)) { throw new RuntimeException( 'Entities passed to the choice field must be managed. Maybe '. 'persist them in the entity manager?' ); } $this->om->initializeObject($object); $idValue = current($this->classMetadata->getIdentifierValues($object)); if ($this->associationIdReader) { $idValue = $this->associationIdReader->getIdValue($idValue); } return $idValue; } /** * Returns the name of the ID field. * * This method assumes that the object has a single-column ID. * * @return string The name of the ID field */ public function getIdField() { return $this->idField; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php000066400000000000000000000055551324732107100302230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; use Doctrine\ORM\QueryBuilder; use Doctrine\DBAL\Connection; /** * Loads entities using a {@link QueryBuilder} instance. * * @author Benjamin Eberlei * @author Bernhard Schussek */ class ORMQueryBuilderLoader implements EntityLoaderInterface { /** * Contains the query builder that builds the query for fetching the * entities. * * This property should only be accessed through queryBuilder. * * @var QueryBuilder */ private $queryBuilder; /** * Construct an ORM Query Builder Loader. * * @param QueryBuilder $queryBuilder The query builder for creating the query builder */ public function __construct(QueryBuilder $queryBuilder) { $this->queryBuilder = $queryBuilder; } /** * {@inheritdoc} */ public function getEntities() { return $this->queryBuilder->getQuery()->execute(); } /** * {@inheritdoc} */ public function getEntitiesByIds($identifier, array $values) { $qb = clone $this->queryBuilder; $alias = current($qb->getRootAliases()); $parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier; $parameter = str_replace('.', '_', $parameter); $where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter); // Guess type $entity = current($qb->getRootEntities()); $metadata = $qb->getEntityManager()->getClassMetadata($entity); if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) { $parameterType = Connection::PARAM_INT_ARRAY; // Filter out non-integer values (e.g. ""). If we don't, some // databases such as PostgreSQL fail. $values = array_values(array_filter($values, function ($v) { return (string) $v === (string) (int) $v || ctype_digit($v); })); } elseif (in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) { $parameterType = Connection::PARAM_STR_ARRAY; // Like above, but we just filter out empty strings. $values = array_values(array_filter($values, function ($v) { return '' !== (string) $v; })); } else { $parameterType = Connection::PARAM_STR_ARRAY; } if (!$values) { return array(); } return $qb->andWhere($where) ->getQuery() ->setParameter($parameter, $values, $parameterType) ->getResult(); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/DataTransformer/000077500000000000000000000000001324732107100244255ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php000066400000000000000000000034111324732107100327550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\DataTransformerInterface; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; /** * @author Bernhard Schussek */ class CollectionToArrayTransformer implements DataTransformerInterface { /** * Transforms a collection into an array. * * @return mixed An array of entities * * @throws TransformationFailedException */ public function transform($collection) { if (null === $collection) { return array(); } // For cases when the collection getter returns $collection->toArray() // in order to prevent modifications of the returned collection if (is_array($collection)) { return $collection; } if (!$collection instanceof Collection) { throw new TransformationFailedException('Expected a Doctrine\Common\Collections\Collection object.'); } return $collection->toArray(); } /** * Transforms choice keys into entities. * * @param mixed $array An array of entities * * @return Collection A collection of entities */ public function reverseTransform($array) { if ('' === $array || null === $array) { $array = array(); } else { $array = (array) $array; } return new ArrayCollection($array); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php000066400000000000000000000015301324732107100261630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form; use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractExtension; class DoctrineOrmExtension extends AbstractExtension { protected $registry; public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } protected function loadTypes() { return array( new EntityType($this->registry), ); } protected function loadTypeGuesser() { return new DoctrineOrmTypeGuesser($this->registry); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php000066400000000000000000000153111324732107100264700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException as LegacyMappingException; use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; use Symfony\Component\Form\Guess\ValueGuess; use Doctrine\Common\Util\ClassUtils; class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface { protected $registry; private $cache = array(); public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } /** * {@inheritdoc} */ public function guessType($class, $property) { if (!$ret = $this->getMetadata($class)) { return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE); } list($metadata, $name) = $ret; if ($metadata->hasAssociation($property)) { $multiple = $metadata->isCollectionValuedAssociation($property); $mapping = $metadata->getAssociationMapping($property); return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', array('em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple), Guess::HIGH_CONFIDENCE); } switch ($metadata->getTypeOfField($property)) { case Type::TARRAY: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), Guess::MEDIUM_CONFIDENCE); case Type::BOOLEAN: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(), Guess::HIGH_CONFIDENCE); case Type::DATETIME: case Type::DATETIMETZ: case 'vardatetime': return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE); case 'dateinterval': return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE); case Type::DATE: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array(), Guess::HIGH_CONFIDENCE); case Type::TIME: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', array(), Guess::HIGH_CONFIDENCE); case Type::DECIMAL: case Type::FLOAT: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', array(), Guess::MEDIUM_CONFIDENCE); case Type::INTEGER: case Type::BIGINT: case Type::SMALLINT: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', array(), Guess::MEDIUM_CONFIDENCE); case Type::STRING: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::MEDIUM_CONFIDENCE); case Type::TEXT: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', array(), Guess::MEDIUM_CONFIDENCE); default: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE); } } /** * {@inheritdoc} */ public function guessRequired($class, $property) { $classMetadatas = $this->getMetadata($class); if (!$classMetadatas) { return; } /** @var ClassMetadataInfo $classMetadata */ $classMetadata = $classMetadatas[0]; // Check whether the field exists and is nullable or not if ($classMetadata->hasField($property)) { if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) { return new ValueGuess(true, Guess::HIGH_CONFIDENCE); } return new ValueGuess(false, Guess::MEDIUM_CONFIDENCE); } // Check whether the association exists, is a to-one association and its // join column is nullable or not if ($classMetadata->isAssociationWithSingleJoinColumn($property)) { $mapping = $classMetadata->getAssociationMapping($property); if (!isset($mapping['joinColumns'][0]['nullable'])) { // The "nullable" option defaults to true, in that case the // field should not be required. return new ValueGuess(false, Guess::HIGH_CONFIDENCE); } return new ValueGuess(!$mapping['joinColumns'][0]['nullable'], Guess::HIGH_CONFIDENCE); } } /** * {@inheritdoc} */ public function guessMaxLength($class, $property) { $ret = $this->getMetadata($class); if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) { $mapping = $ret[0]->getFieldMapping($property); if (isset($mapping['length'])) { return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE); } if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } } } /** * {@inheritdoc} */ public function guessPattern($class, $property) { $ret = $this->getMetadata($class); if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) { if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } } } protected function getMetadata($class) { // normalize class name $class = ClassUtils::getRealClass(ltrim($class, '\\')); if (array_key_exists($class, $this->cache)) { return $this->cache[$class]; } $this->cache[$class] = null; foreach ($this->registry->getManagers() as $name => $em) { try { return $this->cache[$class] = array($em->getClassMetadata($class), $name); } catch (MappingException $e) { // not an entity or mapped super class } catch (LegacyMappingException $e) { // not an entity or mapped super class, using Doctrine ORM 2.2 } } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/EventListener/000077500000000000000000000000001324732107100241205ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php000066400000000000000000000046521324732107100331110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\EventListener; use Doctrine\Common\Collections\Collection; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Merge changes from the request to a Doctrine\Common\Collections\Collection instance. * * This works with ORM, MongoDB and CouchDB instances of the collection interface. * * @author Bernhard Schussek * * @see Collection */ class MergeDoctrineCollectionListener implements EventSubscriberInterface { // Keep BC. To be removed in 4.0 private $bc = true; private $bcLayer = false; public static function getSubscribedEvents() { // Higher priority than core MergeCollectionListener so that this one // is called before return array( FormEvents::SUBMIT => array( array('onBind', 10), // deprecated array('onSubmit', 5), ), ); } public function onSubmit(FormEvent $event) { if ($this->bc) { // onBind() has been overridden from a child class @trigger_error('The onBind() method is deprecated since Symfony 3.1 and will be removed in 4.0. Use the onSubmit() method instead.', E_USER_DEPRECATED); if (!$this->bcLayer) { // If parent::onBind() has not been called, then logic has been executed return; } } $collection = $event->getForm()->getData(); $data = $event->getData(); // If all items were removed, call clear which has a higher // performance on persistent collections if ($collection instanceof Collection && 0 === count($data)) { $collection->clear(); } } /** * Alias of {@link onSubmit()}. * * @deprecated since version 3.1, to be removed in 4.0. * Use {@link onSubmit()} instead. */ public function onBind(FormEvent $event) { if (__CLASS__ === get_class($this)) { $this->bc = false; } else { // parent::onBind() has been called $this->bcLayer = true; } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/Type/000077500000000000000000000000001324732107100222525ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php000066400000000000000000000242711324732107100254020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\Type; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader; use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface; use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader; use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; use Symfony\Bridge\Doctrine\Form\EventListener\MergeDoctrineCollectionListener; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; abstract class DoctrineType extends AbstractType { /** * @var ManagerRegistry */ protected $registry; /** * @var IdReader[] */ private $idReaders = array(); /** * @var DoctrineChoiceLoader[] */ private $choiceLoaders = array(); /** * Creates the label for a choice. * * For backwards compatibility, objects are cast to strings by default. * * @param object $choice The object * * @return string The string representation of the object * * @internal This method is public to be usable as callback. It should not * be used in user code. */ public static function createChoiceLabel($choice) { return (string) $choice; } /** * Creates the field name for a choice. * * This method is used to generate field names if the underlying object has * a single-column integer ID. In that case, the value of the field is * the ID of the object. That ID is also used as field name. * * @param object $choice The object * @param int|string $key The choice key * @param string $value The choice value. Corresponds to the object's * ID here. * * @return string The field name * * @internal This method is public to be usable as callback. It should not * be used in user code. */ public static function createChoiceName($choice, $key, $value) { return str_replace('-', '_', (string) $value); } /** * Gets important parts from QueryBuilder that will allow to cache its results. * For instance in ORM two query builders with an equal SQL string and * equal parameters are considered to be equal. * * @param object $queryBuilder * * @return array|false Array with important QueryBuilder parts or false if * they can't be determined * * @internal This method is public to be usable as callback. It should not * be used in user code. */ public function getQueryBuilderPartsForCachingHash($queryBuilder) { return false; } public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['multiple']) { $builder ->addEventSubscriber(new MergeDoctrineCollectionListener()) ->addViewTransformer(new CollectionToArrayTransformer(), true) ; } } public function configureOptions(OptionsResolver $resolver) { $choiceLoader = function (Options $options) { // Unless the choices are given explicitly, load them on demand if (null === $options['choices']) { $hash = null; $qbParts = null; // If there is no QueryBuilder we can safely cache DoctrineChoiceLoader, // also if concrete Type can return important QueryBuilder parts to generate // hash key we go for it as well if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) { $hash = CachingFactoryDecorator::generateHash(array( $options['em'], $options['class'], $qbParts, )); if (isset($this->choiceLoaders[$hash])) { return $this->choiceLoaders[$hash]; } } if (null !== $options['query_builder']) { $entityLoader = $this->getLoader($options['em'], $options['query_builder'], $options['class']); } else { $queryBuilder = $options['em']->getRepository($options['class'])->createQueryBuilder('e'); $entityLoader = $this->getLoader($options['em'], $queryBuilder, $options['class']); } $doctrineChoiceLoader = new DoctrineChoiceLoader( $options['em'], $options['class'], $options['id_reader'], $entityLoader ); if (null !== $hash) { $this->choiceLoaders[$hash] = $doctrineChoiceLoader; } return $doctrineChoiceLoader; } }; $choiceName = function (Options $options) { /** @var IdReader $idReader */ $idReader = $options['id_reader']; // If the object has a single-column, numeric ID, use that ID as // field name. We can only use numeric IDs as names, as we cannot // guarantee that a non-numeric ID contains a valid form name if ($idReader->isIntId()) { return array(__CLASS__, 'createChoiceName'); } // Otherwise, an incrementing integer is used as name automatically }; // The choices are always indexed by ID (see "choices" normalizer // and DoctrineChoiceLoader), unless the ID is composite. Then they // are indexed by an incrementing integer. // Use the ID/incrementing integer as choice value. $choiceValue = function (Options $options) { /** @var IdReader $idReader */ $idReader = $options['id_reader']; // If the entity has a single-column ID, use that ID as value if ($idReader->isSingleId()) { return array($idReader, 'getIdValue'); } // Otherwise, an incrementing integer is used as value automatically }; $emNormalizer = function (Options $options, $em) { /* @var ManagerRegistry $registry */ if (null !== $em) { if ($em instanceof ObjectManager) { return $em; } return $this->registry->getManager($em); } $em = $this->registry->getManagerForClass($options['class']); if (null === $em) { throw new RuntimeException(sprintf( 'Class "%s" seems not to be a managed Doctrine entity. '. 'Did you forget to map it?', $options['class'] )); } return $em; }; // Invoke the query builder closure so that we can cache choice lists // for equal query builders $queryBuilderNormalizer = function (Options $options, $queryBuilder) { if (is_callable($queryBuilder)) { $queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); } return $queryBuilder; }; // Set the "id_reader" option via the normalizer. This option is not // supposed to be set by the user. $idReaderNormalizer = function (Options $options) { $hash = CachingFactoryDecorator::generateHash(array( $options['em'], $options['class'], )); // The ID reader is a utility that is needed to read the object IDs // when generating the field values. The callback generating the // field values has no access to the object manager or the class // of the field, so we store that information in the reader. // The reader is cached so that two choice lists for the same class // (and hence with the same reader) can successfully be cached. if (!isset($this->idReaders[$hash])) { $classMetadata = $options['em']->getClassMetadata($options['class']); $this->idReaders[$hash] = new IdReader($options['em'], $classMetadata); } return $this->idReaders[$hash]; }; $resolver->setDefaults(array( 'em' => null, 'query_builder' => null, 'choices' => null, 'choice_loader' => $choiceLoader, 'choice_label' => array(__CLASS__, 'createChoiceLabel'), 'choice_name' => $choiceName, 'choice_value' => $choiceValue, 'id_reader' => null, // internal 'choice_translation_domain' => false, )); $resolver->setRequired(array('class')); $resolver->setNormalizer('em', $emNormalizer); $resolver->setNormalizer('query_builder', $queryBuilderNormalizer); $resolver->setNormalizer('id_reader', $idReaderNormalizer); $resolver->setAllowedTypes('em', array('null', 'string', 'Doctrine\Common\Persistence\ObjectManager')); } /** * Return the default loader object. * * @param ObjectManager $manager * @param mixed $queryBuilder * @param string $class * * @return EntityLoaderInterface */ abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class); public function getParent() { return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; } public function reset() { $this->choiceLoaders = array(); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php000066400000000000000000000056211324732107100251050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\Type; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class EntityType extends DoctrineType { public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); // Invoke the query builder closure so that we can cache choice lists // for equal query builders $queryBuilderNormalizer = function (Options $options, $queryBuilder) { if (is_callable($queryBuilder)) { $queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) { throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder'); } } return $queryBuilder; }; $resolver->setNormalizer('query_builder', $queryBuilderNormalizer); $resolver->setAllowedTypes('query_builder', array('null', 'callable', 'Doctrine\ORM\QueryBuilder')); } /** * Return the default loader object. * * @param ObjectManager $manager * @param QueryBuilder $queryBuilder * @param string $class * * @return ORMQueryBuilderLoader */ public function getLoader(ObjectManager $manager, $queryBuilder, $class) { return new ORMQueryBuilderLoader($queryBuilder); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'entity'; } /** * We consider two query builders with an equal SQL string and * equal parameters to be equal. * * @param QueryBuilder $queryBuilder * * @return array * * @internal This method is public to be usable as callback. It should not * be used in user code. */ public function getQueryBuilderPartsForCachingHash($queryBuilder) { return array( $queryBuilder->getQuery()->getSQL(), array_map(array($this, 'parameterToArray'), $queryBuilder->getParameters()->toArray()), ); } /** * Converts a query parameter to an array. * * @return array The array representation of the parameter */ private function parameterToArray(Parameter $parameter) { return array($parameter->getName(), $parameter->getType(), $parameter->getValue()); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/HttpFoundation/000077500000000000000000000000001324732107100233745ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php000066400000000000000000000250641324732107100276200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\HttpFoundation; @trigger_error(sprintf('The class %s is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler instead.', DbalSessionHandler::class), E_USER_DEPRECATED); use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Platforms\SQLServer2008Platform; /** * DBAL based session storage. * * This implementation is very similar to Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler * but uses a Doctrine connection and thus also works with non-PDO-based drivers like mysqli and OCI8. * * @author Fabien Potencier * @author Johannes M. Schmitt * @author Tobias Schultze * * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler instead. */ class DbalSessionHandler implements \SessionHandlerInterface { /** * @var Connection */ private $con; /** * @var string */ private $table; /** * @var string Column for session id */ private $idCol = 'sess_id'; /** * @var string Column for session data */ private $dataCol = 'sess_data'; /** * @var string Column for timestamp */ private $timeCol = 'sess_time'; /** * @param Connection $con A connection * @param string $tableName Table name */ public function __construct(Connection $con, $tableName = 'sessions') { $this->con = $con; $this->table = $tableName; } /** * {@inheritdoc} */ public function open($savePath, $sessionName) { return true; } /** * {@inheritdoc} */ public function close() { return true; } /** * {@inheritdoc} */ public function destroy($sessionId) { // delete the record associated with this id $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->con->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); } catch (\Exception $e) { throw new \RuntimeException(sprintf('Exception was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); } return true; } /** * {@inheritdoc} */ public function gc($maxlifetime) { // delete the session records that have expired $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; try { $stmt = $this->con->prepare($sql); $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); $stmt->execute(); } catch (\Exception $e) { throw new \RuntimeException(sprintf('Exception was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); } return true; } /** * {@inheritdoc} */ public function read($sessionId) { $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->con->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); if ($sessionRows) { return base64_decode($sessionRows[0][0]); } return ''; } catch (\Exception $e) { throw new \RuntimeException(sprintf('Exception was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); } } /** * {@inheritdoc} */ public function write($sessionId, $data) { $encoded = base64_encode($data); try { // We use a single MERGE SQL query when supported by the database. $mergeSql = $this->getMergeSql(); if (null !== $mergeSql) { $mergeStmt = $this->con->prepare($mergeSql); $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); // Oracle has a bug that will intermittently happen if you // have only 1 bind on a CLOB field for 2 different statements // (INSERT and UPDATE in this case) if ('oracle' == $this->con->getDatabasePlatform()->getName()) { $mergeStmt->bindParam(':data2', $encoded, \PDO::PARAM_STR); } $mergeStmt->execute(); return true; } $updateStmt = $this->con->prepare( "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" ); $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); $updateStmt->execute(); // When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in // duplicate key errors when the same session is written simultaneously. We can just catch such an // error and re-execute the update. This is similar to a serializable transaction with retry logic // on serialization failures but without the overhead and without possible false positives due to // longer gap locking. if (!$updateStmt->rowCount()) { try { $insertStmt = $this->con->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" ); $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); } catch (\Exception $e) { $driverException = $e->getPrevious(); // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys // DriverException only available since DBAL 2.5 if ( ($driverException instanceof DriverException && 0 === strpos($driverException->getSQLState(), '23')) || ($driverException instanceof \PDOException && 0 === strpos($driverException->getCode(), '23')) ) { $updateStmt->execute(); } else { throw $e; } } } } catch (\Exception $e) { throw new \RuntimeException(sprintf('Exception was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); } return true; } /** * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. * * @return string|null The SQL string or null when not supported */ private function getMergeSql() { $platform = $this->con->getDatabasePlatform()->getName(); switch (true) { case 'mysql' === $platform: return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; case 'oracle' === $platform: // DUAL is Oracle specific dummy table return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data2, $this->timeCol = :time"; case $this->con->getDatabasePlatform() instanceof SQLServer2008Platform: // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; case 'sqlite' === $platform: return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; case 'postgresql' === $platform && version_compare($this->getServerVersion(), '9.5', '>='): return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->timeCol)"; } } private function getServerVersion() { $params = $this->con->getParams(); // Explicit platform version requested (supersedes auto-detection), so we respect it. if (isset($params['serverVersion'])) { return $params['serverVersion']; } $wrappedConnection = $this->con->getWrappedConnection(); if ($wrappedConnection instanceof ServerInfoAwareConnection) { return $wrappedConnection->getServerVersion(); } // Support DBAL 2.4 by accessing it directly when using PDO PgSQL if ($wrappedConnection instanceof \PDO) { return $wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION); } // If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks. return ''; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandlerSchema.php000066400000000000000000000030261324732107100307330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\HttpFoundation; @trigger_error(sprintf('The class %s is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::createTable instead.', DbalSessionHandlerSchema::class), E_USER_DEPRECATED); use Doctrine\DBAL\Schema\Schema; /** * DBAL Session Storage Schema. * * @author Johannes M. Schmitt * * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::createTable instead. */ final class DbalSessionHandlerSchema extends Schema { public function __construct($tableName = 'sessions') { parent::__construct(); $this->addSessionTable($tableName); } public function addToSchema(Schema $schema) { foreach ($this->getTables() as $table) { $schema->_addTable($table); } } private function addSessionTable($tableName) { $table = $this->createTable($tableName); $table->addColumn('sess_id', 'string'); $table->addColumn('sess_data', 'text')->setNotNull(true); $table->addColumn('sess_time', 'integer')->setNotNull(true)->setUnsigned(true); $table->setPrimaryKey(array('sess_id')); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/LICENSE000066400000000000000000000020511324732107100214310ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Bridge/Doctrine/Logger/000077500000000000000000000000001324732107100216455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php000066400000000000000000000047431324732107100243700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Logger; use Psr\Log\LoggerInterface; use Symfony\Component\Stopwatch\Stopwatch; use Doctrine\DBAL\Logging\SQLLogger; /** * @author Fabien Potencier */ class DbalLogger implements SQLLogger { const MAX_STRING_LENGTH = 32; const BINARY_DATA_VALUE = '(binary value)'; protected $logger; protected $stopwatch; public function __construct(LoggerInterface $logger = null, Stopwatch $stopwatch = null) { $this->logger = $logger; $this->stopwatch = $stopwatch; } /** * {@inheritdoc} */ public function startQuery($sql, array $params = null, array $types = null) { if (null !== $this->stopwatch) { $this->stopwatch->start('doctrine', 'doctrine'); } if (null !== $this->logger) { $this->log($sql, null === $params ? array() : $this->normalizeParams($params)); } } /** * {@inheritdoc} */ public function stopQuery() { if (null !== $this->stopwatch) { $this->stopwatch->stop('doctrine'); } } /** * Logs a message. * * @param string $message A message to log * @param array $params The context */ protected function log($message, array $params) { $this->logger->debug($message, $params); } private function normalizeParams(array $params) { foreach ($params as $index => $param) { // normalize recursively if (is_array($param)) { $params[$index] = $this->normalizeParams($param); continue; } if (!is_string($params[$index])) { continue; } // non utf-8 strings break json encoding if (!preg_match('//u', $params[$index])) { $params[$index] = self::BINARY_DATA_VALUE; continue; } // detect if the too long string must be shorten if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) { $params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'; continue; } } return $params; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/ManagerRegistry.php000066400000000000000000000060761324732107100242530ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine; use ProxyManager\Proxy\LazyLoadingInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface; use Doctrine\Common\Persistence\AbstractManagerRegistry; /** * References Doctrine connections and entity/document managers. * * @author Lukas Kahwe Smith */ abstract class ManagerRegistry extends AbstractManagerRegistry implements ContainerAwareInterface { /** * @var Container */ protected $container; /** * @deprecated since version 3.4, to be removed in 4.0 alongside with the ContainerAwareInterface type. * @final since version 3.4 */ public function setContainer(SymfonyContainerInterface $container = null) { @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a PSR-11 container using the constructor instead.', __METHOD__), E_USER_DEPRECATED); $this->container = $container; } /** * {@inheritdoc} */ protected function getService($name) { return $this->container->get($name); } /** * {@inheritdoc} */ protected function resetService($name) { if (!$this->container->initialized($name)) { return; } $manager = $this->container->get($name); if (!$manager instanceof LazyLoadingInterface) { @trigger_error(sprintf('Resetting a non-lazy manager service is deprecated since Symfony 3.2 and will throw an exception in version 4.0. Set the "%s" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.', $name), E_USER_DEPRECATED); $this->container->set($name, null); return; } $manager->setProxyInitializer(\Closure::bind( function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { if (isset($this->normalizedIds[$normalizedId = strtolower($name)])) { $name = $this->normalizedIds[$normalizedId]; } if (isset($this->aliases[$name])) { $name = $this->aliases[$name]; } if (isset($this->fileMap[$name])) { $wrappedInstance = $this->load($this->fileMap[$name]); } else { $method = !isset($this->methodMap[$name]) ? 'get'.strtr($name, $this->underscoreMap).'Service' : $this->methodMap[$name]; $wrappedInstance = $this->{$method}(false); } $manager->setProxyInitializer(null); return true; }, $this->container, Container::class )); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/PropertyInfo/000077500000000000000000000000001324732107100230665ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php000066400000000000000000000167031324732107100272510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\PropertyInfo; use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory; use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException as OrmMappingException; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; use Symfony\Component\PropertyInfo\Type; /** * Extracts data using Doctrine ORM and ODM metadata. * * @author Kévin Dunglas */ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface { private $classMetadataFactory; public function __construct(ClassMetadataFactory $classMetadataFactory) { $this->classMetadataFactory = $classMetadataFactory; } /** * {@inheritdoc} */ public function getProperties($class, array $context = array()) { try { $metadata = $this->classMetadataFactory->getMetadataFor($class); } catch (MappingException $exception) { return; } catch (OrmMappingException $exception) { return; } $properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) { $properties = array_filter($properties, function ($property) { return false === strpos($property, '.'); }); $properties = array_merge($properties, array_keys($metadata->embeddedClasses)); } return $properties; } /** * {@inheritdoc} */ public function getTypes($class, $property, array $context = array()) { try { $metadata = $this->classMetadataFactory->getMetadataFor($class); } catch (MappingException $exception) { return; } catch (OrmMappingException $exception) { return; } if ($metadata->hasAssociation($property)) { $class = $metadata->getAssociationTargetClass($property); if ($metadata->isSingleValuedAssociation($property)) { if ($metadata instanceof ClassMetadataInfo) { $associationMapping = $metadata->getAssociationMapping($property); $nullable = $this->isAssociationNullable($associationMapping); } else { $nullable = false; } return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)); } $collectionKeyType = Type::BUILTIN_TYPE_INT; if ($metadata instanceof ClassMetadataInfo) { $associationMapping = $metadata->getAssociationMapping($property); if (isset($associationMapping['indexBy'])) { $indexProperty = $associationMapping['indexBy']; $subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']); $typeOfField = $subMetadata->getTypeOfField($indexProperty); $collectionKeyType = $this->getPhpType($typeOfField); } } return array(new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type($collectionKeyType), new Type(Type::BUILTIN_TYPE_OBJECT, false, $class) )); } if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) { return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])); } if ($metadata->hasField($property)) { $typeOfField = $metadata->getTypeOfField($property); $nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property); switch ($typeOfField) { case DBALType::DATE: case DBALType::DATETIME: case DBALType::DATETIMETZ: case 'vardatetime': case DBALType::TIME: return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')); case 'date_immutable': case 'datetime_immutable': case 'datetimetz_immutable': case 'time_immutable': return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')); case 'dateinterval': return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')); case DBALType::TARRAY: return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)); case DBALType::SIMPLE_ARRAY: return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))); case DBALType::JSON_ARRAY: return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)); default: $builtinType = $this->getPhpType($typeOfField); return $builtinType ? array(new Type($builtinType, $nullable)) : null; } } } /** * Determines whether an association is nullable. * * @param array $associationMapping * * @return bool * * @see https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1221-L1246 */ private function isAssociationNullable(array $associationMapping) { if (isset($associationMapping['id']) && $associationMapping['id']) { return false; } if (!isset($associationMapping['joinColumns'])) { return true; } $joinColumns = $associationMapping['joinColumns']; foreach ($joinColumns as $joinColumn) { if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) { return false; } } return true; } /** * Gets the corresponding built-in PHP type. * * @param string $doctrineType * * @return string|null */ private function getPhpType($doctrineType) { switch ($doctrineType) { case DBALType::SMALLINT: case DBALType::INTEGER: return Type::BUILTIN_TYPE_INT; case DBALType::FLOAT: return Type::BUILTIN_TYPE_FLOAT; case DBALType::BIGINT: case DBALType::STRING: case DBALType::TEXT: case DBALType::GUID: case DBALType::DECIMAL: return Type::BUILTIN_TYPE_STRING; case DBALType::BOOLEAN: return Type::BUILTIN_TYPE_BOOL; case DBALType::BLOB: case 'binary': return Type::BUILTIN_TYPE_RESOURCE; case DBALType::OBJECT: return Type::BUILTIN_TYPE_OBJECT; } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/README.md000066400000000000000000000006711324732107100217110ustar00rootroot00000000000000Doctrine Bridge =============== Provides integration for [Doctrine](http://www.doctrine-project.org/) with various Symfony components. Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bridge/Doctrine/RegistryInterface.php000066400000000000000000000051161324732107100245730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine; use Doctrine\Common\Persistence\ManagerRegistry as ManagerRegistryInterface; use Doctrine\ORM\EntityManager; /** * References Doctrine connections and entity managers. * * @author Fabien Potencier */ interface RegistryInterface extends ManagerRegistryInterface { /** * Gets the default entity manager name. * * @return string The default entity manager name */ public function getDefaultEntityManagerName(); /** * Gets a named entity manager. * * @param string $name The entity manager name (null for the default one) * * @return EntityManager */ public function getEntityManager($name = null); /** * Gets an array of all registered entity managers. * * @return array An array of EntityManager instances */ public function getEntityManagers(); /** * Resets a named entity manager. * * This method is useful when an entity manager has been closed * because of a rollbacked transaction AND when you think that * it makes sense to get a new one to replace the closed one. * * Be warned that you will get a brand new entity manager as * the existing one is not useable anymore. This means that any * other object with a dependency on this entity manager will * hold an obsolete reference. You can inject the registry instead * to avoid this problem. * * @param string $name The entity manager name (null for the default one) * * @return EntityManager */ public function resetEntityManager($name = null); /** * Resolves a registered namespace alias to the full namespace. * * This method looks for the alias in all registered entity managers. * * @param string $alias The alias * * @return string The full namespace * * @see Configuration::getEntityNamespace */ public function getEntityNamespace($alias); /** * Gets all connection names. * * @return array An array of connection names */ public function getEntityManagerNames(); /** * Gets the entity manager associated with a given class. * * @param string $class A Doctrine Entity class name * * @return EntityManager|null */ public function getEntityManagerForClass($class); } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/000077500000000000000000000000001324732107100222355ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/RememberMe/000077500000000000000000000000001324732107100242555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php000066400000000000000000000101421324732107100312470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Security\RememberMe; use Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface; use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface; use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; use Symfony\Component\Security\Core\Exception\TokenNotFoundException; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type as DoctrineType; /** * This class provides storage for the tokens that is set in "remember me" * cookies. This way no password secrets will be stored in the cookies on * the client machine, and thus the security is improved. * * This depends only on doctrine in order to get a database connection * and to do the conversion of the datetime column. * * In order to use this class, you need the following table in your database: * CREATE TABLE `rememberme_token` ( * `series` char(88) UNIQUE PRIMARY KEY NOT NULL, * `value` char(88) NOT NULL, * `lastUsed` datetime NOT NULL, * `class` varchar(100) NOT NULL, * `username` varchar(200) NOT NULL * ); */ class DoctrineTokenProvider implements TokenProviderInterface { private $conn; public function __construct(Connection $conn) { $this->conn = $conn; } /** * {@inheritdoc} */ public function loadTokenBySeries($series) { $sql = 'SELECT class, username, value, lastUsed' .' FROM rememberme_token WHERE series=:series'; $paramValues = array('series' => $series); $paramTypes = array('series' => \PDO::PARAM_STR); $stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes); $row = $stmt->fetch(\PDO::FETCH_ASSOC); if ($row) { return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['lastUsed'])); } throw new TokenNotFoundException('No token found.'); } /** * {@inheritdoc} */ public function deleteTokenBySeries($series) { $sql = 'DELETE FROM rememberme_token WHERE series=:series'; $paramValues = array('series' => $series); $paramTypes = array('series' => \PDO::PARAM_STR); $this->conn->executeUpdate($sql, $paramValues, $paramTypes); } /** * {@inheritdoc} */ public function updateToken($series, $tokenValue, \DateTime $lastUsed) { $sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed' .' WHERE series=:series'; $paramValues = array( 'value' => $tokenValue, 'lastUsed' => $lastUsed, 'series' => $series, ); $paramTypes = array( 'value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, 'series' => \PDO::PARAM_STR, ); $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); if ($updated < 1) { throw new TokenNotFoundException('No token found.'); } } /** * {@inheritdoc} */ public function createNewToken(PersistentTokenInterface $token) { $sql = 'INSERT INTO rememberme_token' .' (class, username, series, value, lastUsed)' .' VALUES (:class, :username, :series, :value, :lastUsed)'; $paramValues = array( 'class' => $token->getClass(), 'username' => $token->getUsername(), 'series' => $token->getSeries(), 'value' => $token->getTokenValue(), 'lastUsed' => $token->getLastUsed(), ); $paramTypes = array( 'class' => \PDO::PARAM_STR, 'username' => \PDO::PARAM_STR, 'series' => \PDO::PARAM_STR, 'value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, ); $this->conn->executeUpdate($sql, $paramValues, $paramTypes); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/User/000077500000000000000000000000001324732107100231535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php000066400000000000000000000106661324732107100275230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Security\User; use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserInterface; /** * Wrapper around a Doctrine ObjectManager. * * Provides easy to use provisioning for Doctrine entity users. * * @author Fabien Potencier * @author Johannes M. Schmitt */ class EntityUserProvider implements UserProviderInterface { private $registry; private $managerName; private $classOrAlias; private $class; private $property; public function __construct(ManagerRegistry $registry, $classOrAlias, $property = null, $managerName = null) { $this->registry = $registry; $this->managerName = $managerName; $this->classOrAlias = $classOrAlias; $this->property = $property; } /** * {@inheritdoc} */ public function loadUserByUsername($username) { $repository = $this->getRepository(); if (null !== $this->property) { $user = $repository->findOneBy(array($this->property => $username)); } else { if (!$repository instanceof UserLoaderInterface) { throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository))); } $user = $repository->loadUserByUsername($username); } if (null === $user) { throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username)); } return $user; } /** * {@inheritdoc} */ public function refreshUser(UserInterface $user) { $class = $this->getClass(); if (!$user instanceof $class) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); } $repository = $this->getRepository(); if ($repository instanceof UserProviderInterface) { $refreshedUser = $repository->refreshUser($user); } else { // The user must be reloaded via the primary key as all other data // might have changed without proper persistence in the database. // That's the case when the user has been changed by a form with // validation errors. if (!$id = $this->getClassMetadata()->getIdentifierValues($user)) { throw new \InvalidArgumentException('You cannot refresh a user '. 'from the EntityUserProvider that does not contain an identifier. '. 'The user object has to be serialized with its own identifier '. 'mapped by Doctrine.' ); } $refreshedUser = $repository->find($id); if (null === $refreshedUser) { throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($id))); } } return $refreshedUser; } /** * {@inheritdoc} */ public function supportsClass($class) { return $class === $this->getClass() || is_subclass_of($class, $this->getClass()); } private function getObjectManager() { return $this->registry->getManager($this->managerName); } private function getRepository() { return $this->getObjectManager()->getRepository($this->classOrAlias); } private function getClass() { if (null === $this->class) { $class = $this->classOrAlias; if (false !== strpos($class, ':')) { $class = $this->getClassMetadata()->getName(); } $this->class = $class; } return $this->class; } private function getClassMetadata() { return $this->getObjectManager()->getClassMetadata($this->classOrAlias); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Security/User/UserLoaderInterface.php000066400000000000000000000021031324732107100275460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Security\User; use Symfony\Component\Security\Core\User\UserInterface; /** * Represents a class that loads UserInterface objects from Doctrine source for the authentication system. * * This interface is meant to facilitate the loading of a User from Doctrine source using a custom method. * If you want to implement your own logic of retrieving the user from Doctrine your repository should implement this * interface. * * @see UserInterface * * @author Michal Trojanowski */ interface UserLoaderInterface { /** * Loads the user for the given username. * * This method must return null if the user is not found. * * @param string $username The username * * @return UserInterface|null */ public function loadUserByUsername($username); } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Test/000077500000000000000000000000001324732107100213455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php000066400000000000000000000037671324732107100256420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Test; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Cache\ArrayCache; use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\EntityManager; use PHPUnit\Framework\TestCase; /** * Provides utility functions needed in tests. * * @author Bernhard Schussek */ class DoctrineTestHelper { /** * Returns an entity manager for testing. * * @param Configuration|null $config * * @return EntityManager */ public static function createTestEntityManager(Configuration $config = null) { if (!extension_loaded('pdo_sqlite')) { TestCase::markTestSkipped('Extension pdo_sqlite is required.'); } if (null === $config) { $config = self::createTestConfiguration(); } $params = array( 'driver' => 'pdo_sqlite', 'memory' => true, ); return EntityManager::create($params, $config); } /** * @return Configuration */ public static function createTestConfiguration() { $config = new Configuration(); $config->setEntityNamespaces(array('SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures')); $config->setAutoGenerateProxyClasses(true); $config->setProxyDir(\sys_get_temp_dir()); $config->setProxyNamespace('SymfonyTests\Doctrine'); $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader())); $config->setQueryCacheImpl(new ArrayCache()); $config->setMetadataCacheImpl(new ArrayCache()); return $config; } /** * This class cannot be instantiated. */ private function __construct() { } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php000066400000000000000000000040351324732107100264270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Test; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Repository\RepositoryFactory; /** * @author Andreas Braun */ final class TestRepositoryFactory implements RepositoryFactory { /** * @var ObjectRepository[] */ private $repositoryList = array(); /** * {@inheritdoc} */ public function getRepository(EntityManagerInterface $entityManager, $entityName) { $repositoryHash = $this->getRepositoryHash($entityManager, $entityName); if (isset($this->repositoryList[$repositoryHash])) { return $this->repositoryList[$repositoryHash]; } return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName); } public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository) { $repositoryHash = $this->getRepositoryHash($entityManager, $entityName); $this->repositoryList[$repositoryHash] = $repository; } /** * @return ObjectRepository */ private function createRepository(EntityManagerInterface $entityManager, $entityName) { /* @var $metadata ClassMetadata */ $metadata = $entityManager->getClassMetadata($entityName); $repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName(); return new $repositoryClassName($entityManager, $metadata); } private function getRepositoryHash(EntityManagerInterface $entityManager, $entityName) { return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/000077500000000000000000000000001324732107100215305ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php000066400000000000000000000035721324732107100303070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\ContainerAwareEventManager; use Symfony\Component\DependencyInjection\Container; class ContainerAwareEventManagerTest extends TestCase { private $container; private $evm; protected function setUp() { $this->container = new Container(); $this->evm = new ContainerAwareEventManager($this->container); } public function testDispatchEvent() { $this->container->set('foobar', $listener1 = new MyListener()); $this->evm->addEventListener('foo', 'foobar'); $this->evm->addEventListener('foo', $listener2 = new MyListener()); $this->evm->dispatchEvent('foo'); $this->assertTrue($listener1->called); $this->assertTrue($listener2->called); } public function testRemoveEventListener() { $this->evm->addEventListener('foo', 'bar'); $this->evm->addEventListener('foo', $listener = new MyListener()); $listeners = array('foo' => array('_service_bar' => 'bar', spl_object_hash($listener) => $listener)); $this->assertSame($listeners, $this->evm->getListeners()); $this->assertSame($listeners['foo'], $this->evm->getListeners('foo')); $this->evm->removeEventListener('foo', $listener); $this->assertSame(array('_service_bar' => 'bar'), $this->evm->getListeners('foo')); $this->evm->removeEventListener('foo', 'bar'); $this->assertSame(array(), $this->evm->getListeners('foo')); } } class MyListener { public $called = false; public function foo() { $this->called = true; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DataCollector/000077500000000000000000000000001324732107100242505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php000066400000000000000000000160061324732107100320340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\DataCollector; use Doctrine\DBAL\Platforms\MySqlPlatform; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class DoctrineDataCollectorTest extends TestCase { public function testCollectConnections() { $c = $this->createCollector(array()); $c->collect(new Request(), new Response()); $this->assertEquals(array('default' => 'doctrine.dbal.default_connection'), $c->getConnections()); } public function testCollectManagers() { $c = $this->createCollector(array()); $c->collect(new Request(), new Response()); $this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $c->getManagers()); } public function testCollectQueryCount() { $c = $this->createCollector(array()); $c->collect(new Request(), new Response()); $this->assertEquals(0, $c->getQueryCount()); $queries = array( array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 0), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $this->assertEquals(1, $c->getQueryCount()); } public function testCollectTime() { $c = $this->createCollector(array()); $c->collect(new Request(), new Response()); $this->assertEquals(0, $c->getTime()); $queries = array( array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $this->assertEquals(1, $c->getTime()); $queries = array( array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1), array('sql' => 'SELECT * FROM table2', 'params' => array(), 'types' => array(), 'executionMS' => 2), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $this->assertEquals(3, $c->getTime()); } /** * @dataProvider paramProvider */ public function testCollectQueries($param, $types, $expected, $explainable) { $queries = array( array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $collectedQueries = $c->getQueries(); $this->assertEquals($expected, $collectedQueries['default'][0]['params'][0]); $this->assertEquals($explainable, $collectedQueries['default'][0]['explainable']); } public function testCollectQueryWithNoParams() { $queries = array( array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1), array('sql' => 'SELECT * FROM table1', 'params' => null, 'types' => null, 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $collectedQueries = $c->getQueries(); $this->assertEquals(array(), $collectedQueries['default'][0]['params']); $this->assertTrue($collectedQueries['default'][0]['explainable']); $this->assertEquals(array(), $collectedQueries['default'][1]['params']); $this->assertTrue($collectedQueries['default'][1]['explainable']); } public function testReset() { $queries = array( array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $c->reset(); $c->collect(new Request(), new Response()); $this->assertEquals(array('default' => array()), $c->getQueries()); } /** * @dataProvider paramProvider */ public function testSerialization($param, $types, $expected, $explainable) { $queries = array( array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); $c = unserialize(serialize($c)); $collectedQueries = $c->getQueries(); $this->assertEquals($expected, $collectedQueries['default'][0]['params'][0]); $this->assertEquals($explainable, $collectedQueries['default'][0]['explainable']); } public function paramProvider() { return array( array('some value', array(), 'some value', true), array(1, array(), 1, true), array(true, array(), true, true), array(null, array(), null, true), array(new \DateTime('2011-09-11'), array('date'), '2011-09-11', true), array(fopen(__FILE__, 'r'), array(), 'Resource(stream)', false), array(new \stdClass(), array(), 'Object(stdClass)', false), array( new StringRepresentableClass(), array(), 'Object(Symfony\Bridge\Doctrine\Tests\DataCollector\StringRepresentableClass): "string representation"', false, ), ); } private function createCollector($queries) { $connection = $this->getMockBuilder('Doctrine\DBAL\Connection') ->disableOriginalConstructor() ->getMock(); $connection->expects($this->any()) ->method('getDatabasePlatform') ->will($this->returnValue(new MySqlPlatform())); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry ->expects($this->any()) ->method('getConnectionNames') ->will($this->returnValue(array('default' => 'doctrine.dbal.default_connection'))); $registry ->expects($this->any()) ->method('getManagerNames') ->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager'))); $registry->expects($this->any()) ->method('getConnection') ->will($this->returnValue($connection)); $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); $logger->queries = $queries; $collector = new DoctrineDataCollector($registry); $collector->addLogger('default', $logger); return $collector; } } class StringRepresentableClass { public function __toString() { return 'string representation'; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/000077500000000000000000000000001324732107100241335ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php000066400000000000000000000016131324732107100315360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\DataFixtures; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; use Symfony\Bridge\Doctrine\Tests\Fixtures\ContainerAwareFixture; class ContainerAwareLoaderTest extends TestCase { public function testShouldSetContainerOnContainerAwareFixture() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $loader = new ContainerAwareLoader($container); $fixture = new ContainerAwareFixture(); $loader->addFixture($fixture); $this->assertSame($container, $fixture->container); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/000077500000000000000000000000001324732107100254515ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/000077500000000000000000000000001324732107100300525ustar00rootroot00000000000000RegisterEventListenersAndSubscribersPassTest.php000066400000000000000000000146151324732107100415130ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\CompilerPass; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; class RegisterEventListenersAndSubscribersPassTest extends TestCase { /** * @expectedException \InvalidArgumentException */ public function testExceptionOnAbstractTaggedSubscriber() { $container = $this->createBuilder(); $abstractDefinition = new Definition('stdClass'); $abstractDefinition->setAbstract(true); $abstractDefinition->addTag('doctrine.event_subscriber'); $container->setDefinition('a', $abstractDefinition); $this->process($container); } /** * @expectedException \InvalidArgumentException */ public function testExceptionOnAbstractTaggedListener() { $container = $this->createBuilder(); $abstractDefinition = new Definition('stdClass'); $abstractDefinition->setAbstract(true); $abstractDefinition->addTag('doctrine.event_listener', array('event' => 'test')); $container->setDefinition('a', $abstractDefinition); $this->process($container); } public function testProcessEventListenersWithPriorities() { $container = $this->createBuilder(); $container ->register('a', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'foo', 'priority' => -5, )) ->addTag('doctrine.event_listener', array( 'event' => 'bar', )) ; $container ->register('b', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'foo', )) ; $this->process($container); $this->assertEquals(array('b', 'a'), $this->getServiceOrder($container, 'addEventListener')); $calls = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls(); $this->assertEquals(array('foo', 'bar'), $calls[1][1][0]); } public function testProcessEventListenersWithMultipleConnections() { $container = $this->createBuilder(true); $container ->register('a', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'onFlush', )) ; $this->process($container); $callsDefault = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls(); $this->assertEquals('addEventListener', $callsDefault[0][0]); $this->assertEquals(array('onFlush'), $callsDefault[0][1][0]); $callsSecond = $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls(); $this->assertEquals($callsDefault, $callsSecond); } public function testProcessEventSubscribersWithPriorities() { $container = $this->createBuilder(); $container ->register('a', 'stdClass') ->addTag('doctrine.event_subscriber') ; $container ->register('b', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 5, )) ; $container ->register('c', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $container ->register('d', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $container ->register('e', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $this->process($container); $serviceOrder = $this->getServiceOrder($container, 'addEventSubscriber'); $unordered = array_splice($serviceOrder, 0, 3); sort($unordered); $this->assertEquals(array('c', 'd', 'e'), $unordered); $this->assertEquals(array('b', 'a'), $serviceOrder); } public function testProcessNoTaggedServices() { $container = $this->createBuilder(true); $this->process($container); $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()); $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()); } private function process(ContainerBuilder $container) { $pass = new RegisterEventListenersAndSubscribersPass('doctrine.connections', 'doctrine.dbal.%s_connection.event_manager', 'doctrine'); $pass->process($container); } private function getServiceOrder(ContainerBuilder $container, $method) { $order = array(); foreach ($container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() as list($name, $arguments)) { if ($method !== $name) { continue; } if ('addEventListener' === $name) { $order[] = (string) $arguments[1]; continue; } $order[] = (string) $arguments[0]; } return $order; } private function createBuilder($multipleConnections = false) { $container = new ContainerBuilder(); $connections = array('default' => 'doctrine.dbal.default_connection'); $container->register('doctrine.dbal.default_connection.event_manager', 'stdClass'); $container->register('doctrine.dbal.default_connection', 'stdClass'); if ($multipleConnections) { $container->register('doctrine.dbal.second_connection.event_manager', 'stdClass'); $container->register('doctrine.dbal.second_connection', 'stdClass'); $connections['second'] = 'doctrine.dbal.second_connection'; } $container->setParameter('doctrine.connections', $connections); return $container; } } RegisterMappingsPassTest.php000066400000000000000000000024731324732107100354640ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPasscreateBuilder(); $this->process($container, array( 'manager.param.one', 'manager.param.two', )); } private function process(ContainerBuilder $container, array $managerParamNames) { $pass = new ConcreteMappingsPass( new Definition('\stdClass'), array(), $managerParamNames, 'some.%s.metadata_driver' ); $pass->process($container); } private function createBuilder() { $container = new ContainerBuilder(); return $container; } } class ConcreteMappingsPass extends RegisterMappingsPass { } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php000066400000000000000000000226451324732107100324770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** * @author Fabio B. Silva */ class DoctrineExtensionTest extends TestCase { /** * @var \Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension */ private $extension; protected function setUp() { parent::setUp(); $this->extension = $this ->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension') ->setMethods(array( 'getMappingResourceConfigDirectory', 'getObjectManagerElementName', 'getMappingObjectDefaultName', 'getMappingResourceExtension', 'load', )) ->getMock() ; $this->extension->expects($this->any()) ->method('getObjectManagerElementName') ->will($this->returnCallback(function ($name) { return 'doctrine.orm.'.$name; })); } /** * @expectedException \LogicException */ public function testFixManagersAutoMappingsWithTwoAutomappings() { $emConfigs = array( 'em1' => array( 'auto_mapping' => true, ), 'em2' => array( 'auto_mapping' => true, ), ); $bundles = array( 'FristBundle' => 'My\FristBundle', 'SecondBundle' => 'My\SecondBundle', ); $reflection = new \ReflectionClass(get_class($this->extension)); $method = $reflection->getMethod('fixManagersAutoMappings'); $method->setAccessible(true); $method->invoke($this->extension, $emConfigs, $bundles); } public function getAutomappingData() { return array( array( array( // no auto mapping on em1 'auto_mapping' => false, ), array( // no auto mapping on em2 'auto_mapping' => false, ), array(), array(), ), array( array( // no auto mapping on em1 'auto_mapping' => false, ), array( // auto mapping enabled on em2 'auto_mapping' => true, ), array(), array( 'mappings' => array( 'FristBundle' => array( 'mapping' => true, 'is_bundle' => true, ), 'SecondBundle' => array( 'mapping' => true, 'is_bundle' => true, ), ), ), ), array( array( // no auto mapping on em1, but it defines SecondBundle as own 'auto_mapping' => false, 'mappings' => array( 'SecondBundle' => array( 'mapping' => true, 'is_bundle' => true, ), ), ), array( // auto mapping enabled on em2 'auto_mapping' => true, ), array( 'mappings' => array( 'SecondBundle' => array( 'mapping' => true, 'is_bundle' => true, ), ), ), array( 'mappings' => array( 'FristBundle' => array( 'mapping' => true, 'is_bundle' => true, ), ), ), ), ); } /** * @dataProvider getAutomappingData */ public function testFixManagersAutoMappings(array $originalEm1, array $originalEm2, array $expectedEm1, array $expectedEm2) { $emConfigs = array( 'em1' => $originalEm1, 'em2' => $originalEm2, ); $bundles = array( 'FristBundle' => 'My\FristBundle', 'SecondBundle' => 'My\SecondBundle', ); $reflection = new \ReflectionClass(get_class($this->extension)); $method = $reflection->getMethod('fixManagersAutoMappings'); $method->setAccessible(true); $newEmConfigs = $method->invoke($this->extension, $emConfigs, $bundles); $this->assertEquals($newEmConfigs['em1'], array_merge(array( 'auto_mapping' => false, ), $expectedEm1)); $this->assertEquals($newEmConfigs['em2'], array_merge(array( 'auto_mapping' => false, ), $expectedEm2)); } public function providerBasicDrivers() { return array( array('doctrine.orm.cache.apc.class', array('type' => 'apc')), array('doctrine.orm.cache.apcu.class', array('type' => 'apcu')), array('doctrine.orm.cache.array.class', array('type' => 'array')), array('doctrine.orm.cache.xcache.class', array('type' => 'xcache')), array('doctrine.orm.cache.wincache.class', array('type' => 'wincache')), array('doctrine.orm.cache.zenddata.class', array('type' => 'zenddata')), array('doctrine.orm.cache.redis.class', array('type' => 'redis'), array('setRedis')), array('doctrine.orm.cache.memcache.class', array('type' => 'memcache'), array('setMemcache')), array('doctrine.orm.cache.memcached.class', array('type' => 'memcached'), array('setMemcached')), ); } /** * @param string $class * @param array $config * * @dataProvider providerBasicDrivers */ public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array()) { $container = $this->createContainer(); $cacheName = 'metadata_cache'; $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => $config, ); $this->invokeLoadCacheDriver($objectManager, $container, $cacheName); $this->assertTrue($container->hasDefinition('doctrine.orm.default_metadata_cache')); $definition = $container->getDefinition('doctrine.orm.default_metadata_cache'); $defCalls = $definition->getMethodCalls(); $expectedCalls[] = 'setNamespace'; $actualCalls = array_map(function ($call) { return $call[0]; }, $defCalls); $this->assertFalse($definition->isPublic()); $this->assertEquals("%$class%", $definition->getClass()); foreach (array_unique($expectedCalls) as $call) { $this->assertContains($call, $actualCalls); } } public function testServiceCacheDriver() { $cacheName = 'metadata_cache'; $container = $this->createContainer(); $definition = new Definition('%doctrine.orm.cache.apc.class%'); $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => array( 'type' => 'service', 'id' => 'service_driver', ), ); $container->setDefinition('service_driver', $definition); $this->invokeLoadCacheDriver($objectManager, $container, $cacheName); $this->assertTrue($container->hasAlias('doctrine.orm.default_metadata_cache')); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage "unrecognized_type" is an unrecognized Doctrine cache driver. */ public function testUnrecognizedCacheDriverException() { $cacheName = 'metadata_cache'; $container = $this->createContainer(); $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => array( 'type' => 'unrecognized_type', ), ); $this->invokeLoadCacheDriver($objectManager, $container, $cacheName); } protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder $container, $cacheName) { $method = new \ReflectionMethod($this->extension, 'loadObjectManagerCacheDriver'); $method->setAccessible(true); $method->invokeArgs($this->extension, array($objectManager, $container, $cacheName)); } /** * @return \Symfony\Component\DependencyInjection\ContainerBuilder */ protected function createContainer(array $data = array()) { return new ContainerBuilder(new ParameterBag(array_merge(array( 'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'), 'kernel.cache_dir' => __DIR__, 'kernel.debug' => false, 'kernel.environment' => 'test', 'kernel.name' => 'kernel', 'kernel.root_dir' => __DIR__, ), $data))); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/000077500000000000000000000000001324732107100253335ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php000066400000000000000000000035061324732107100325600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\ExpressionLanguage; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\ExpressionLanguage\DoctrineParserCache; /** * @group legacy */ class DoctrineParserCacheTest extends TestCase { public function testFetch() { $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); $parserCache = new DoctrineParserCache($doctrineCacheMock); $doctrineCacheMock->expects($this->once()) ->method('fetch') ->will($this->returnValue('bar')); $result = $parserCache->fetch('foo'); $this->assertEquals('bar', $result); } public function testFetchUnexisting() { $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); $parserCache = new DoctrineParserCache($doctrineCacheMock); $doctrineCacheMock ->expects($this->once()) ->method('fetch') ->will($this->returnValue(false)); $this->assertNull($parserCache->fetch('')); } public function testSave() { $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); $parserCache = new DoctrineParserCache($doctrineCacheMock); $expression = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParsedExpression') ->disableOriginalConstructor() ->getMock(); $doctrineCacheMock->expects($this->once()) ->method('save') ->with('foo', $expression); $parserCache->save('foo', $expression); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/000077500000000000000000000000001324732107100233415ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/AssociationEntity.php000066400000000000000000000020031324732107100275160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class AssociationEntity { /** * @var int * @ORM\Id @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity="SingleIntIdEntity") * * @var \Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity */ public $single; /** * @ORM\ManyToOne(targetEntity="CompositeIntIdEntity") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="composite_id1", referencedColumnName="id1"), * @ORM\JoinColumn(name="composite_id2", referencedColumnName="id2") * }) * * @var \Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity */ public $composite; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/AssociationEntity2.php000066400000000000000000000020301324732107100276000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class AssociationEntity2 { /** * @var int * @ORM\Id @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity="SingleIntIdNoToStringEntity") * * @var \Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity */ public $single; /** * @ORM\ManyToOne(targetEntity="CompositeIntIdEntity") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="composite_id1", referencedColumnName="id1"), * @ORM\JoinColumn(name="composite_id2", referencedColumnName="id2") * }) * * @var \Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity */ public $composite; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php000066400000000000000000000014701324732107100301430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class CompositeIntIdEntity { /** @Id @Column(type="integer") */ protected $id1; /** @Id @Column(type="integer") */ protected $id2; /** @Column(type="string") */ public $name; public function __construct($id1, $id2, $name) { $this->id1 = $id1; $this->id2 = $id2; $this->name = $name; } public function __toString() { return $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php000066400000000000000000000022611324732107100326050ustar00rootroot00000000000000objectOne = $objectOne; $this->objectTwo = $objectTwo; } /** * @return SingleIntIdNoToStringEntity */ public function getObjectOne() { return $this->objectOne; } /** * @return SingleIntIdNoToStringEntity */ public function getObjectTwo() { return $this->objectTwo; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php000066400000000000000000000014711324732107100306600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class CompositeStringIdEntity { /** @Id @Column(type="string") */ protected $id1; /** @Id @Column(type="string") */ protected $id2; /** @Column(type="string") */ public $name; public function __construct($id1, $id2, $name) { $this->id1 = $id1; $this->id2 = $id2; $this->name = $name; } public function __toString() { return $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php000066400000000000000000000014521324732107100303250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface { public $container; public function setContainer(ContainerInterface $container = null) { $this->container = $container; } public function load(ObjectManager $manager) { } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNameEntity.php000066400000000000000000000013651324732107100272670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class DoubleNameEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string") */ public $name; /** @Column(type="string", nullable=true) */ public $name2; public function __construct($id, $name, $name2) { $this->id = $id; $this->name = $name; $this->name2 = $name2; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNullableNameEntity.php000066400000000000000000000014141324732107100307410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class DoubleNullableNameEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string", nullable=true) */ public $name; /** @Column(type="string", nullable=true) */ public $name2; public function __construct($id, $name, $name2) { $this->id = $id; $this->name = $name; $this->name2 = $name2; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Embeddable/000077500000000000000000000000001324732107100253455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Embeddable/Identifier.php000066400000000000000000000007551324732107100301470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures\Embeddable; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Embeddable */ class Identifier { /** * @var int * * @ORM\Id * @ORM\Column(type="integer") */ protected $value; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/EmbeddedIdentifierEntity.php000066400000000000000000000010441324732107100307420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class EmbeddedIdentifierEntity { /** * @var Embeddable\Identifier * * @ORM\Embedded(class="Symfony\Bridge\Doctrine\Tests\Fixtures\Embeddable\Identifier") */ protected $id; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Employee.php000066400000000000000000000005641324732107100256360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class Employee extends Person { } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GroupableEntity.php000066400000000000000000000014231324732107100271670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class GroupableEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string", nullable=true) */ public $name; /** @Column(type="string", nullable=true) */ public $groupName; public function __construct($id, $name, $groupName) { $this->id = $id; $this->name = $name; $this->groupName = $groupName; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GuidIdEntity.php000066400000000000000000000010511324732107100264110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class GuidIdEntity { /** @Id @Column(type="guid") */ protected $id; public function __construct($id) { $this->id = $id; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php000066400000000000000000000017671324732107100253330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\InheritanceType; /** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"}) */ class Person { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string") */ public $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } public function __toString() { return (string) $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php000066400000000000000000000015671324732107100321310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\OneToOne; /** @Entity */ class SingleAssociationToIntIdEntity { /** @Id @OneToOne(targetEntity="SingleIntIdNoToStringEntity", cascade={"ALL"}) */ protected $entity; /** @Column(type="string", nullable=true) */ public $name; public function __construct(SingleIntIdNoToStringEntity $entity, $name) { $this->entity = $entity; $this->name = $name; } public function __toString() { return (string) $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php000066400000000000000000000015011324732107100274150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class SingleIntIdEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string", nullable=true) */ public $name; /** @Column(type="array", nullable=true) */ public $phoneNumbers = array(); public function __construct($id, $name) { $this->id = $id; $this->name = $name; } public function __toString() { return (string) $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdNoToStringEntity.php000066400000000000000000000012431324732107100314070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class SingleIntIdNoToStringEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string", nullable=true) */ public $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdStringWrapperNameEntity.php000066400000000000000000000013611324732107100327520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper; /** @Entity */ class SingleIntIdStringWrapperNameEntity { /** @Id @Column(type="integer") */ protected $id; /** @Column(type="string_wrapper", nullable=true) */ public $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringCastableIdEntity.php000066400000000000000000000021231324732107100315710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; /** @Entity */ class SingleStringCastableIdEntity { /** * @Id * @Column(type="string") * @GeneratedValue(strategy="NONE") */ protected $id; /** @Column(type="string", nullable=true) */ public $name; public function __construct($id, $name) { $this->id = new StringCastableObjectIdentity($id); $this->name = $name; } public function __toString() { return (string) $this->name; } } class StringCastableObjectIdentity { protected $id; public function __construct($id) { $this->id = $id; } public function __toString() { return (string) $this->id; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php000066400000000000000000000013261324732107100301360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class SingleStringIdEntity { /** @Id @Column(type="string") */ protected $id; /** @Column(type="string") */ public $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } public function __toString() { return $this->name; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/000077500000000000000000000000001324732107100242625ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php000066400000000000000000000011171324732107100276020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures\Type; class StringWrapper { private $string; /** * @param string $string */ public function __construct($string = null) { $this->string = $string; } /** * @return string */ public function getString() { return $this->string; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php000066400000000000000000000016141324732107100304460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures\Type; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\StringType; class StringWrapperType extends StringType { /** * {@inheritdoc} */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return $value instanceof StringWrapper ? $value->getString() : null; } /** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { return new StringWrapper($value); } /** * {@inheritdoc} */ public function getName() { return 'string_wrapper'; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php000066400000000000000000000021611324732107100247700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Symfony\Component\Security\Core\User\UserInterface; /** @Entity */ class User implements UserInterface { /** @Id @Column(type="integer") */ protected $id1; /** @Id @Column(type="integer") */ protected $id2; /** @Column(type="string") */ public $name; public function __construct($id1, $id2, $name) { $this->id1 = $id1; $this->id2 = $id2; $this->name = $name; } public function getRoles() { } public function getPassword() { } public function getSalt() { } public function getUsername() { return $this->name; } public function eraseCredentials() { } public function equals(UserInterface $user) { } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UuidIdEntity.php000066400000000000000000000010511324732107100264270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; /** @Entity */ class UuidIdEntity { /** @Id @Column(type="uuid") */ protected $id; public function __construct($id) { $this->id = $id; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/000077500000000000000000000000001324732107100224335ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/000077500000000000000000000000001324732107100244615ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php000066400000000000000000000304031324732107100320430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\ORM\Mapping\ClassMetadata; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader; use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface; use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; /** * @author Bernhard Schussek */ class DoctrineChoiceLoaderTest extends TestCase { /** * @var ChoiceListFactoryInterface|\PHPUnit_Framework_MockObject_MockObject */ private $factory; /** * @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ private $om; /** * @var ObjectRepository|\PHPUnit_Framework_MockObject_MockObject */ private $repository; /** * @var string */ private $class; /** * @var IdReader|\PHPUnit_Framework_MockObject_MockObject */ private $idReader; /** * @var EntityLoaderInterface|\PHPUnit_Framework_MockObject_MockObject */ private $objectLoader; /** * @var \stdClass */ private $obj1; /** * @var \stdClass */ private $obj2; /** * @var \stdClass */ private $obj3; protected function setUp() { $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); $this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); $this->repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock(); $this->class = 'stdClass'; $this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader') ->disableOriginalConstructor() ->getMock(); $this->objectLoader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface')->getMock(); $this->obj1 = (object) array('name' => 'A'); $this->obj2 = (object) array('name' => 'B'); $this->obj3 = (object) array('name' => 'C'); $this->om->expects($this->any()) ->method('getRepository') ->with($this->class) ->willReturn($this->repository); $this->om->expects($this->any()) ->method('getClassMetadata') ->with($this->class) ->willReturn(new ClassMetadata($this->class)); } public function testLoadChoiceList() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $value = function () {}; $choiceList = new ArrayChoiceList($choices, $value); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $this->assertEquals($choiceList, $loader->loadChoiceList($value)); // no further loads on subsequent calls $this->assertEquals($choiceList, $loader->loadChoiceList($value)); } /** * @group legacy */ public function testLegacyLoadChoiceList() { $factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); $loader = new DoctrineChoiceLoader( $factory, $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $value = function () {}; $choiceList = new ArrayChoiceList($choices, $value); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $factory->expects($this->never()) ->method('createListFromChoices'); $this->assertEquals($choiceList, $loaded = $loader->loadChoiceList($value)); // no further loads on subsequent calls $this->assertSame($loaded, $loader->loadChoiceList($value)); } public function testLoadChoiceListUsesObjectLoaderIfAvailable() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader, $this->objectLoader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $choiceList = new ArrayChoiceList($choices); $this->repository->expects($this->never()) ->method('findAll'); $this->objectLoader->expects($this->once()) ->method('getEntities') ->willReturn($choices); $this->assertEquals($choiceList, $loaded = $loader->loadChoiceList()); // no further loads on subsequent calls $this->assertSame($loaded, $loader->loadChoiceList()); } public function testLoadValuesForChoices() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $this->assertSame(array('1', '2'), $loader->loadValuesForChoices(array($this->obj2, $this->obj3))); // no further loads on subsequent calls $this->assertSame(array('1', '2'), $loader->loadValuesForChoices(array($this->obj2, $this->obj3))); } public function testLoadValuesForChoicesDoesNotLoadIfEmptyChoices() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $this->repository->expects($this->never()) ->method('findAll'); $this->assertSame(array(), $loader->loadValuesForChoices(array())); } public function testLoadValuesForChoicesDoesNotLoadIfSingleIntId() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->repository->expects($this->never()) ->method('findAll'); $this->idReader->expects($this->any()) ->method('getIdValue') ->with($this->obj2) ->willReturn('2'); $this->assertSame(array('2'), $loader->loadValuesForChoices(array($this->obj2))); } public function testLoadValuesForChoicesLoadsIfSingleIntIdAndValueGiven() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $value = function (\stdClass $object) { return $object->name; }; $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $this->assertSame(array('B'), $loader->loadValuesForChoices( array($this->obj2), $value )); } public function testLoadValuesForChoicesDoesNotLoadIfValueIsIdReader() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $value = array($this->idReader, 'getIdValue'); $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->repository->expects($this->never()) ->method('findAll'); $this->idReader->expects($this->any()) ->method('getIdValue') ->with($this->obj2) ->willReturn('2'); $this->assertSame(array('2'), $loader->loadValuesForChoices( array($this->obj2), $value )); } public function testLoadChoicesForValues() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $this->assertSame(array($this->obj2, $this->obj3), $loader->loadChoicesForValues(array('1', '2'))); // no further loads on subsequent calls $this->assertSame(array($this->obj2, $this->obj3), $loader->loadChoicesForValues(array('1', '2'))); } public function testLoadChoicesForValuesDoesNotLoadIfEmptyValues() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $this->repository->expects($this->never()) ->method('findAll'); $this->assertSame(array(), $loader->loadChoicesForValues(array())); } public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader, $this->objectLoader ); $choices = array($this->obj2, $this->obj3); $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->idReader->expects($this->any()) ->method('getIdField') ->willReturn('idField'); $this->repository->expects($this->never()) ->method('findAll'); $this->objectLoader->expects($this->once()) ->method('getEntitiesByIds') ->with('idField', array(4 => '3', 7 => '2')) ->willReturn($choices); $this->idReader->expects($this->any()) ->method('getIdValue') ->willReturnMap(array( array($this->obj2, '2'), array($this->obj3, '3'), )); $this->assertSame( array(4 => $this->obj3, 7 => $this->obj2), $loader->loadChoicesForValues(array(4 => '3', 7 => '2') )); } public function testLoadChoicesForValuesLoadsAllIfSingleIntIdAndValueGiven() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader ); $choices = array($this->obj1, $this->obj2, $this->obj3); $value = function (\stdClass $object) { return $object->name; }; $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->repository->expects($this->once()) ->method('findAll') ->willReturn($choices); $this->assertSame(array($this->obj2), $loader->loadChoicesForValues( array('B'), $value )); } public function testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader() { $loader = new DoctrineChoiceLoader( $this->om, $this->class, $this->idReader, $this->objectLoader ); $choices = array($this->obj2, $this->obj3); $value = array($this->idReader, 'getIdValue'); $this->idReader->expects($this->any()) ->method('isSingleId') ->willReturn(true); $this->idReader->expects($this->any()) ->method('getIdField') ->willReturn('idField'); $this->repository->expects($this->never()) ->method('findAll'); $this->objectLoader->expects($this->once()) ->method('getEntitiesByIds') ->with('idField', array('2')) ->willReturn($choices); $this->idReader->expects($this->any()) ->method('getIdValue') ->willReturnMap(array( array($this->obj2, '2'), array($this->obj3, '3'), )); $this->assertSame(array($this->obj2), $loader->loadChoicesForValues(array('2'), $value)); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php000066400000000000000000000127171324732107100321630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Doctrine\DBAL\Connection; use Doctrine\ORM\Version; class ORMQueryBuilderLoaderTest extends TestCase { public function testIdentifierTypeIsStringArray() { $this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', Connection::PARAM_STR_ARRAY); } public function testIdentifierTypeIsIntegerArray() { $this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', Connection::PARAM_INT_ARRAY); } protected function checkIdentifierType($classname, $expectedType) { $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) ->getMock(); $query->expects($this->once()) ->method('setParameter') ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2), $expectedType) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') ->setConstructorArgs(array($em)) ->setMethods(array('getQuery')) ->getMock(); $qb->expects($this->once()) ->method('getQuery') ->willReturn($query); $qb->select('e') ->from($classname, 'e'); $loader = new ORMQueryBuilderLoader($qb); $loader->getEntitiesByIds('id', array(1, 2)); } public function testFilterNonIntegerValues() { $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) ->getMock(); $query->expects($this->once()) ->method('setParameter') ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2, 3, '9223372036854775808'), Connection::PARAM_INT_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') ->setConstructorArgs(array($em)) ->setMethods(array('getQuery')) ->getMock(); $qb->expects($this->once()) ->method('getQuery') ->willReturn($query); $qb->select('e') ->from('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', 'e'); $loader = new ORMQueryBuilderLoader($qb); $loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo', '9223372036854775808')); } /** * @dataProvider provideGuidEntityClasses */ public function testFilterEmptyUuids($entityClass) { $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) ->getMock(); $query->expects($this->once()) ->method('setParameter') ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'), Connection::PARAM_STR_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') ->setConstructorArgs(array($em)) ->setMethods(array('getQuery')) ->getMock(); $qb->expects($this->once()) ->method('getQuery') ->willReturn($query); $qb->select('e') ->from($entityClass, 'e'); $loader = new ORMQueryBuilderLoader($qb); $loader->getEntitiesByIds('id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499')); } public function testEmbeddedIdentifierName() { if (Version::compare('2.5.0') > 0) { $this->markTestSkipped('Applicable only for Doctrine >= 2.5.0'); return; } $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) ->getMock(); $query->expects($this->once()) ->method('setParameter') ->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') ->setConstructorArgs(array($em)) ->setMethods(array('getQuery')) ->getMock(); $qb->expects($this->once()) ->method('getQuery') ->willReturn($query); $qb->select('e') ->from('Symfony\Bridge\Doctrine\Tests\Fixtures\EmbeddedIdentifierEntity', 'e'); $loader = new ORMQueryBuilderLoader($qb); $loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo')); } public function provideGuidEntityClasses() { return array( array('Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'), array('Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'), ); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/000077500000000000000000000000001324732107100255275ustar00rootroot00000000000000CollectionToArrayTransformerTest.php000066400000000000000000000045171324732107100346500ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\DataTransformer; use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; /** * @author Bernhard Schussek */ class CollectionToArrayTransformerTest extends TestCase { /** * @var CollectionToArrayTransformer */ private $transformer; protected function setUp() { $this->transformer = new CollectionToArrayTransformer(); } public function testTransform() { $array = array( 2 => 'foo', 3 => 'bar', ); $this->assertSame($array, $this->transformer->transform(new ArrayCollection($array))); } /** * This test is needed for cases when getXxxs() in the entity returns the * result of $collection->toArray(), in order to prevent modifications of * the inner collection. * * See https://github.com/symfony/symfony/pull/9308 */ public function testTransformArray() { $array = array( 2 => 'foo', 3 => 'bar', ); $this->assertSame($array, $this->transformer->transform($array)); } public function testTransformNull() { $this->assertSame(array(), $this->transformer->transform(null)); } /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformExpectsArrayOrCollection() { $this->transformer->transform('Foo'); } public function testReverseTransform() { $array = array( 2 => 'foo', 3 => 'bar', ); $this->assertEquals(new ArrayCollection($array), $this->transformer->reverseTransform($array)); } public function testReverseTransformEmpty() { $this->assertEquals(new ArrayCollection(), $this->transformer->reverseTransform('')); } public function testReverseTransformNull() { $this->assertEquals(new ArrayCollection(), $this->transformer->reverseTransform(null)); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php000066400000000000000000000117271324732107100304410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\ValueGuess; class DoctrineOrmTypeGuesserTest extends TestCase { /** * @dataProvider requiredProvider */ public function testRequiredGuesser($classMetadata, $expected) { $this->assertEquals($expected, $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); } public function requiredProvider() { $return = array(); // Simple field, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); // Simple field, nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); $return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)); // One-to-one, nullable (by default) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array())); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)); // One-to-one, nullable (explicit) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array('nullable' => true))); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)); // One-to-one, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array('nullable' => false))); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); // One-to-many, no clue $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); $return[] = array($classMetadata, null); return $return; } private function getGuesser(ClassMetadata $classMetadata) { $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata)); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em))); return new DoctrineOrmTypeGuesser($registry); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/000077500000000000000000000000001324732107100252225ustar00rootroot00000000000000MergeDoctrineCollectionListenerTest.php000066400000000000000000000064321324732107100347720ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\EventListener; use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\EventListener\MergeDoctrineCollectionListener; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; class MergeDoctrineCollectionListenerTest extends TestCase { /** @var \Doctrine\Common\Collections\ArrayCollection */ private $collection; /** @var \Symfony\Component\EventDispatcher\EventDispatcher */ private $dispatcher; private $factory; private $form; protected function setUp() { $this->collection = new ArrayCollection(array('test')); $this->dispatcher = new EventDispatcher(); $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->form = $this->getBuilder() ->getForm(); } protected function tearDown() { $this->collection = null; $this->dispatcher = null; $this->factory = null; $this->form = null; } protected function getBuilder($name = 'name') { return new FormBuilder($name, null, $this->dispatcher, $this->factory); } protected function getForm($name = 'name') { return $this->getBuilder($name) ->setData($this->collection) ->addEventSubscriber(new MergeDoctrineCollectionListener()) ->getForm(); } public function testOnSubmitDoNothing() { $submittedData = array('test'); $event = new FormEvent($this->getForm(), $submittedData); $this->dispatcher->dispatch(FormEvents::SUBMIT, $event); $this->assertTrue($this->collection->contains('test')); $this->assertSame(1, $this->collection->count()); } public function testOnSubmitNullClearCollection() { $submittedData = array(); $event = new FormEvent($this->getForm(), $submittedData); $this->dispatcher->dispatch(FormEvents::SUBMIT, $event); $this->assertTrue($this->collection->isEmpty()); } /** * @group legacy */ public function testLegacyChildClassOnSubmitCallParent() { $form = $this->getBuilder('name') ->setData($this->collection) ->addEventSubscriber(new TestClassExtendingMergeDoctrineCollectionListener()) ->getForm(); $submittedData = array(); $event = new FormEvent($form, $submittedData); $this->dispatcher->dispatch(FormEvents::SUBMIT, $event); $this->assertTrue($this->collection->isEmpty()); $this->assertTrue(TestClassExtendingMergeDoctrineCollectionListener::$onBindCalled); } } /** * @group legacy */ class TestClassExtendingMergeDoctrineCollectionListener extends MergeDoctrineCollectionListener { public static $onBindCalled = false; public function onBind(FormEvent $event) { self::$onBindCalled = true; parent::onBind($event); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/Type/000077500000000000000000000000001324732107100233545ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php000066400000000000000000000074601324732107100312340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\Type; use Symfony\Component\Form\Test\FormPerformanceTestCase; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Doctrine\ORM\Tools\SchemaTool; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Component\Form\Extension\Core\CoreExtension; use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; /** * @author Bernhard Schussek */ class EntityTypePerformanceTest extends FormPerformanceTestCase { const ENTITY_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'; /** * @var \Doctrine\ORM\EntityManager */ private $em; protected function getExtensions() { $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $manager->expects($this->any()) ->method('getManager') ->will($this->returnValue($this->em)); $manager->expects($this->any()) ->method('getManagerForClass') ->will($this->returnValue($this->em)); return array( new CoreExtension(), new DoctrineOrmExtension($manager), ); } protected function setUp() { $this->em = DoctrineTestHelper::createTestEntityManager(); parent::setUp(); $schemaTool = new SchemaTool($this->em); $classes = array( $this->em->getClassMetadata(self::ENTITY_CLASS), ); try { $schemaTool->dropSchema($classes); } catch (\Exception $e) { } try { $schemaTool->createSchema($classes); } catch (\Exception $e) { } $ids = range(1, 300); foreach ($ids as $id) { $name = 65 + (int) chr($id % 57); $this->em->persist(new SingleIntIdEntity($id, $name)); } $this->em->flush(); } /** * This test case is realistic in collection forms where each * row contains the same entity field. * * @group benchmark */ public function testCollapsedEntityField() { $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( 'class' => self::ENTITY_CLASS, )); // force loading of the choice list $form->createView(); } } /** * @group benchmark */ public function testCollapsedEntityFieldWithChoices() { $choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult(); $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( 'class' => self::ENTITY_CLASS, 'choices' => $choices, )); // force loading of the choice list $form->createView(); } } /** * @group benchmark */ public function testCollapsedEntityFieldWithPreferredChoices() { $choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult(); $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( 'class' => self::ENTITY_CLASS, 'preferred_choices' => $choices, )); // force loading of the choice list $form->createView(); } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php000066400000000000000000001526711324732107100270570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Form\Type; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Tools\SchemaTool; use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeStringIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\Forms; use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest; use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleAssociationToIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; class EntityTypeTest extends BaseTypeTest { const TESTED_TYPE = 'Symfony\Bridge\Doctrine\Form\Type\EntityType'; const ITEM_GROUP_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity'; const SINGLE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'; const SINGLE_IDENT_NO_TO_STRING_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'; const SINGLE_STRING_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity'; const SINGLE_ASSOC_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleAssociationToIntIdEntity'; const SINGLE_STRING_CASTABLE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity'; const COMPOSITE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'; const COMPOSITE_STRING_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeStringIdEntity'; /** * @var EntityManager */ private $em; /** * @var \PHPUnit_Framework_MockObject_MockObject|ManagerRegistry */ private $emRegistry; protected function setUp() { $this->em = DoctrineTestHelper::createTestEntityManager(); $this->emRegistry = $this->createRegistryMock('default', $this->em); parent::setUp(); $schemaTool = new SchemaTool($this->em); $classes = array( $this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_NO_TO_STRING_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_ASSOC_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_CASTABLE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS), ); try { $schemaTool->dropSchema($classes); } catch (\Exception $e) { } try { $schemaTool->createSchema($classes); } catch (\Exception $e) { } } protected function tearDown() { parent::tearDown(); $this->em = null; $this->emRegistry = null; } protected function getExtensions() { return array_merge(parent::getExtensions(), array( new DoctrineOrmExtension($this->emRegistry), )); } protected function persist(array $entities) { foreach ($entities as $entity) { $this->em->persist($entity); } $this->em->flush(); // no clear, because entities managed by the choice field must // be managed! } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException */ public function testClassOptionIsRequired() { $this->factory->createNamed('name', static::TESTED_TYPE); } /** * @expectedException \Symfony\Component\Form\Exception\RuntimeException */ public function testInvalidClassOption() { $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'class' => 'foo', )); } public function testSetDataToUninitializedEntityWithNonRequired() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', )); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); } public function testSetDataToUninitializedEntityWithNonRequiredToString() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, )) ->createView(); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $view->vars['choices']); } public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $qb = $this->em->createQueryBuilder()->select('e')->from(self::SINGLE_IDENT_CLASS, 'e'); $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', 'query_builder' => $qb, )) ->createView(); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $view->vars['choices']); } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure() { $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => new \stdClass(), )); } /** * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException */ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder() { $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function () { return new \stdClass(); }, )); $field->submit('2'); } public function testConfigureQueryBuilderWithClosureReturningNullUseDefault() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function () { return; }, )); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); } public function testSetDataSingleNull() { $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )); $field->setData(null); $this->assertNull($field->getData()); $this->assertSame('', $field->getViewData()); } public function testSetDataMultipleExpandedNull() { $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )); $field->setData(null); $this->assertNull($field->getData()); $this->assertSame(array(), $field->getViewData()); } public function testSetDataMultipleNonExpandedNull() { $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )); $field->setData(null); $this->assertNull($field->getData()); $this->assertSame(array(), $field->getViewData()); } public function testSubmitSingleNonExpandedSingleIdentifier() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('2'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('2', $field->getViewData()); } public function testSubmitSingleNonExpandedSingleAssocIdentifier() { $innerEntity1 = new SingleIntIdNoToStringEntity(1, 'InFoo'); $innerEntity2 = new SingleIntIdNoToStringEntity(2, 'InBar'); $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $this->persist(array($innerEntity1, $innerEntity2, $entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('2'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('2', $field->getViewData()); } public function testSubmitSingleNonExpandedCompositeIdentifier() { $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', )); // the collection key is used here $field->submit('1'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('1', $field->getViewData()); } public function testSubmitMultipleNonExpandedSingleIdentifier() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('1', '3')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertSame(array('1', '3'), $field->getViewData()); } public function testSubmitMultipleNonExpandedSingleAssocIdentifier() { $innerEntity1 = new SingleIntIdNoToStringEntity(1, 'InFoo'); $innerEntity2 = new SingleIntIdNoToStringEntity(2, 'InBar'); $innerEntity3 = new SingleIntIdNoToStringEntity(3, 'InBaz'); $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $entity3 = new SingleAssociationToIntIdEntity($innerEntity3, 'Baz'); $this->persist(array($innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('1', '3')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertSame(array('1', '3'), $field->getViewData()); } public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $existing = new ArrayCollection(array(0 => $entity2)); $field->setData($existing); $field->submit(array('1', '3')); // entry with index 0 ($entity2) was replaced $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); $this->assertSame(array('1', '3'), $field->getViewData()); } public function testSubmitMultipleNonExpandedCompositeIdentifier() { $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', )); // because of the composite key collection keys are used $field->submit(array('0', '2')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertSame(array('0', '2'), $field->getViewData()); } public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData() { $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', )); $existing = new ArrayCollection(array(0 => $entity2)); $field->setData($existing); $field->submit(array('0', '2')); // entry with index 0 ($entity2) was replaced $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); $this->assertSame(array('0', '2'), $field->getViewData()); } public function testSubmitSingleExpanded() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('2'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertFalse($field['1']->getData()); $this->assertTrue($field['2']->getData()); $this->assertNull($field['1']->getViewData()); $this->assertSame('2', $field['2']->getViewData()); } public function testSubmitMultipleExpanded() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Bar'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('1', '3')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertTrue($field['1']->getData()); $this->assertFalse($field['2']->getData()); $this->assertTrue($field['3']->getData()); $this->assertSame('1', $field['1']->getViewData()); $this->assertNull($field['2']->getViewData()); $this->assertSame('3', $field['3']->getViewData()); } public function testSubmitMultipleExpandedWithNegativeIntegerId() { $entity1 = new SingleIntIdEntity(-1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('-1')); $expected = new ArrayCollection(array($entity1)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertTrue($field['_1']->getData()); $this->assertFalse($field['2']->getData()); } public function testSubmitSingleNonExpandedStringCastableIdentifier() { $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('2'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('2', $field->getViewData()); } public function testSubmitSingleStringCastableIdentifierExpanded() { $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('2'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertFalse($field['0']->getData()); $this->assertTrue($field['1']->getData()); $this->assertNull($field['0']->getViewData()); $this->assertSame('2', $field['1']->getViewData()); } public function testSubmitMultipleNonExpandedStringCastableIdentifierForExistingData() { $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', )); $existing = new ArrayCollection(array(0 => $entity2)); $field->setData($existing); $field->submit(array('1', '3')); // entry with index 0 ($entity2) was replaced $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); $this->assertSame(array('1', '3'), $field->getViewData()); } public function testSubmitMultipleNonExpandedStringCastableIdentifier() { $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('1', '3')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertSame(array('1', '3'), $field->getViewData()); } public function testSubmitMultipleStringCastableIdentifierExpanded() { $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Bar'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit(array('1', '3')); $expected = new ArrayCollection(array($entity1, $entity3)); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); $this->assertTrue($field['0']->getData()); $this->assertFalse($field['1']->getData()); $this->assertTrue($field['2']->getData()); $this->assertSame('1', $field['0']->getViewData()); $this->assertNull($field['1']->getViewData()); $this->assertSame('3', $field['2']->getViewData()); } public function testOverrideChoices() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, // not all persisted entities should be displayed 'choices' => array($entity1, $entity2), 'choice_label' => 'name', )); $field->submit('2'); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('2', $field->getViewData()); } public function testOverrideChoicesValues() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', 'choice_value' => 'name', )); $field->submit('Bar'); $this->assertEquals(array('Foo' => new ChoiceView($entity1, 'Foo', 'Foo'), 'Bar' => new ChoiceView($entity2, 'Bar', 'Bar')), $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); $this->assertSame('Bar', $field->getViewData()); } public function testOverrideChoicesValuesWithCallable() { $entity1 = new GroupableEntity(1, 'Foo', 'BazGroup'); $entity2 = new GroupableEntity(2, 'Bar', 'BooGroup'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, 'choice_label' => 'name', 'choice_value' => function (GroupableEntity $entity = null) { if (null === $entity) { return ''; } return $entity->groupName.'/'.$entity->name; }, )); $field->submit('BooGroup/Bar'); $this->assertEquals(array( 'BazGroup/Foo' => new ChoiceView($entity1, 'BazGroup/Foo', 'Foo'), 'BooGroup/Bar' => new ChoiceView($entity2, 'BooGroup/Bar', 'Bar'), ), $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); $this->assertSame('BooGroup/Bar', $field->getViewData()); } public function testChoicesForValuesOptimization() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $this->persist(array($entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); $this->em->clear(); $field->submit(1); $unitOfWorkIdentityMap = $this->em->getUnitOfWork()->getIdentityMap(); $managedEntitiesNames = array_map('strval', $unitOfWorkIdentityMap['Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity']); $this->assertContains((string) $entity1, $managedEntitiesNames); $this->assertNotContains((string) $entity2, $managedEntitiesNames); } public function testGroupByChoices() { $item1 = new GroupableEntity(1, 'Foo', 'Group1'); $item2 = new GroupableEntity(2, 'Bar', 'Group1'); $item3 = new GroupableEntity(3, 'Baz', 'Group2'); $item4 = new GroupableEntity(4, 'Boo!', null); $this->persist(array($item1, $item2, $item3, $item4)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, 'choices' => array($item1, $item2, $item3, $item4), 'choice_label' => 'name', 'group_by' => 'groupName', )); $field->submit('2'); $this->assertSame('2', $field->getViewData()); $this->assertEquals(array( 'Group1' => new ChoiceGroupView('Group1', array( 1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar'), )), 'Group2' => new ChoiceGroupView('Group2', array( 3 => new ChoiceView($item3, '3', 'Baz'), )), 4 => new ChoiceView($item4, '4', 'Boo!'), ), $field->createView()->vars['choices']); } public function testPreferredChoices() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'preferred_choices' => array($entity3, $entity2), 'choice_label' => 'name', )); $this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['preferred_choices']); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo')), $field->createView()->vars['choices']); } public function testOverrideChoicesWithPreferredChoices() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choices' => array($entity2, $entity3), 'preferred_choices' => array($entity3), 'choice_label' => 'name', )); $this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz')), $field->createView()->vars['preferred_choices']); $this->assertEquals(array(2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); } public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choices' => array($entity1, $entity2), 'choice_label' => 'name', )); $field->submit('3'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedChoicesSingleAssocIdentifier() { $innerEntity1 = new SingleIntIdNoToStringEntity(1, 'InFoo'); $innerEntity2 = new SingleIntIdNoToStringEntity(2, 'InBar'); $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $this->persist(array($innerEntity1, $innerEntity2, $entity1, $entity2)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'choices' => array($entity1, $entity2), 'choice_label' => 'name', )); $field->submit('3'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedChoicesCompositeIdentifier() { $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choices' => array($entity1, $entity2), 'choice_label' => 'name', )); $field->submit('2'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifier() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repository->createQueryBuilder('e') ->where('e.id IN (1, 2)'), 'choice_label' => 'name', )); $field->submit('3'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleAssocIdentifier() { $innerEntity1 = new SingleIntIdNoToStringEntity(1, 'InFoo'); $innerEntity2 = new SingleIntIdNoToStringEntity(2, 'InBar'); $innerEntity3 = new SingleIntIdNoToStringEntity(3, 'InBaz'); $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $entity3 = new SingleAssociationToIntIdEntity($innerEntity3, 'Baz'); $this->persist(array($innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3)); $repository = $this->em->getRepository(self::SINGLE_ASSOC_IDENT_CLASS); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'query_builder' => $repository->createQueryBuilder('e') ->where('e.entity IN (1, 2)'), 'choice_label' => 'name', )); $field->submit('3'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedQueryBuilderAsClosureSingleIdentifier() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repository) { return $repository->createQueryBuilder('e') ->where('e.id IN (1, 2)'); }, 'choice_label' => 'name', )); $field->submit('3'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testDisallowChoicesThatAreNotIncludedQueryBuilderAsClosureCompositeIdentifier() { $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repository) { return $repository->createQueryBuilder('e') ->where('e.id1 IN (10, 50)'); }, 'choice_label' => 'name', )); $field->submit('2'); $this->assertFalse($field->isSynchronized()); $this->assertNull($field->getData()); } public function testSubmitSingleStringIdentifier() { $entity1 = new SingleStringIdEntity('foo', 'Foo'); $this->persist(array($entity1)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_IDENT_CLASS, 'choice_label' => 'name', )); $field->submit('foo'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity1, $field->getData()); $this->assertSame('foo', $field->getViewData()); } public function testSubmitCompositeStringIdentifier() { $entity1 = new CompositeStringIdEntity('foo1', 'foo2', 'Foo'); $this->persist(array($entity1)); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_STRING_IDENT_CLASS, 'choice_label' => 'name', )); // the collection key is used here $field->submit('0'); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity1, $field->getData()); $this->assertSame('0', $field->getViewData()); } public function testGetManagerForClassIfNoEm() { $this->emRegistry->expects($this->never()) ->method('getManager'); $this->emRegistry->expects($this->once()) ->method('getManagerForClass') ->with(self::SINGLE_IDENT_CLASS) ->will($this->returnValue($this->em)); $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', )); } public function testExplicitEm() { $this->emRegistry->expects($this->never()) ->method('getManager'); $this->emRegistry->expects($this->never()) ->method('getManagerForClass'); $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => $this->em, 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', )); } public function testLoaderCaching() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $repo = $this->em->getRepository(self::SINGLE_IDENT_CLASS); $entityType = new EntityType($this->emRegistry); $entityTypeGuesser = new DoctrineOrmTypeGuesser($this->emRegistry); $factory = Forms::createFormFactoryBuilder() ->addType($entityType) ->addTypeGuesser($entityTypeGuesser) ->getFormFactory(); $formBuilder = $factory->createNamedBuilder('form', FormTypeTest::TESTED_TYPE); $formBuilder->add('property1', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'), )); $formBuilder->add('property2', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'); }, )); $formBuilder->add('property3', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'); }, )); $form = $formBuilder->getForm(); $form->submit(array( 'property1' => 1, 'property2' => 1, 'property3' => 2, )); $choiceLoader1 = $form->get('property1')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); $this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); $this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader3); } public function testLoaderCachingWithParameters() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); $this->persist(array($entity1, $entity2, $entity3)); $repo = $this->em->getRepository(self::SINGLE_IDENT_CLASS); $entityType = new EntityType($this->emRegistry); $entityTypeGuesser = new DoctrineOrmTypeGuesser($this->emRegistry); $factory = Forms::createFormFactoryBuilder() ->addType($entityType) ->addTypeGuesser($entityTypeGuesser) ->getFormFactory(); $formBuilder = $factory->createNamedBuilder('form', FormTypeTest::TESTED_TYPE); $formBuilder->add('property1', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1), )); $formBuilder->add('property2', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1); }, )); $formBuilder->add('property3', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1); }, )); $form = $formBuilder->getForm(); $form->submit(array( 'property1' => 1, 'property2' => 1, 'property3' => 2, )); $choiceLoader1 = $form->get('property1')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); $this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); $this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader3); } protected function createRegistryMock($name, $em) { $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) ->will($this->returnValue($em)); return $registry; } public function testPassDisabledAsOption() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'disabled' => true, 'class' => self::SINGLE_IDENT_CLASS, )); $this->assertTrue($form->isDisabled()); } public function testPassIdAndNameToView() { $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->createView(); $this->assertEquals('name', $view->vars['id']); $this->assertEquals('name', $view->vars['name']); $this->assertEquals('name', $view->vars['full_name']); } public function testStripLeadingUnderscoresAndDigitsFromId() { $view = $this->factory->createNamed('_09name', static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->createView(); $this->assertEquals('name', $view->vars['id']); $this->assertEquals('_09name', $view->vars['name']); $this->assertEquals('_09name', $view->vars['full_name']); } public function testPassIdAndNameToViewWithParent() { $view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->getForm() ->createView(); $this->assertEquals('parent_child', $view['child']->vars['id']); $this->assertEquals('child', $view['child']->vars['name']); $this->assertEquals('parent[child]', $view['child']->vars['full_name']); } public function testPassIdAndNameToViewWithGrandParent() { $builder = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', FormTypeTest::TESTED_TYPE); $builder->get('child')->add('grand_child', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )); $view = $builder->getForm()->createView(); $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); $this->assertEquals('grand_child', $view['child']['grand_child']->vars['name']); $this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->vars['full_name']); } public function testPassTranslationDomainToView() { $view = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'translation_domain' => 'domain', )) ->createView(); $this->assertSame('domain', $view->vars['translation_domain']); } public function testInheritTranslationDomainFromParent() { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( 'translation_domain' => 'domain', )) ->add('child', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->getForm() ->createView(); $this->assertEquals('domain', $view['child']->vars['translation_domain']); } public function testPreferOwnTranslationDomain() { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( 'translation_domain' => 'parent_domain', )) ->add('child', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'translation_domain' => 'domain', )) ->getForm() ->createView(); $this->assertEquals('domain', $view['child']->vars['translation_domain']); } public function testDefaultTranslationDomain() { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', static::TESTED_TYPE, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->getForm() ->createView(); $this->assertNull($view['child']->vars['translation_domain']); } public function testPassLabelToView() { $view = $this->factory->createNamed('__test___field', static::TESTED_TYPE, null, array( 'label' => 'My label', 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->createView(); $this->assertSame('My label', $view->vars['label']); } public function testPassMultipartFalseToView() { $view = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )) ->createView(); $this->assertFalse($view->vars['multipart']); } public function testSubmitNull($expected = null, $norm = null, $view = null) { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, )); $form->submit(null); $this->assertNull($form->getData()); $this->assertNull($form->getNormData()); $this->assertSame('', $form->getViewData(), 'View data is always a string'); } public function testSubmitNullExpanded() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'expanded' => true, )); $form->submit(null); $this->assertNull($form->getData()); $this->assertNull($form->getNormData()); $this->assertSame('', $form->getViewData(), 'View data is always a string'); } public function testSubmitNullMultiple() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, )); $form->submit(null); $collection = new ArrayCollection(); $this->assertEquals($collection, $form->getData()); $this->assertEquals($collection, $form->getNormData()); $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); } public function testSubmitNullExpandedMultiple() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'expanded' => true, 'multiple' => true, )); $form->submit(null); $collection = new ArrayCollection(); $this->assertEquals($collection, $form->getData()); $this->assertEquals($collection, $form->getNormData()); $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); } public function testSetDataEmptyArraySubmitNullMultiple() { $emptyArray = array(); $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, )); $form->setData($emptyArray); $form->submit(null); $this->assertInternalType('array', $form->getData()); $this->assertEquals(array(), $form->getData()); $this->assertEquals(array(), $form->getNormData()); $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); } public function testSetDataNonEmptyArraySubmitNullMultiple() { $entity1 = new SingleIntIdEntity(1, 'Foo'); $this->persist(array($entity1)); $form = $this->factory->create(static::TESTED_TYPE, null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, )); $existing = array(0 => $entity1); $form->setData($existing); $form->submit(null); $this->assertInternalType('array', $form->getData()); $this->assertEquals(array(), $form->getData()); $this->assertEquals(array(), $form->getNormData()); $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/HttpFoundation/000077500000000000000000000000001324732107100244765ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/HttpFoundation/DbalSessionHandlerTest.php000066400000000000000000000015431324732107100315560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\HttpFoundation; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler; /** * Test class for DbalSessionHandler. * * @author Drak * * @group legacy */ class DbalSessionHandlerTest extends TestCase { public function testConstruct() { $connection = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock(); $handler = new DbalSessionHandler($connection); $this->assertInstanceOf('Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler', $handler); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Logger/000077500000000000000000000000001324732107100227475ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php000066400000000000000000000121521324732107100263230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Logger; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Logger\DbalLogger; class DbalLoggerTest extends TestCase { /** * @dataProvider getLogFixtures */ public function testLog($sql, $params, $logParams) { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->setConstructorArgs(array($logger, null)) ->setMethods(array('log')) ->getMock() ; $dbalLogger ->expects($this->once()) ->method('log') ->with($sql, $logParams) ; $dbalLogger->startQuery($sql, $params); } public function getLogFixtures() { return array( array('SQL', null, array()), array('SQL', array(), array()), array('SQL', array('foo' => 'bar'), array('foo' => 'bar')), array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), array('SQL', array('foo' => ''), array('foo' => '')), ); } public function testLogNonUtf8() { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->setConstructorArgs(array($logger, null)) ->setMethods(array('log')) ->getMock() ; $dbalLogger ->expects($this->once()) ->method('log') ->with('SQL', array('utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE)) ; $dbalLogger->startQuery('SQL', array( 'utf8' => 'foo', 'nonutf8' => "\x7F\xFF", )); } public function testLogNonUtf8Array() { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->setConstructorArgs(array($logger, null)) ->setMethods(array('log')) ->getMock() ; $dbalLogger ->expects($this->once()) ->method('log') ->with('SQL', array( 'utf8' => 'foo', array( 'nonutf8' => DbalLogger::BINARY_DATA_VALUE, ), ) ) ; $dbalLogger->startQuery('SQL', array( 'utf8' => 'foo', array( 'nonutf8' => "\x7F\xFF", ), )); } public function testLogLongString() { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->setConstructorArgs(array($logger, null)) ->setMethods(array('log')) ->getMock() ; $testString = 'abc'; $shortString = str_pad('', DbalLogger::MAX_STRING_LENGTH, $testString); $longString = str_pad('', DbalLogger::MAX_STRING_LENGTH + 1, $testString); $dbalLogger ->expects($this->once()) ->method('log') ->with('SQL', array('short' => $shortString, 'long' => substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6).' [...]')) ; $dbalLogger->startQuery('SQL', array( 'short' => $shortString, 'long' => $longString, )); } public function testLogUTF8LongString() { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->setConstructorArgs(array($logger, null)) ->setMethods(array('log')) ->getMock() ; $testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í'); $testStringCount = count($testStringArray); $shortString = ''; $longString = ''; for ($i = 1; $i <= DbalLogger::MAX_STRING_LENGTH; ++$i) { $shortString .= $testStringArray[$i % $testStringCount]; $longString .= $testStringArray[$i % $testStringCount]; } $longString .= $testStringArray[$i % $testStringCount]; $dbalLogger ->expects($this->once()) ->method('log') ->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]')) ; $dbalLogger->startQuery('SQL', array( 'short' => $shortString, 'long' => $longString, )); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php000066400000000000000000000031521324732107100262050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\ManagerRegistry; use Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper\PhpDumperTest; class ManagerRegistryTest extends TestCase { public static function setUpBeforeClass() { if (!class_exists('PHPUnit_Framework_TestCase')) { self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.'); } $test = new PhpDumperTest(); $test->testDumpContainerWithProxyServiceWillShareProxies(); } public function testResetService() { $container = new \LazyServiceProjectServiceContainer(); $registry = new TestManagerRegistry('name', array(), array('defaultManager' => 'foo'), 'defaultConnection', 'defaultManager', 'proxyInterfaceName'); $registry->setTestContainer($container); $foo = $container->get('foo'); $foo->bar = 123; $this->assertTrue(isset($foo->bar)); $registry->resetManager(); $this->assertSame($foo, $container->get('foo')); $this->assertObjectNotHasAttribute('bar', $foo); } } class TestManagerRegistry extends ManagerRegistry { public function setTestContainer($container) { $this->container = $container; } public function getAliasNamespace($alias) { return 'Foo'; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/000077500000000000000000000000001324732107100241705ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php000066400000000000000000000133261324732107100312110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\Setup; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor; use Symfony\Component\PropertyInfo\Type; /** * @author Kévin Dunglas */ class DoctrineExtractorTest extends TestCase { /** * @var DoctrineExtractor */ private $extractor; protected function setUp() { $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'), true); $entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config); if (!DBALType::hasType('foo')) { DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType'); $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('custom_foo', 'foo'); } $this->extractor = new DoctrineExtractor($entityManager->getMetadataFactory()); } public function testGetProperties() { $this->assertEquals( array( 'id', 'guid', 'time', 'timeImmutable', 'dateInterval', 'json', 'simpleArray', 'float', 'decimal', 'bool', 'binary', 'customFoo', 'bigint', 'foo', 'bar', 'indexedBar', ), $this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy') ); } public function testGetPropertiesWithEmbedded() { if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); } $this->assertEquals( array( 'id', 'embedded', ), $this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded') ); } /** * @dataProvider typesProvider */ public function testExtract($property, array $type = null) { $this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array())); } public function testExtractWithEmbedded() { if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); } $expectedTypes = array(new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable' )); $actualTypes = $this->extractor->getTypes( 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded', 'embedded', array() ); $this->assertEquals($expectedTypes, $actualTypes); } public function typesProvider() { return array( array('id', array(new Type(Type::BUILTIN_TYPE_INT))), array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))), array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))), array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))), array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))), array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))), array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))), array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))), array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))), array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))), array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))), array('bar', array(new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation') ))), array('indexedBar', array(new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation') ))), array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))), array('customFoo', null), array('notMapped', null), ); } public function testGetPropertiesCatchException() { $this->assertNull($this->extractor->getProperties('Not\Exist')); } public function testGetTypesCatchException() { $this->assertNull($this->extractor->getTypes('Not\Exist', 'baz')); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/000077500000000000000000000000001324732107100260015ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php000066400000000000000000000034411324732107100312770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; /** * @Entity * * @author Kévin Dunglas */ class DoctrineDummy { /** * @Id * @Column(type="smallint") */ public $id; /** * @ManyToOne(targetEntity="DoctrineRelation") */ public $foo; /** * @ManyToMany(targetEntity="DoctrineRelation") */ public $bar; /** * @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid") */ protected $indexedBar; /** * @Column(type="guid") */ protected $guid; /** * @Column(type="time") */ private $time; /** * @Column(type="time_immutable") */ private $timeImmutable; /** * @Column(type="dateinterval") */ private $dateInterval; /** * @Column(type="json_array") */ private $json; /** * @Column(type="simple_array") */ private $simpleArray; /** * @Column(type="float") */ private $float; /** * @Column(type="decimal", precision=10, scale=2) */ private $decimal; /** * @Column(type="boolean") */ private $bool; /** * @Column(type="binary") */ private $binary; /** * @Column(type="custom_foo") */ private $customFoo; /** * @Column(type="bigint") */ private $bigint; public $notMapped; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineEmbeddable.php000066400000000000000000000010531324732107100322050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; /** * @Embeddable * * @author Udaltsov Valentin */ class DoctrineEmbeddable { /** * @Column(type="string") */ protected $field; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php000066400000000000000000000034431324732107100315730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; /** * @author Teoh Han Hui */ class DoctrineFooType extends Type { /** * Type name. */ const NAME = 'foo'; /** * {@inheritdoc} */ public function getName() { return self::NAME; } /** * {@inheritdoc} */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getClobTypeDeclarationSQL(array()); } /** * {@inheritdoc} */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (null === $value) { return; } if (!$value instanceof Foo) { throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', gettype($value))); } return $foo->bar; } /** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { if (null === $value) { return; } if (!is_string($value)) { throw ConversionException::conversionFailed($value, self::NAME); } $foo = new Foo(); $foo->bar = $value; return $foo; } /** * {@inheritdoc} */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return true; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php000066400000000000000000000011731324732107100317610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; /** * @Entity * * @author Kévin Dunglas */ class DoctrineRelation { /** * @Id * @Column(type="smallint") */ public $id; /** * @Column(type="guid") */ protected $rguid; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineWithEmbedded.php000066400000000000000000000013031324732107100325240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Embedded; /** * @Entity * * @author Udaltsov Valentin */ class DoctrineWithEmbedded { /** * @Id * @Column(type="smallint") */ public $id; /** * @Embedded(class="DoctrineEmbeddable") */ protected $embedded; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/Foo.php000066400000000000000000000006471324732107100272440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; /** * @author Teoh Han Hui */ class Foo { /** * @var string */ public $bar; } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Security/000077500000000000000000000000001324732107100233375ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Security/User/000077500000000000000000000000001324732107100242555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php000066400000000000000000000166311324732107100314630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Security\User; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\User; use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; use Doctrine\ORM\Tools\SchemaTool; class EntityUserProviderTest extends TestCase { public function testRefreshUserGetsUserByPrimaryKey() { $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); $user1 = new User(1, 1, 'user1'); $user2 = new User(1, 2, 'user2'); $em->persist($user1); $em->persist($user2); $em->flush(); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); // try to change the user identity $user1->name = 'user2'; $this->assertSame($user1, $provider->refreshUser($user1)); } public function testLoadUserByUsername() { $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); $user = new User(1, 1, 'user1'); $em->persist($user); $em->flush(); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $this->assertSame($user, $provider->loadUserByUsername('user1')); } public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty() { $user = new User(1, 1, 'user1'); $repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface') ->disableOriginalConstructor() ->getMock(); $repository ->expects($this->once()) ->method('loadUserByUsername') ->with('user1') ->willReturn($user); $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') ->disableOriginalConstructor() ->getMock(); $em ->expects($this->once()) ->method('getRepository') ->with('Symfony\Bridge\Doctrine\Tests\Fixtures\User') ->willReturn($repository); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User'); $this->assertSame($user, $provider->loadUserByUsername('user1')); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage You must either make the "Symfony\Bridge\Doctrine\Tests\Fixtures\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration. */ public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty() { $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); $user = new User(1, 1, 'user1'); $em->persist($user); $em->flush(); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User'); $provider->loadUserByUsername('user1'); } public function testRefreshUserRequiresId() { $em = DoctrineTestHelper::createTestEntityManager(); $user1 = new User(null, null, 'user1'); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}( 'InvalidArgumentException', 'You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine' ); $provider->refreshUser($user1); } public function testRefreshInvalidUser() { $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); $user1 = new User(1, 1, 'user1'); $em->persist($user1); $em->flush(); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $user2 = new User(1, 2, 'user2'); $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}( 'Symfony\Component\Security\Core\Exception\UsernameNotFoundException', 'User with id {"id1":1,"id2":2} not found' ); $provider->refreshUser($user2); } public function testSupportProxy() { $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); $user1 = new User(1, 1, 'user1'); $em->persist($user1); $em->flush(); $em->clear(); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1)); $this->assertTrue($provider->supportsClass(get_class($user2))); } public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() { $repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock(); $repository->expects($this->once()) ->method('loadUserByUsername') ->with('name') ->willReturn( $this->getMockBuilder('\Symfony\Component\Security\Core\User\UserInterface')->getMock() ); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User' ); $provider->loadUserByUsername('name'); } /** * @expectedException \InvalidArgumentException */ public function testLoadUserByUserNameShouldDeclineInvalidInterface() { $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User' ); $provider->loadUserByUsername('name'); } private function getManager($em, $name = null) { $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $manager->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) ->will($this->returnValue($em)); return $manager; } private function getObjectManager($repository) { $em = $this->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager') ->setMethods(array('getClassMetadata', 'getRepository')) ->getMockForAbstractClass(); $em->expects($this->any()) ->method('getRepository') ->willReturn($repository); return $em; } private function createSchema($em) { $schemaTool = new SchemaTool($em); $schemaTool->createSchema(array( $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\User'), )); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Validator/000077500000000000000000000000001324732107100234555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/000077500000000000000000000000001324732107100257645ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php000066400000000000000000000631351324732107100336560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\DBAL\Types\Type; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory; use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee; use Symfony\Bridge\Doctrine\Tests\Fixtures\Person; use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; use Doctrine\ORM\Tools\SchemaTool; /** * @author Bernhard Schussek */ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase { const EM_NAME = 'foo'; /** * @var ObjectManager */ protected $em; /** * @var ManagerRegistry */ protected $registry; /** * @var ObjectRepository */ protected $repository; protected $repositoryFactory; protected function setUp() { $this->repositoryFactory = new TestRepositoryFactory(); $config = DoctrineTestHelper::createTestConfiguration(); $config->setRepositoryFactory($this->repositoryFactory); if (!Type::hasType('string_wrapper')) { Type::addType('string_wrapper', 'Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapperType'); } $this->em = DoctrineTestHelper::createTestEntityManager($config); $this->registry = $this->createRegistryMock($this->em); $this->createSchema($this->em); parent::setUp(); } protected function createRegistryMock(ObjectManager $em = null) { $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo(self::EM_NAME)) ->will($this->returnValue($em)); return $registry; } protected function createRepositoryMock() { $repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository') ->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName')) ->getMock() ; return $repository; } protected function createEntityManagerMock($repositoryMock) { $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') ->getMock() ; $em->expects($this->any()) ->method('getRepository') ->will($this->returnValue($repositoryMock)) ; $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock(); $classMetadata ->expects($this->any()) ->method('hasField') ->will($this->returnValue(true)) ; $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') ->disableOriginalConstructor() ->getMock() ; $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') ->setConstructorArgs(array($reflParser, 'property-name')) ->setMethods(array('getValue')) ->getMock() ; $refl ->expects($this->any()) ->method('getValue') ->will($this->returnValue(true)) ; $classMetadata->reflFields = array('name' => $refl); $em->expects($this->any()) ->method('getClassMetadata') ->will($this->returnValue($classMetadata)) ; return $em; } protected function createValidator() { return new UniqueEntityValidator($this->registry); } private function createSchema(ObjectManager $em) { $schemaTool = new SchemaTool($em); $schemaTool->createSchema(array( $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Person'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity'), )); } /** * This is a functional test as there is a large integration necessary to get the validator working. */ public function testValidateUniqueness() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, )); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateCustomErrorPath() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'errorPath' => 'bar', )); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.bar') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessWithNull() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, )); $entity1 = new SingleIntIdEntity(1, null); $entity2 = new SingleIntIdEntity(2, null); $this->em->persist($entity1); $this->em->persist($entity2); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); } public function testValidateUniquenessWithIgnoreNullDisabled() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name', 'name2'), 'em' => self::EM_NAME, 'ignoreNull' => false, )); $entity1 = new DoubleNameEntity(1, 'Foo', null); $entity2 = new DoubleNameEntity(2, 'Foo', null); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue('Foo') ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name', 'name2'), 'em' => self::EM_NAME, 'ignoreNull' => true, )); $entity1 = new SingleIntIdEntity(1, null); $this->validator->validate($entity1, $constraint); } public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name', 'name2'), 'em' => self::EM_NAME, 'ignoreNull' => true, )); $entity1 = new DoubleNullableNameEntity(1, null, 'Foo'); $entity2 = new DoubleNullableNameEntity(2, null, 'Foo'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->assertNoViolation(); } public function testValidateUniquenessWithValidCustomErrorPath() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name', 'name2'), 'em' => self::EM_NAME, 'errorPath' => 'name2', )); $entity1 = new DoubleNameEntity(1, 'Foo', 'Bar'); $entity2 = new DoubleNameEntity(2, 'Foo', 'Bar'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.name2') ->setParameter('{{ value }}', '"Bar"') ->setInvalidValue('Bar') ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessUsingCustomRepositoryMethod() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', )); $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') ->will($this->returnValue(array())) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); $entity1 = new SingleIntIdEntity(1, 'foo'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); } public function testValidateUniquenessWithUnrewoundArray() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', )); $entity = new SingleIntIdEntity(1, 'foo'); $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') ->will( $this->returnCallback(function () use ($entity) { $returnValue = array( $entity, ); next($returnValue); return $returnValue; }) ) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); $this->validator->validate($entity, $constraint); $this->assertNoViolation(); } /** * @dataProvider resultTypesProvider */ public function testValidateResultTypes($entity1, $result) { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', )); $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') ->will($this->returnValue($result)) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); } public function resultTypesProvider() { $entity = new SingleIntIdEntity(1, 'foo'); return array( array($entity, array($entity)), array($entity, new \ArrayIterator(array($entity))), array($entity, new ArrayCollection(array($entity))), ); } public function testAssociatedEntity() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('single'), 'em' => self::EM_NAME, )); $entity1 = new SingleIntIdEntity(1, 'foo'); $associated = new AssociationEntity(); $associated->single = $entity1; $associated2 = new AssociationEntity(); $associated2->single = $entity1; $this->em->persist($entity1); $this->em->persist($associated); $this->em->flush(); $this->validator->validate($associated, $constraint); $this->assertNoViolation(); $this->em->persist($associated2); $this->em->flush(); $this->validator->validate($associated2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.single') ->setParameter('{{ value }}', 'object("Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity") identified by (id => 1)') ->setInvalidValue($entity1) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->setCause(array($associated, $associated2)) ->assertRaised(); } public function testValidateUniquenessNotToStringEntityWithAssociatedEntity() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('single'), 'em' => self::EM_NAME, )); $entity1 = new SingleIntIdNoToStringEntity(1, 'foo'); $associated = new AssociationEntity2(); $associated->single = $entity1; $associated2 = new AssociationEntity2(); $associated2->single = $entity1; $this->em->persist($entity1); $this->em->persist($associated); $this->em->flush(); $this->validator->validate($associated, $constraint); $this->assertNoViolation(); $this->em->persist($associated2); $this->em->flush(); $this->validator->validate($associated2, $constraint); $expectedValue = 'object("Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity") identified by (id => 1)'; $this->buildViolation('myMessage') ->atPath('property.path.single') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($entity1) ->setCause(array($associated, $associated2)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testAssociatedEntityWithNull() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('single'), 'em' => self::EM_NAME, 'ignoreNull' => false, )); $associated = new AssociationEntity(); $associated->single = null; $this->em->persist($associated); $this->em->flush(); $this->validator->validate($associated, $constraint); $this->assertNoViolation(); } public function testValidateUniquenessWithArrayValue() { $repository = $this->createRepositoryMock(); $this->repositoryFactory->setRepository($this->em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', $repository); $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('phoneNumbers'), 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', )); $entity1 = new SingleIntIdEntity(1, 'foo'); $entity1->phoneNumbers[] = 123; $repository->expects($this->once()) ->method('findByCustom') ->will($this->returnValue(array($entity1))) ; $this->em->persist($entity1); $this->em->flush(); $entity2 = new SingleIntIdEntity(2, 'bar'); $entity2->phoneNumbers[] = 123; $this->em->persist($entity2); $this->em->flush(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.phoneNumbers') ->setParameter('{{ value }}', 'array') ->setInvalidValue(array(123)) ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException * @expectedExceptionMessage Object manager "foo" does not exist. */ public function testDedicatedEntityManagerNullObject() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, )); $this->em = null; $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); $entity = new SingleIntIdEntity(1, null); $this->validator->validate($entity, $constraint); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException * @expectedExceptionMessage Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity" */ public function testEntityManagerNullObject() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), // no "em" option set )); $this->em = null; $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); $entity = new SingleIntIdEntity(1, null); $this->validator->validate($entity, $constraint); } public function testValidateInheritanceUniqueness() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\Person', )); $entity1 = new Person(1, 'Foo'); $entity2 = new Employee(2, 'Foo'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.name') ->setInvalidValue('Foo') ->setCode('23bd9dbf-6b9b-41cd-a99e-4844bcf3077f') ->setCause(array($entity1)) ->setParameters(array('{{ value }}' => '"Foo"')) ->assertRaised(); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException * @expectedExceptionMessage The "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity" entity repository does not support the "Symfony\Bridge\Doctrine\Tests\Fixtures\Person" entity. The entity should be an instance of or extend "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity". */ public function testInvalidateRepositoryForInheritance() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, 'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', )); $entity = new Person(1, 'Foo'); $this->validator->validate($entity, $constraint); } public function testValidateUniquenessWithCompositeObjectNoToStringIdEntity() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('objectOne', 'objectTwo'), 'em' => self::EM_NAME, )); $objectOne = new SingleIntIdNoToStringEntity(1, 'foo'); $objectTwo = new SingleIntIdNoToStringEntity(2, 'bar'); $this->em->persist($objectOne); $this->em->persist($objectTwo); $this->em->flush(); $entity = new CompositeObjectNoToStringIdEntity($objectOne, $objectTwo); $this->em->persist($entity); $this->em->flush(); $newEntity = new CompositeObjectNoToStringIdEntity($objectOne, $objectTwo); $this->validator->validate($newEntity, $constraint); $expectedValue = 'object("Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity") identified by (id => 1)'; $this->buildViolation('myMessage') ->atPath('property.path.objectOne') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($objectOne) ->setCause(array($entity)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessWithCustomDoctrineTypeValue() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, )); $existingEntity = new SingleIntIdStringWrapperNameEntity(1, new StringWrapper('foo')); $this->em->persist($existingEntity); $this->em->flush(); $newEntity = new SingleIntIdStringWrapperNameEntity(2, new StringWrapper('foo')); $this->validator->validate($newEntity, $constraint); $expectedValue = 'object("Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper")'; $this->buildViolation('myMessage') ->atPath('property.path.name') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($existingEntity->name) ->setCause(array($existingEntity)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } /** * This is a functional test as there is a large integration necessary to get the validator working. */ public function testValidateUniquenessCause() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', 'fields' => array('name'), 'em' => self::EM_NAME, )); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->em->persist($entity1); $this->em->flush(); $this->validator->validate($entity1, $constraint); $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) ->setCause(array($entity1)) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Validator/000077500000000000000000000000001324732107100223535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Validator/Constraints/000077500000000000000000000000001324732107100246625ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php000066400000000000000000000027201324732107100300370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Validator\Constraints; use Symfony\Component\Validator\Constraint; /** * Constraint for the Unique Entity validator. * * @Annotation * @Target({"CLASS", "ANNOTATION"}) * * @author Benjamin Eberlei */ class UniqueEntity extends Constraint { const NOT_UNIQUE_ERROR = '23bd9dbf-6b9b-41cd-a99e-4844bcf3077f'; public $message = 'This value is already used.'; public $service = 'doctrine.orm.validator.unique'; public $em = null; public $entityClass = null; public $repositoryMethod = 'findBy'; public $fields = array(); public $errorPath = null; public $ignoreNull = true; protected static $errorNames = array( self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR', ); public function getRequiredOptions() { return array('fields'); } /** * The validator must be defined as a service with this name. * * @return string */ public function validatedBy() { return $this->service; } /** * {@inheritdoc} */ public function getTargets() { return self::CLASS_CONSTRAINT; } public function getDefaultOption() { return 'fields'; } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php000066400000000000000000000175651324732107100317220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Validator\Constraints; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\ConstraintValidator; /** * Unique Entity Validator checks if one or a set of fields contain unique values. * * @author Benjamin Eberlei */ class UniqueEntityValidator extends ConstraintValidator { private $registry; public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } /** * @param object $entity * @param Constraint $constraint * * @throws UnexpectedTypeException * @throws ConstraintDefinitionException */ public function validate($entity, Constraint $constraint) { if (!$constraint instanceof UniqueEntity) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity'); } if (!is_array($constraint->fields) && !is_string($constraint->fields)) { throw new UnexpectedTypeException($constraint->fields, 'array'); } if (null !== $constraint->errorPath && !is_string($constraint->errorPath)) { throw new UnexpectedTypeException($constraint->errorPath, 'string or null'); } $fields = (array) $constraint->fields; if (0 === count($fields)) { throw new ConstraintDefinitionException('At least one field has to be specified.'); } if (null === $entity) { return; } if ($constraint->em) { $em = $this->registry->getManager($constraint->em); if (!$em) { throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em)); } } else { $em = $this->registry->getManagerForClass(get_class($entity)); if (!$em) { throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_class($entity))); } } $class = $em->getClassMetadata(get_class($entity)); /* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */ $criteria = array(); $hasNullValue = false; foreach ($fields as $fieldName) { if (!$class->hasField($fieldName) && !$class->hasAssociation($fieldName)) { throw new ConstraintDefinitionException(sprintf('The field "%s" is not mapped by Doctrine, so it cannot be validated for uniqueness.', $fieldName)); } $fieldValue = $class->reflFields[$fieldName]->getValue($entity); if (null === $fieldValue) { $hasNullValue = true; } if ($constraint->ignoreNull && null === $fieldValue) { continue; } $criteria[$fieldName] = $fieldValue; if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) { /* Ensure the Proxy is initialized before using reflection to * read its identifiers. This is necessary because the wrapped * getter methods in the Proxy are being bypassed. */ $em->initializeObject($criteria[$fieldName]); } } // validation doesn't fail if one of the fields is null and if null values should be ignored if ($hasNullValue && $constraint->ignoreNull) { return; } // skip validation if there are no criteria (this can happen when the // "ignoreNull" option is enabled and fields to be checked are null if (empty($criteria)) { return; } if (null !== $constraint->entityClass) { /* Retrieve repository from given entity name. * We ensure the retrieved repository can handle the entity * by checking the entity is the same, or subclass of the supported entity. */ $repository = $em->getRepository($constraint->entityClass); $supportedClass = $repository->getClassName(); if (!$entity instanceof $supportedClass) { throw new ConstraintDefinitionException(sprintf('The "%s" entity repository does not support the "%s" entity. The entity should be an instance of or extend "%s".', $constraint->entityClass, $class->getName(), $supportedClass)); } } else { $repository = $em->getRepository(get_class($entity)); } $result = $repository->{$constraint->repositoryMethod}($criteria); if ($result instanceof \IteratorAggregate) { $result = $result->getIterator(); } /* If the result is a MongoCursor, it must be advanced to the first * element. Rewinding should have no ill effect if $result is another * iterator implementation. */ if ($result instanceof \Iterator) { $result->rewind(); } elseif (is_array($result)) { reset($result); } /* If no entity matched the query criteria or a single entity matched, * which is the same as the entity being validated, the criteria is * unique. */ if (0 === count($result) || (1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result)))) { return; } $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0]; $invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]]; $this->context->buildViolation($constraint->message) ->atPath($errorPath) ->setParameter('{{ value }}', $this->formatWithIdentifiers($em, $class, $invalidValue)) ->setInvalidValue($invalidValue) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->setCause($result) ->addViolation(); } private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, $value) { if (!is_object($value) || $value instanceof \DateTimeInterface) { return $this->formatValue($value, self::PRETTY_DATE); } if ($class->getName() !== $idClass = get_class($value)) { // non unique value might be a composite PK that consists of other entity objects if ($em->getMetadataFactory()->hasMetadataFor($idClass)) { $identifiers = $em->getClassMetadata($idClass)->getIdentifierValues($value); } else { // this case might happen if the non unique column has a custom doctrine type and its value is an object // in which case we cannot get any identifiers for it $identifiers = array(); } } else { $identifiers = $class->getIdentifierValues($value); } if (!$identifiers) { return sprintf('object("%s")', $idClass); } array_walk($identifiers, function (&$id, $field) { if (!is_object($id) || $id instanceof \DateTimeInterface) { $idAsString = $this->formatValue($id, self::PRETTY_DATE); } else { $idAsString = sprintf('object("%s")', get_class($id)); } $id = sprintf('%s => %s', $field, $idAsString); }); return sprintf('object("%s") identified by (%s)', $idClass, implode(', ', $identifiers)); } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php000066400000000000000000000016441324732107100270440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Validator; use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Component\Validator\ObjectInitializerInterface; /** * Automatically loads proxy object before validation. * * @author Fabien Potencier */ class DoctrineInitializer implements ObjectInitializerInterface { protected $registry; public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } public function initialize($object) { $manager = $this->registry->getManagerForClass(get_class($object)); if (null !== $manager) { $manager->initializeObject($object); } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/composer.json000066400000000000000000000035261324732107100231560ustar00rootroot00000000000000{ "name": "symfony/doctrine-bridge", "type": "symfony-bridge", "description": "Symfony Doctrine Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "doctrine/common": "~2.4", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "symfony/stopwatch": "~2.8|~3.0|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/form": "^3.3.10|~4.0", "symfony/http-kernel": "~2.8|~3.0|~4.0", "symfony/property-access": "~2.8|~3.0|~4.0", "symfony/property-info": "~2.8|3.0|~4.0", "symfony/proxy-manager-bridge": "~2.8|~3.0|~4.0", "symfony/security": "~2.8|~3.0|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/validator": "^3.2.5|~4.0", "symfony/translation": "~2.8|~3.0|~4.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.4", "doctrine/orm": "^2.4.5" }, "conflict": { "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", "symfony/dependency-injection": "<3.4" }, "suggest": { "symfony/form": "", "symfony/validator": "", "symfony/property-info": "", "doctrine/data-fixtures": "", "doctrine/dbal": "", "doctrine/orm": "" }, "autoload": { "psr-4": { "Symfony\\Bridge\\Doctrine\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bridge/Doctrine/phpunit.xml.dist000066400000000000000000000015631324732107100236060ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Bridge/Monolog/000077500000000000000000000000001324732107100202715ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/.gitignore000066400000000000000000000000421324732107100222550ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Bridge/Monolog/CHANGELOG.md000066400000000000000000000010241324732107100220770ustar00rootroot00000000000000CHANGELOG ========= 3.3.0 ----- * Improved the console handler output formatting by adding var-dumper support 3.0.0 ----- * deprecated interface `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed * deprecated methods `Logger::crit()`, `Logger::emerg()`, `Logger::err()` and `Logger::warn()` have been removed 2.4.0 ----- * added ConsoleHandler and ConsoleFormatter which can be used to show log messages in the console output depending on the verbosity settings 2.1.0 ----- * added ChromePhpHandler symfony-3.4.6/src/Symfony/Bridge/Monolog/Formatter/000077500000000000000000000000001324732107100222345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php000066400000000000000000000150311324732107100262330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Formatter; use Monolog\Formatter\FormatterInterface; use Monolog\Logger; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; /** * Formats incoming records for console output by coloring them depending on log level. * * @author Tobias Schultze * @author Grégoire Pineau */ class ConsoleFormatter implements FormatterInterface { const SIMPLE_FORMAT = "%datetime% %start_tag%%level_name%%end_tag% [%channel%] %message%%context%%extra%\n"; const SIMPLE_DATE = 'H:i:s'; private static $levelColorMap = array( Logger::DEBUG => 'fg=white', Logger::INFO => 'fg=green', Logger::NOTICE => 'fg=blue', Logger::WARNING => 'fg=cyan', Logger::ERROR => 'fg=yellow', Logger::CRITICAL => 'fg=red', Logger::ALERT => 'fg=red', Logger::EMERGENCY => 'fg=white;bg=red', ); private $options; private $cloner; private $outputBuffer; private $dumper; /** * Available options: * * format: The format of the outputted log string. The following placeholders are supported: %datetime%, %start_tag%, %level_name%, %end_tag%, %channel%, %message%, %context%, %extra%; * * date_format: The format of the outputted date string; * * colors: If true, the log string contains ANSI code to add color; * * multiline: If false, "context" and "extra" are dumped on one line. */ public function __construct($options = array()) { // BC Layer if (!is_array($options)) { @trigger_error(sprintf('The constructor arguments $format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra of "%s" are deprecated since Symfony 3.3 and will be removed in 4.0. Use $options instead.', self::class), E_USER_DEPRECATED); $args = func_get_args(); $options = array(); if (isset($args[0])) { $options['format'] = $args[0]; } if (isset($args[1])) { $options['date_format'] = $args[1]; } if (isset($args[2])) { $options['multiline'] = $args[2]; } } $this->options = array_replace(array( 'format' => self::SIMPLE_FORMAT, 'date_format' => self::SIMPLE_DATE, 'colors' => true, 'multiline' => false, ), $options); if (class_exists(VarCloner::class)) { $this->cloner = new VarCloner(); $this->cloner->addCasters(array( '*' => array($this, 'castObject'), )); $this->outputBuffer = fopen('php://memory', 'r+b'); if ($this->options['multiline']) { $output = $this->outputBuffer; } else { $output = array($this, 'echoLine'); } $this->dumper = new CliDumper($output, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); } } /** * {@inheritdoc} */ public function formatBatch(array $records) { foreach ($records as $key => $record) { $records[$key] = $this->format($record); } return $records; } /** * {@inheritdoc} */ public function format(array $record) { $record = $this->replacePlaceHolder($record); $levelColor = self::$levelColorMap[$record['level']]; if ($this->options['multiline']) { $separator = "\n"; } else { $separator = ' '; } $context = $this->dumpData($record['context']); if ($context) { $context = $separator.$context; } $extra = $this->dumpData($record['extra']); if ($extra) { $extra = $separator.$extra; } $formatted = strtr($this->options['format'], array( '%datetime%' => $record['datetime']->format($this->options['date_format']), '%start_tag%' => sprintf('<%s>', $levelColor), '%level_name%' => sprintf('%-9s', $record['level_name']), '%end_tag%' => '', '%channel%' => $record['channel'], '%message%' => $this->replacePlaceHolder($record)['message'], '%context%' => $context, '%extra%' => $extra, )); return $formatted; } /** * @internal */ public function echoLine($line, $depth, $indentPad) { if (-1 !== $depth) { fwrite($this->outputBuffer, $line); } } /** * @internal */ public function castObject($v, array $a, Stub $s, $isNested) { if ($this->options['multiline']) { return $a; } if ($isNested && !$v instanceof \DateTimeInterface) { $s->cut = -1; $a = array(); } return $a; } private function replacePlaceHolder(array $record) { $message = $record['message']; if (false === strpos($message, '{')) { return $record; } $context = $record['context']; $replacements = array(); foreach ($context as $k => $v) { // Remove quotes added by the dumper around string. $v = trim($this->dumpData($v, false), '"'); $v = OutputFormatter::escape($v); $replacements['{'.$k.'}'] = sprintf('%s', $v); } $record['message'] = strtr($message, $replacements); return $record; } private function dumpData($data, $colors = null) { if (null === $this->dumper) { return ''; } if (null === $colors) { $this->dumper->setColors($this->options['colors']); } else { $this->dumper->setColors($colors); } if (!$data instanceof Data) { $data = $this->cloner->cloneVar($data); } $data = $data->withRefHandles(false); $this->dumper->dump($data); $dump = stream_get_contents($this->outputBuffer, -1, 0); rewind($this->outputBuffer); ftruncate($this->outputBuffer, 0); return rtrim($dump); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Formatter/VarDumperFormatter.php000066400000000000000000000020351324732107100265360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Formatter; use Monolog\Formatter\FormatterInterface; use Symfony\Component\VarDumper\Cloner\VarCloner; /** * @author Grégoire Pineau */ class VarDumperFormatter implements FormatterInterface { private $cloner; public function __construct(VarCloner $cloner = null) { $this->cloner = $cloner ?: new VarCloner(); } public function format(array $record) { $record['context'] = $this->cloner->cloneVar($record['context']); $record['extra'] = $this->cloner->cloneVar($record['extra']); return $record; } public function formatBatch(array $records) { foreach ($records as $k => $record) { $record[$k] = $this->format($record); } return $records; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/000077500000000000000000000000001324732107100216465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php000066400000000000000000000034461324732107100255510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; /** * ChromePhpHandler. * * @author Christophe Coevoet */ class ChromePhpHandler extends BaseChromePhpHandler { private $headers = array(); /** * @var Response */ private $response; /** * Adds the headers to the response once it's created. */ public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) { $this->sendHeaders = false; $this->headers = array(); return; } $this->response = $event->getResponse(); foreach ($this->headers as $header => $content) { $this->response->headers->set($header, $content); } $this->headers = array(); } /** * {@inheritdoc} */ protected function sendHeader($header, $content) { if (!$this->sendHeaders) { return; } if ($this->response) { $this->response->headers->set($header, $content); } else { $this->headers[$header] = $content; } } /** * Override default behavior since we check it in onKernelResponse. */ protected function headersAccepted() { return true; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php000066400000000000000000000140001324732107100252520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Formatter\LineFormatter; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\VarDumper\Dumper\CliDumper; /** * Writes logs to the console output depending on its verbosity setting. * * It is disabled by default and gets activated as soon as a command is executed. * Instead of listening to the console events, the output can also be set manually. * * The minimum logging level at which this handler will be triggered depends on the * verbosity setting of the console output. The default mapping is: * - OutputInterface::VERBOSITY_NORMAL will show all WARNING and higher logs * - OutputInterface::VERBOSITY_VERBOSE (-v) will show all NOTICE and higher logs * - OutputInterface::VERBOSITY_VERY_VERBOSE (-vv) will show all INFO and higher logs * - OutputInterface::VERBOSITY_DEBUG (-vvv) will show all DEBUG and higher logs, i.e. all logs * * This mapping can be customized with the $verbosityLevelMap constructor parameter. * * @author Tobias Schultze */ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscriberInterface { private $output; private $verbosityLevelMap = array( OutputInterface::VERBOSITY_QUIET => Logger::ERROR, OutputInterface::VERBOSITY_NORMAL => Logger::WARNING, OutputInterface::VERBOSITY_VERBOSE => Logger::NOTICE, OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO, OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG, ); /** * @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null * until the output is set, e.g. by using console events) * @param bool $bubble Whether the messages that are handled can bubble up the stack * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = array()) { parent::__construct(Logger::DEBUG, $bubble); $this->output = $output; if ($verbosityLevelMap) { $this->verbosityLevelMap = $verbosityLevelMap; } } /** * {@inheritdoc} */ public function isHandling(array $record) { return $this->updateLevel() && parent::isHandling($record); } /** * {@inheritdoc} */ public function handle(array $record) { // we have to update the logging level each time because the verbosity of the // console output might have changed in the meantime (it is not immutable) return $this->updateLevel() && parent::handle($record); } /** * Sets the console output to use for printing logs. */ public function setOutput(OutputInterface $output) { $this->output = $output; } /** * Disables the output. */ public function close() { $this->output = null; parent::close(); } /** * Before a command is executed, the handler gets activated and the console output * is set in order to know where to write the logs. */ public function onCommand(ConsoleCommandEvent $event) { $output = $event->getOutput(); if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->setOutput($output); } /** * After a command has been executed, it disables the output. */ public function onTerminate(ConsoleTerminateEvent $event) { $this->close(); } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array( ConsoleEvents::COMMAND => array('onCommand', 255), ConsoleEvents::TERMINATE => array('onTerminate', -255), ); } /** * {@inheritdoc} */ protected function write(array $record) { // at this point we've determined for sure that we want to output the record, so use the output's own verbosity $this->output->write((string) $record['formatted'], false, $this->output->getVerbosity()); } /** * {@inheritdoc} */ protected function getDefaultFormatter() { if (!class_exists(CliDumper::class)) { return new LineFormatter(); } if (!$this->output) { return new ConsoleFormatter(); } return new ConsoleFormatter(array( 'colors' => $this->output->isDecorated(), 'multiline' => OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity(), )); } /** * Updates the logging level based on the verbosity setting of the console output. * * @return bool Whether the handler is enabled and verbosity is not set to quiet */ private function updateLevel() { if (null === $this->output) { return false; } $verbosity = $this->output->getVerbosity(); if (isset($this->verbosityLevelMap[$verbosity])) { $this->setLevel($this->verbosityLevelMap[$verbosity]); } else { $this->setLevel(Logger::DEBUG); } return true; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php000066400000000000000000000034711324732107100247100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; @trigger_error('The '.__NAMESPACE__.'\DebugHandler class is deprecated since Symfony 3.2 and will be removed in 4.0. Use Symfony\Bridge\Monolog\Processor\DebugProcessor instead.', E_USER_DEPRECATED); use Monolog\Logger; use Monolog\Handler\TestHandler; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** * DebugLogger. * * @author Jordi Boggiano * * @deprecated since version 3.2, to be removed in 4.0. Use Symfony\Bridge\Monolog\Processor\DebugProcessor instead. */ class DebugHandler extends TestHandler implements DebugLoggerInterface { /** * {@inheritdoc} */ public function getLogs() { $records = array(); foreach ($this->records as $record) { $records[] = array( 'timestamp' => $record['datetime']->getTimestamp(), 'message' => $record['message'], 'priority' => $record['level'], 'priorityName' => $record['level_name'], 'context' => $record['context'], 'channel' => isset($record['channel']) ? $record['channel'] : '', ); } return $records; } /** * {@inheritdoc} */ public function countErrors() { $cnt = 0; $levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY); foreach ($levels as $level) { if (isset($this->recordsByLevel[$level])) { $cnt += count($this->recordsByLevel[$level]); } } return $cnt; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/000077500000000000000000000000001324732107100245665ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php000066400000000000000000000030601324732107100325770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler\FingersCrossed; use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpFoundation\RequestStack; /** * Activation strategy that ignores 404s for certain URLs. * * @author Jordi Boggiano * @author Fabien Potencier */ class NotFoundActivationStrategy extends ErrorLevelActivationStrategy { private $blacklist; private $requestStack; public function __construct(RequestStack $requestStack, array $excludedUrls, $actionLevel) { parent::__construct($actionLevel); $this->requestStack = $requestStack; $this->blacklist = '{('.implode('|', $excludedUrls).')}i'; } public function isHandlerActivated(array $record) { $isActivated = parent::isHandlerActivated($record); if ( $isActivated && isset($record['context']['exception']) && $record['context']['exception'] instanceof HttpException && $record['context']['exception']->getStatusCode() == 404 && ($request = $this->requestStack->getMasterRequest()) ) { return !preg_match($this->blacklist, $request->getPathInfo()); } return $isActivated; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php000066400000000000000000000035611324732107100251170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpFoundation\Response; /** * FirePHPHandler. * * @author Jordi Boggiano */ class FirePHPHandler extends BaseFirePHPHandler { private $headers = array(); /** * @var Response */ private $response; /** * Adds the headers to the response once it's created. */ public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $event->getRequest()->headers->get('User-Agent')) && !$event->getRequest()->headers->has('X-FirePHP-Version')) { $this->sendHeaders = false; $this->headers = array(); return; } $this->response = $event->getResponse(); foreach ($this->headers as $header => $content) { $this->response->headers->set($header, $content); } $this->headers = array(); } /** * {@inheritdoc} */ protected function sendHeader($header, $content) { if (!$this->sendHeaders) { return; } if ($this->response) { $this->response->headers->set($header, $content); } else { $this->headers[$header] = $content; } } /** * Override default behavior since we check the user agent in onKernelResponse. */ protected function headersAccepted() { return true; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php000066400000000000000000000060601324732107100255670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\AbstractHandler; use Monolog\Logger; use Symfony\Bridge\Monolog\Formatter\VarDumperFormatter; /** * @author Grégoire Pineau */ class ServerLogHandler extends AbstractHandler { private $host; private $context; private $socket; public function __construct($host, $level = Logger::DEBUG, $bubble = true, $context = array()) { parent::__construct($level, $bubble); if (false === strpos($host, '://')) { $host = 'tcp://'.$host; } $this->host = $host; $this->context = stream_context_create($context); } /** * {@inheritdoc} */ public function handle(array $record) { if (!$this->isHandling($record)) { return false; } set_error_handler(self::class.'::nullErrorHandler'); try { if (!$this->socket = $this->socket ?: $this->createSocket()) { return false === $this->bubble; } } finally { restore_error_handler(); } $recordFormatted = $this->formatRecord($record); set_error_handler(self::class.'::nullErrorHandler'); try { if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) { stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); // Let's retry: the persistent connection might just be stale if ($this->socket = $this->createSocket()) { stream_socket_sendto($this->socket, $recordFormatted); } } } finally { restore_error_handler(); } return false === $this->bubble; } /** * {@inheritdoc} */ protected function getDefaultFormatter() { return new VarDumperFormatter(); } private static function nullErrorHandler() { } private function createSocket() { $socket = stream_socket_client($this->host, $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_PERSISTENT, $this->context); if ($socket) { stream_set_blocking($socket, false); } return $socket; } private function formatRecord(array $record) { if ($this->processors) { foreach ($this->processors as $processor) { $record = call_user_func($processor, $record); } } $recordFormatted = $this->getFormatter()->format($record); foreach (array('log_uuid', 'uuid', 'uid') as $key) { if (isset($record['extra'][$key])) { $recordFormatted['log_id'] = $record['extra'][$key]; break; } } return base64_encode(serialize($recordFormatted))."\n"; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php000066400000000000000000000040421324732107100261030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; /** * Extended SwiftMailerHandler that flushes mail queue if necessary. * * @author Philipp Kräutli */ class SwiftMailerHandler extends BaseSwiftMailerHandler { protected $transport; protected $instantFlush = false; public function setTransport(\Swift_Transport $transport) { $this->transport = $transport; } /** * After the kernel has been terminated we will always flush messages. */ public function onKernelTerminate(PostResponseEvent $event) { $this->instantFlush = true; } /** * After the CLI application has been terminated we will always flush messages. */ public function onCliTerminate(ConsoleTerminateEvent $event) { $this->instantFlush = true; } /** * {@inheritdoc} */ protected function send($content, array $records) { parent::send($content, $records); if ($this->instantFlush) { $this->flushMemorySpool(); } } /** * Flushes the mail queue if a memory spool is used. */ private function flushMemorySpool() { $mailerTransport = $this->mailer->getTransport(); if (!$mailerTransport instanceof \Swift_Transport_SpoolTransport) { return; } $spool = $mailerTransport->getSpool(); if (!$spool instanceof \Swift_MemorySpool) { return; } if (null === $this->transport) { throw new \Exception('No transport available to flush mail queue'); } $spool->flushQueue($this->transport); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/LICENSE000066400000000000000000000020511324732107100212740ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Bridge/Monolog/Logger.php000066400000000000000000000032671324732107100222310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog; use Monolog\Logger as BaseLogger; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** * Logger. * * @author Fabien Potencier */ class Logger extends BaseLogger implements DebugLoggerInterface { /** * {@inheritdoc} */ public function getLogs() { if ($logger = $this->getDebugLogger()) { return $logger->getLogs(); } return array(); } /** * {@inheritdoc} */ public function countErrors() { if ($logger = $this->getDebugLogger()) { return $logger->countErrors(); } return 0; } /** * {@inheritdoc} */ public function clear() { if (($logger = $this->getDebugLogger()) && method_exists($logger, 'clear')) { $logger->clear(); } } /** * Returns a DebugLoggerInterface instance if one is registered with this logger. * * @return DebugLoggerInterface|null A DebugLoggerInterface instance or null if none is registered */ private function getDebugLogger() { foreach ($this->processors as $processor) { if ($processor instanceof DebugLoggerInterface) { return $processor; } } foreach ($this->handlers as $handler) { if ($handler instanceof DebugLoggerInterface) { return $handler; } } } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Processor/000077500000000000000000000000001324732107100222505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php000066400000000000000000000027671324732107100257230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Processor; use Monolog\Logger; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; class DebugProcessor implements DebugLoggerInterface { private $records = array(); private $errorCount = 0; public function __invoke(array $record) { $this->records[] = array( 'timestamp' => $record['datetime']->getTimestamp(), 'message' => $record['message'], 'priority' => $record['level'], 'priorityName' => $record['level_name'], 'context' => $record['context'], 'channel' => isset($record['channel']) ? $record['channel'] : '', ); switch ($record['level']) { case Logger::ERROR: case Logger::CRITICAL: case Logger::ALERT: case Logger::EMERGENCY: ++$this->errorCount; } return $record; } /** * {@inheritdoc} */ public function getLogs() { return $this->records; } /** * {@inheritdoc} */ public function countErrors() { return $this->errorCount; } /** * {@inheritdoc} */ public function clear() { $this->records = array(); $this->errorCount = 0; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php000066400000000000000000000022011324732107100257340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Processor; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; /** * Adds the current security token to the log entry. * * @author Dany Maillard */ class TokenProcessor { private $tokenStorage; public function __construct(TokenStorageInterface $tokenStorage) { $this->tokenStorage = $tokenStorage; } public function __invoke(array $records) { $records['extra']['token'] = null; if (null !== $token = $this->tokenStorage->getToken()) { $records['extra']['token'] = array( 'username' => $token->getUsername(), 'authenticated' => $token->isAuthenticated(), 'roles' => array_map(function ($role) { return $role->getRole(); }, $token->getRoles()), ); } return $records; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php000066400000000000000000000020331324732107100253740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Processor; use Monolog\Processor\WebProcessor as BaseWebProcessor; use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** * WebProcessor override to read from the HttpFoundation's Request. * * @author Jordi Boggiano */ class WebProcessor extends BaseWebProcessor { public function __construct(array $extraFields = null) { // Pass an empty array as the default null value would access $_SERVER parent::__construct(array(), $extraFields); } public function onKernelRequest(GetResponseEvent $event) { if ($event->isMasterRequest()) { $this->serverData = $event->getRequest()->server->all(); $this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp(); } } } symfony-3.4.6/src/Symfony/Bridge/Monolog/README.md000066400000000000000000000006221324732107100215500ustar00rootroot00000000000000Monolog Bridge ============== Provides integration for Monolog with various Symfony components. Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/000077500000000000000000000000001324732107100213735ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Handler/000077500000000000000000000000001324732107100227505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php000066400000000000000000000204321324732107100272220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Tests\Handler; use Monolog\Logger; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Console\Command\Command; /** * Tests the ConsoleHandler and also the ConsoleFormatter. * * @author Tobias Schultze */ class ConsoleHandlerTest extends TestCase { public function testConstructor() { $handler = new ConsoleHandler(null, false); $this->assertFalse($handler->getBubble(), 'the bubble parameter gets propagated'); } public function testIsHandling() { $handler = new ConsoleHandler(); $this->assertFalse($handler->isHandling(array()), '->isHandling returns false when no output is set'); } /** * @dataProvider provideVerbosityMappingTests */ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array()) { $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output ->expects($this->atLeastOnce()) ->method('getVerbosity') ->will($this->returnValue($verbosity)) ; $handler = new ConsoleHandler($output, true, $map); $this->assertSame($isHandling, $handler->isHandling(array('level' => $level)), '->isHandling returns correct value depending on console verbosity and log level' ); // check that the handler actually outputs the record if it handles it $levelName = Logger::getLevelName($level); $levelName = sprintf('%-9s', $levelName); $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock(); $realOutput->setVerbosity($verbosity); if ($realOutput->isDebug()) { $log = "16:21:54 $levelName [app] My info message\n[]\n[]\n"; } else { $log = "16:21:54 $levelName [app] My info message [] []\n"; } $realOutput ->expects($isHandling ? $this->once() : $this->never()) ->method('doWrite') ->with($log, false); $handler = new ConsoleHandler($realOutput, true, $map); $infoRecord = array( 'message' => 'My info message', 'context' => array(), 'level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array(), ); $this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.'); } public function provideVerbosityMappingTests() { return array( array(OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true), array(OutputInterface::VERBOSITY_QUIET, Logger::WARNING, false), array(OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true), array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false), array(OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true), array(OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false), array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true), array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false), array(OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true), array(OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true), array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, array( OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE, )), array(OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, array( OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE, )), ); } public function testVerbosityChanged() { $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output ->expects($this->at(0)) ->method('getVerbosity') ->will($this->returnValue(OutputInterface::VERBOSITY_QUIET)) ; $output ->expects($this->at(1)) ->method('getVerbosity') ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) ; $handler = new ConsoleHandler($output); $this->assertFalse($handler->isHandling(array('level' => Logger::NOTICE)), 'when verbosity is set to quiet, the handler does not handle the log' ); $this->assertTrue($handler->isHandling(array('level' => Logger::NOTICE)), 'since the verbosity of the output increased externally, the handler is now handling the log' ); } public function testGetFormatter() { $handler = new ConsoleHandler(); $this->assertInstanceOf('Symfony\Bridge\Monolog\Formatter\ConsoleFormatter', $handler->getFormatter(), '-getFormatter returns ConsoleFormatter by default' ); } public function testWritingAndFormatting() { $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output ->expects($this->any()) ->method('getVerbosity') ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) ; $output ->expects($this->once()) ->method('write') ->with("16:21:54 INFO [app] My info message\n[]\n[]\n") ; $handler = new ConsoleHandler(null, false); $handler->setOutput($output); $infoRecord = array( 'message' => 'My info message', 'context' => array(), 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array(), ); $this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.'); } public function testLogsFromListeners() { $output = new BufferedOutput(); $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $handler = new ConsoleHandler(null, false); $logger = new Logger('app'); $logger->pushHandler($handler); $dispatcher = new EventDispatcher(); $dispatcher->addListener(ConsoleEvents::COMMAND, function () use ($logger) { $logger->addInfo('Before command message.'); }); $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use ($logger) { $logger->addInfo('Before terminate message.'); }); $dispatcher->addSubscriber($handler); $dispatcher->addListener(ConsoleEvents::COMMAND, function () use ($logger) { $logger->addInfo('After command message.'); }); $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use ($logger) { $logger->addInfo('After terminate message.'); }); $event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output); $dispatcher->dispatch(ConsoleEvents::COMMAND, $event); $this->assertContains('Before command message.', $out = $output->fetch()); $this->assertContains('After command message.', $out); $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output, 0); $dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); $this->assertContains('Before terminate message.', $out = $output->fetch()); $this->assertContains('After terminate message.', $out); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/000077500000000000000000000000001324732107100256705ustar00rootroot00000000000000NotFoundActivationStrategyTest.php000066400000000000000000000041251324732107100344650ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Tests\Handler\FingersCrossed; use Monolog\Logger; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Exception\HttpException; class NotFoundActivationStrategyTest extends TestCase { /** * @dataProvider isActivatedProvider */ public function testIsActivated($url, $record, $expected) { $requestStack = new RequestStack(); $requestStack->push(Request::create($url)); $strategy = new NotFoundActivationStrategy($requestStack, array('^/foo', 'bar'), Logger::WARNING); $this->assertEquals($expected, $strategy->isHandlerActivated($record)); } public function isActivatedProvider() { return array( array('/test', array('level' => Logger::DEBUG), false), array('/foo', array('level' => Logger::DEBUG, 'context' => $this->getContextException(404)), false), array('/baz/bar', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false), array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false), array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true), array('/test', array('level' => Logger::ERROR), true), array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), true), array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true), ); } protected function getContextException($code) { return array('exception' => new HttpException($code)); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php000066400000000000000000000106231324732107100241650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Tests; use Monolog\Handler\TestHandler; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\DebugHandler; use Symfony\Bridge\Monolog\Processor\DebugProcessor; use Symfony\Bridge\Monolog\Logger; class LoggerTest extends TestCase { /** * @group legacy */ public function testGetLogsWithDebugHandler() { $handler = new DebugHandler(); $logger = new Logger(__METHOD__, array($handler)); $this->assertTrue($logger->error('error message')); $this->assertCount(1, $logger->getLogs()); } public function testGetLogsWithoutDebugProcessor() { $handler = new TestHandler(); $logger = new Logger(__METHOD__, array($handler)); $this->assertTrue($logger->error('error message')); $this->assertSame(array(), $logger->getLogs()); } /** * @group legacy */ public function testCountErrorsWithDebugHandler() { $handler = new DebugHandler(); $logger = new Logger(__METHOD__, array($handler)); $this->assertTrue($logger->debug('test message')); $this->assertTrue($logger->info('test message')); $this->assertTrue($logger->notice('test message')); $this->assertTrue($logger->warning('test message')); $this->assertTrue($logger->error('test message')); $this->assertTrue($logger->critical('test message')); $this->assertTrue($logger->alert('test message')); $this->assertTrue($logger->emergency('test message')); $this->assertSame(4, $logger->countErrors()); } /** * @group legacy */ public function testGetLogsWithDebugHandler2() { $logger = new Logger('test'); $logger->pushHandler(new DebugHandler()); $logger->addInfo('test'); $this->assertCount(1, $logger->getLogs()); list($record) = $logger->getLogs(); $this->assertEquals('test', $record['message']); $this->assertEquals(Logger::INFO, $record['priority']); } public function testCountErrorsWithoutDebugProcessor() { $handler = new TestHandler(); $logger = new Logger(__METHOD__, array($handler)); $this->assertTrue($logger->error('error message')); $this->assertSame(0, $logger->countErrors()); } public function testGetLogsWithDebugProcessor() { $handler = new TestHandler(); $processor = new DebugProcessor(); $logger = new Logger(__METHOD__, array($handler), array($processor)); $this->assertTrue($logger->error('error message')); $this->assertCount(1, $logger->getLogs()); } public function testCountErrorsWithDebugProcessor() { $handler = new TestHandler(); $processor = new DebugProcessor(); $logger = new Logger(__METHOD__, array($handler), array($processor)); $this->assertTrue($logger->debug('test message')); $this->assertTrue($logger->info('test message')); $this->assertTrue($logger->notice('test message')); $this->assertTrue($logger->warning('test message')); $this->assertTrue($logger->error('test message')); $this->assertTrue($logger->critical('test message')); $this->assertTrue($logger->alert('test message')); $this->assertTrue($logger->emergency('test message')); $this->assertSame(4, $logger->countErrors()); } public function testGetLogsWithDebugProcessor2() { $handler = new TestHandler(); $logger = new Logger('test', array($handler)); $logger->pushProcessor(new DebugProcessor()); $logger->addInfo('test'); $this->assertCount(1, $logger->getLogs()); list($record) = $logger->getLogs(); $this->assertEquals('test', $record['message']); $this->assertEquals(Logger::INFO, $record['priority']); } public function testClear() { $handler = new TestHandler(); $logger = new Logger('test', array($handler)); $logger->pushProcessor(new DebugProcessor()); $logger->addInfo('test'); $logger->clear(); $this->assertEmpty($logger->getLogs()); $this->assertSame(0, $logger->countErrors()); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Processor/000077500000000000000000000000001324732107100233525ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php000066400000000000000000000030031324732107100276770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Tests\Processor; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Processor\TokenProcessor; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; /** * Tests the TokenProcessor. * * @author Dany Maillard */ class TokenProcessorTest extends TestCase { public function testProcessor() { $token = new UsernamePasswordToken('user', 'password', 'provider', array('ROLE_USER')); $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage->method('getToken')->willReturn($token); $processor = new TokenProcessor($tokenStorage); $record = array('extra' => array()); $record = $processor($record); $this->assertArrayHasKey('token', $record['extra']); $this->assertEquals($token->getUsername(), $record['extra']['token']['username']); $this->assertEquals($token->isAuthenticated(), $record['extra']['token']['authenticated']); $roles = array_map(function ($role) { return $role->getRole(); }, $token->getRoles()); $this->assertEquals($roles, $record['extra']['token']['roles']); } } symfony-3.4.6/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php000066400000000000000000000110421324732107100273360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Monolog\Tests\Processor; use Monolog\Logger; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Processor\WebProcessor; use Symfony\Component\HttpFoundation\Request; class WebProcessorTest extends TestCase { public function testUsesRequestServerData() { list($event, $server) = $this->createRequestEvent(); $processor = new WebProcessor(); $processor->onKernelRequest($event); $record = $processor($this->getRecord()); $this->assertCount(5, $record['extra']); $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']); $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); } public function testUseRequestClientIp() { Request::setTrustedProxies(array('192.168.0.1'), Request::HEADER_X_FORWARDED_ALL); list($event, $server) = $this->createRequestEvent(array('X_FORWARDED_FOR' => '192.168.0.2')); $processor = new WebProcessor(); $processor->onKernelRequest($event); $record = $processor($this->getRecord()); $this->assertCount(5, $record['extra']); $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); $this->assertEquals($server['X_FORWARDED_FOR'], $record['extra']['ip']); $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); } public function testCanBeConstructedWithExtraFields() { if (!$this->isExtraFieldsSupported()) { $this->markTestSkipped('WebProcessor of the installed Monolog version does not support $extraFields parameter'); } list($event, $server) = $this->createRequestEvent(); $processor = new WebProcessor(array('url', 'referrer')); $processor->onKernelRequest($event); $record = $processor($this->getRecord()); $this->assertCount(2, $record['extra']); $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); } /** * @return array */ private function createRequestEvent($additionalServerParameters = array()) { $server = array_merge( array( 'REQUEST_URI' => 'A', 'REMOTE_ADDR' => '192.168.0.1', 'REQUEST_METHOD' => 'C', 'SERVER_NAME' => 'D', 'HTTP_REFERER' => 'E', ), $additionalServerParameters ); $request = new Request(); $request->server->replace($server); $request->headers->replace($server); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); $event->expects($this->any()) ->method('isMasterRequest') ->will($this->returnValue(true)); $event->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)); return array($event, $server); } /** * @param int $level * @param string $message * * @return array Record */ private function getRecord($level = Logger::WARNING, $message = 'test') { return array( 'message' => $message, 'context' => array(), 'level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'test', 'datetime' => new \DateTime(), 'extra' => array(), ); } private function isExtraFieldsSupported() { $monologWebProcessorClass = new \ReflectionClass('Monolog\Processor\WebProcessor'); foreach ($monologWebProcessorClass->getConstructor()->getParameters() as $parameter) { if ('extraFields' === $parameter->getName()) { return true; } } return false; } } symfony-3.4.6/src/Symfony/Bridge/Monolog/composer.json000066400000000000000000000032101324732107100230070ustar00rootroot00000000000000{ "name": "symfony/monolog-bridge", "type": "symfony-bridge", "description": "Symfony Monolog Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "monolog/monolog": "~1.19", "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "require-dev": { "symfony/console": "~2.8|~3.0|~4.0", "symfony/event-dispatcher": "~2.8|~3.0|~4.0", "symfony/security-core": "~2.8|~3.0|~4.0", "symfony/var-dumper": "~3.3|~4.0" }, "conflict": { "symfony/http-foundation": "<3.3" }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings. You need version ~2.3 of the console for it.", "symfony/event-dispatcher": "Needed when using log messages in console commands.", "symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler." }, "autoload": { "psr-4": { "Symfony\\Bridge\\Monolog\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bridge/Monolog/phpunit.xml.dist000066400000000000000000000015621324732107100234500ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Bridge/PhpUnit/000077500000000000000000000000001324732107100202465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/PhpUnit/.gitignore000066400000000000000000000000421324732107100222320ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Bridge/PhpUnit/CHANGELOG.md000066400000000000000000000012531324732107100220600ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added a `CoverageListener` to enhance the code coverage report * all deprecations but those from tests marked with `@group legacy` are always displayed when not in `weak` mode 3.3.0 ----- * using the `testLegacy` prefix in method names to mark a test as legacy is deprecated, use the `@group legacy` notation instead * using the `Legacy` prefix in class names to mark a test as legacy is deprecated, use the `@group legacy` notation instead 3.1.0 ----- * passing a numerically indexed array to the constructor of the `SymfonyTestsListenerTrait` is deprecated, pass an array of namespaces indexed by the mocked feature instead symfony-3.4.6/src/Symfony/Bridge/PhpUnit/ClockMock.php000066400000000000000000000044431324732107100226310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit; /** * @author Nicolas Grekas */ class ClockMock { private static $now; public static function withClockMock($enable = null) { if (null === $enable) { return null !== self::$now; } self::$now = is_numeric($enable) ? (float) $enable : ($enable ? microtime(true) : null); } public static function time() { if (null === self::$now) { return \time(); } return (int) self::$now; } public static function sleep($s) { if (null === self::$now) { return \sleep($s); } self::$now += (int) $s; return 0; } public static function usleep($us) { if (null === self::$now) { return \usleep($us); } self::$now += $us / 1000000; } public static function microtime($asFloat = false) { if (null === self::$now) { return \microtime($asFloat); } if ($asFloat) { return self::$now; } return sprintf('%0.6f %d', self::$now - (int) self::$now, (int) self::$now); } public static function register($class) { $self = get_called_class(); $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); } elseif (0 === strpos($class, 'Tests\\')) { $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { if (function_exists($ns.'\time')) { continue; } eval(<< * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit; if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV5', 'Symfony\Bridge\PhpUnit\CoverageListener'); } elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV6', 'Symfony\Bridge\PhpUnit\CoverageListener'); } else { class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV7', 'Symfony\Bridge\PhpUnit\CoverageListener'); } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php000066400000000000000000000325331324732107100255320ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit; /** * Catch deprecation notices and print a summary report at the end of the test suite. * * @author Nicolas Grekas */ class DeprecationErrorHandler { const MODE_WEAK = 'weak'; const MODE_WEAK_VENDORS = 'weak_vendors'; const MODE_DISABLED = 'disabled'; private static $isRegistered = false; /** * Registers and configures the deprecation handler. * * The following reporting modes are supported: * - use "weak" to hide the deprecation report but keep a global count; * - use "weak_vendors" to act as "weak" but only for vendors; * - use "/some-regexp/" to stop the test suite whenever a deprecation * message matches the given regular expression; * - use a number to define the upper bound of allowed deprecations, * making the test suite fail whenever more notices are trigerred. * * @param int|string|false $mode The reporting mode, defaults to not allowing any deprecations */ public static function register($mode = 0) { if (self::$isRegistered) { return; } $UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\'; $getMode = function () use ($mode) { static $memoizedMode = false; if (false !== $memoizedMode) { return $memoizedMode; } if (false === $mode) { $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); } if (DeprecationErrorHandler::MODE_WEAK !== $mode && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) { $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; } return $memoizedMode = $mode; }; $inVendors = function ($path) { /** @var string[] absolute paths to vendor directories */ static $vendors; if (null === $vendors) { foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $v = dirname(dirname($r->getFileName())); if (file_exists($v.'/composer/installed.json')) { $vendors[] = $v; } } } } $realPath = realpath($path); if (false === $realPath && '-' !== $path && 'Standard input code' !== $path) { return true; } foreach ($vendors as $vendor) { if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) { return true; } } return false; }; $deprecations = array( 'unsilencedCount' => 0, 'remainingCount' => 0, 'legacyCount' => 0, 'otherCount' => 0, 'remaining vendorCount' => 0, 'unsilenced' => array(), 'remaining' => array(), 'legacy' => array(), 'other' => array(), 'remaining vendor' => array(), ); $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { $mode = $getMode(); if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) { $ErrorHandler = $UtilPrefix.'ErrorHandler'; return $ErrorHandler::handleError($type, $msg, $file, $line, $context); } $trace = debug_backtrace(true); $group = 'other'; $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file); $i = count($trace); while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { // No-op } if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) { if (isset($trace[$i]['class']) && in_array($trace[$i]['class'], array('Symfony\Bridge\PhpUnit\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'), true)) { $parsedMsg = unserialize($msg); $msg = $parsedMsg['deprecation']; $class = $parsedMsg['class']; $method = $parsedMsg['method']; // If the deprecation has been triggered via // \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest() // then we need to use the serialized information to determine // if the error has been triggered from vendor code. $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); } else { $class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class']; $method = $trace[$i]['function']; } $Test = $UtilPrefix.'Test'; if (0 !== error_reporting()) { $group = 'unsilenced'; } elseif (0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') || in_array('legacy', $Test::getGroups($class, $method), true) ) { $group = 'legacy'; } elseif ($isVendor) { $group = 'remaining vendor'; } else { $group = 'remaining'; } if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $msg)) { $e = new \Exception($msg); $r = new \ReflectionProperty($e, 'trace'); $r->setAccessible(true); $r->setValue($e, array_slice($trace, 1, $i)); echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':'; echo "\n".$msg; echo "\nStack trace:"; echo "\n".str_replace(' '.getcwd().DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString()); echo "\n"; exit(1); } if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) { $ref = &$deprecations[$group][$msg]['count']; ++$ref; $ref = &$deprecations[$group][$msg][$class.'::'.$method]; ++$ref; } } elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) { $ref = &$deprecations[$group][$msg]['count']; ++$ref; } ++$deprecations[$group.'Count']; }; $oldErrorHandler = set_error_handler($deprecationHandler); if (null !== $oldErrorHandler) { restore_error_handler(); if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) { restore_error_handler(); self::register($mode); } } else { self::$isRegistered = true; if (self::hasColorSupport()) { $colorize = function ($str, $red) { $color = $red ? '41;37' : '43;30'; return "\x1B[{$color}m{$str}\x1B[0m"; }; } else { $colorize = function ($str) { return $str; }; } register_shutdown_function(function () use ($getMode, &$deprecations, $deprecationHandler, $colorize) { $mode = $getMode(); if (isset($mode[0]) && '/' === $mode[0]) { return; } $currErrorHandler = set_error_handler('var_dump'); restore_error_handler(); if (DeprecationErrorHandler::MODE_WEAK === $mode) { $colorize = function ($str) { return $str; }; } if ($currErrorHandler !== $deprecationHandler) { echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n"; } $cmp = function ($a, $b) { return $b['count'] - $a['count']; }; $groups = array('unsilenced', 'remaining'); if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) { $groups[] = 'remaining vendor'; } array_push($groups, 'legacy', 'other'); $displayDeprecations = function ($deprecations) use ($colorize, $cmp, $groups) { foreach ($groups as $group) { if ($deprecations[$group.'Count']) { echo "\n", $colorize( sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']), 'legacy' !== $group && 'remaining vendor' !== $group ), "\n"; uasort($deprecations[$group], $cmp); foreach ($deprecations[$group] as $msg => $notices) { echo "\n ", $notices['count'], 'x: ', $msg, "\n"; arsort($notices); foreach ($notices as $method => $count) { if ('count' !== $method) { echo ' ', $count, 'x in ', preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method), "\n"; } } } } } if (!empty($notices)) { echo "\n"; } }; $displayDeprecations($deprecations); // store failing status $isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; // reset deprecations array foreach ($deprecations as $group => $arrayOrInt) { $deprecations[$group] = is_int($arrayOrInt) ? 0 : array(); } register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) { foreach ($deprecations as $group => $arrayOrInt) { if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) { echo "Shutdown-time deprecations:\n"; break; } } $displayDeprecations($deprecations); if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { exit(1); } }); }); } } public static function collectDeprecations($outputFile) { $deprecations = array(); $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { if ($previousErrorHandler) { return $previousErrorHandler($type, $msg, $file, $line, $context); } static $autoload = true; $ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler', $autoload) ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; $autoload = false; return $ErrorHandler::handleError($type, $msg, $file, $line, $context); } $deprecations[] = array(error_reporting(), $msg, $file); }); register_shutdown_function(function () use ($outputFile, &$deprecations) { file_put_contents($outputFile, serialize($deprecations)); }); } private static function hasColorSupport() { if ('\\' === DIRECTORY_SEPARATOR) { return defined('STDOUT') && function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT) || '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); } return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/DnsMock.php000066400000000000000000000136361324732107100223260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit; /** * @author Nicolas Grekas */ class DnsMock { private static $hosts = array(); private static $dnsTypes = array( 'A' => DNS_A, 'MX' => DNS_MX, 'NS' => DNS_NS, 'SOA' => DNS_SOA, 'PTR' => DNS_PTR, 'CNAME' => DNS_CNAME, 'AAAA' => DNS_AAAA, 'A6' => DNS_A6, 'SRV' => DNS_SRV, 'NAPTR' => DNS_NAPTR, 'TXT' => DNS_TXT, 'HINFO' => DNS_HINFO, ); /** * Configures the mock values for DNS queries. * * @param array $hosts Mocked hosts as keys, arrays of DNS records as returned by dns_get_record() as values */ public static function withMockedHosts(array $hosts) { self::$hosts = $hosts; } public static function checkdnsrr($hostname, $type = 'MX') { if (!self::$hosts) { return \checkdnsrr($hostname, $type); } if (isset(self::$hosts[$hostname])) { $type = strtoupper($type); foreach (self::$hosts[$hostname] as $record) { if ($record['type'] === $type) { return true; } if ('ANY' === $type && isset(self::$dnsTypes[$record['type']]) && 'HINFO' !== $record['type']) { return true; } } } return false; } public static function getmxrr($hostname, &$mxhosts, &$weight = null) { if (!self::$hosts) { return \getmxrr($hostname, $mxhosts, $weight); } $mxhosts = $weight = array(); if (isset(self::$hosts[$hostname])) { foreach (self::$hosts[$hostname] as $record) { if ('MX' === $record['type']) { $mxhosts[] = $record['host']; $weight[] = $record['pri']; } } } return (bool) $mxhosts; } public static function gethostbyaddr($ipAddress) { if (!self::$hosts) { return \gethostbyaddr($ipAddress); } foreach (self::$hosts as $hostname => $records) { foreach ($records as $record) { if ('A' === $record['type'] && $ipAddress === $record['ip']) { return $hostname; } if ('AAAA' === $record['type'] && $ipAddress === $record['ipv6']) { return $hostname; } } } return $ipAddress; } public static function gethostbyname($hostname) { if (!self::$hosts) { return \gethostbyname($hostname); } if (isset(self::$hosts[$hostname])) { foreach (self::$hosts[$hostname] as $record) { if ('A' === $record['type']) { return $record['ip']; } } } return $hostname; } public static function gethostbynamel($hostname) { if (!self::$hosts) { return \gethostbynamel($hostname); } $ips = false; if (isset(self::$hosts[$hostname])) { $ips = array(); foreach (self::$hosts[$hostname] as $record) { if ('A' === $record['type']) { $ips[] = $record['ip']; } } } return $ips; } public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = null, &$addtl = null, $raw = false) { if (!self::$hosts) { return \dns_get_record($hostname, $type, $authns, $addtl, $raw); } $records = false; if (isset(self::$hosts[$hostname])) { if (DNS_ANY === $type) { $type = DNS_ALL; } $records = array(); foreach (self::$hosts[$hostname] as $record) { if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) { $records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record); } } } return $records; } public static function register($class) { $self = get_called_class(); $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); } elseif (0 === strpos($class, 'Tests\\')) { $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { if (function_exists($ns.'\checkdnsrr')) { continue; } eval(<< * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; /** * {@inheritdoc} * * @internal */ class Command extends \PHPUnit_TextUI_Command { /** * {@inheritdoc} */ protected function createRunner() { return new TestRunner($this->arguments['loader']); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php000066400000000000000000000015731324732107100263140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; /** * CoverageListener adds `@covers ` on each test suite when possible * to make the code coverage more accurate. * * @author Grégoire Pineau * * @internal */ class CoverageListenerForV5 extends \PHPUnit_Framework_BaseTestListener { private $trait; public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) { $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); } public function startTest(\PHPUnit_Framework_Test $test) { $this->trait->startTest($test); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php000066400000000000000000000016321324732107100263110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\BaseTestListener; use PHPUnit\Framework\Test; /** * CoverageListener adds `@covers ` on each test suite when possible * to make the code coverage more accurate. * * @author Grégoire Pineau * * @internal */ class CoverageListenerForV6 extends BaseTestListener { private $trait; public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) { $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); } public function startTest(Test $test) { $this->trait->startTest($test); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php000066400000000000000000000020201324732107100263020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; use PHPUnit\Framework\TestSuite; /** * CoverageListener adds `@covers ` on each test suite when possible * to make the code coverage more accurate. * * @author Grégoire Pineau * * @internal */ class CoverageListenerForV7 implements TestListener { use TestListenerDefaultImplementation; private $trait; public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) { $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); } public function startTestSuite(TestSuite $suite): void { $this->trait->startTest($test); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php000066400000000000000000000061761324732107100264420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Warning; /** * PHP 5.3 compatible trait-like shared implementation. * * @author Grégoire Pineau * * @internal */ class CoverageListenerTrait { private $sutFqcnResolver; private $warningOnSutNotFound; private $warnings; public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) { $this->sutFqcnResolver = $sutFqcnResolver; $this->warningOnSutNotFound = $warningOnSutNotFound; $this->warnings = array(); } public function startTest($test) { if (!$test instanceof TestCase) { return; } $annotations = $test->getAnnotations(); $ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing'); foreach ($ignoredAnnotations as $annotation) { if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) { return; } } $sutFqcn = $this->findSutFqcn($test); if (!$sutFqcn) { if ($this->warningOnSutNotFound) { $message = 'Could not find the tested class.'; // addWarning does not exist on old PHPUnit version if (method_exists($test->getTestResultObject(), 'addWarning') && class_exists(Warning::class)) { $test->getTestResultObject()->addWarning($test, new Warning($message), 0); } else { $this->warnings[] = sprintf("%s::%s\n%s", get_class($test), $test->getName(), $message); } } return; } $testClass = \PHPUnit\Util\Test::class; if (!class_exists($testClass, false)) { $testClass = \PHPUnit_Util_Test::class; } $r = new \ReflectionProperty($testClass, 'annotationCache'); $r->setAccessible(true); $cache = $r->getValue(); $cache = array_replace_recursive($cache, array( get_class($test) => array( 'covers' => array($sutFqcn), ), )); $r->setValue($testClass, $cache); } private function findSutFqcn($test) { if ($this->sutFqcnResolver) { $resolver = $this->sutFqcnResolver; return $resolver($test); } $class = get_class($test); $sutFqcn = str_replace('\\Tests\\', '\\', $class); $sutFqcn = preg_replace('{Test$}', '', $sutFqcn); if (!class_exists($sutFqcn)) { return; } return $sutFqcn; } public function __destruct() { if (!$this->warnings) { return; } echo "\n"; foreach ($this->warnings as $key => $warning) { echo sprintf("%d) %s\n", ++$key, $warning); } } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php000066400000000000000000000026361324732107100272510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; /** * Collects and replays skipped tests. * * @author Nicolas Grekas * * @internal */ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener { private $trait; public function __construct(array $mockedNamespaces = array()) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } public function globalListenerDisabled() { $this->trait->globalListenerDisabled(); } public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) { $this->trait->startTestSuite($suite); } public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { $this->trait->addSkippedTest($test, $e, $time); } public function startTest(\PHPUnit_Framework_Test $test) { $this->trait->startTest($test); } public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) { $this->trait->addWarning($test, $e, $time); } public function endTest(\PHPUnit_Framework_Test $test, $time) { $this->trait->endTest($test, $time); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php000066400000000000000000000026361324732107100272520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\BaseTestListener; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; /** * Collects and replays skipped tests. * * @author Nicolas Grekas * * @internal */ class SymfonyTestsListenerForV6 extends BaseTestListener { private $trait; public function __construct(array $mockedNamespaces = array()) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } public function globalListenerDisabled() { $this->trait->globalListenerDisabled(); } public function startTestSuite(TestSuite $suite) { $this->trait->startTestSuite($suite); } public function addSkippedTest(Test $test, \Exception $e, $time) { $this->trait->addSkippedTest($test, $e, $time); } public function startTest(Test $test) { $this->trait->startTest($test); } public function addWarning(Test $test, Warning $e, $time) { $this->trait->addWarning($test, $e, $time); } public function endTest(Test $test, $time) { $this->trait->endTest($test, $time); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php000066400000000000000000000030561324732107100272500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; /** * Collects and replays skipped tests. * * @author Nicolas Grekas * * @internal */ class SymfonyTestsListenerForV7 implements TestListener { use TestListenerDefaultImplementation; private $trait; public function __construct(array $mockedNamespaces = array()) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } public function globalListenerDisabled() { $this->trait->globalListenerDisabled(); } public function startTestSuite(TestSuite $suite): void { $this->trait->startTestSuite($suite); } public function addSkippedTest(Test $test, \Throwable $t, float $time): void { $this->trait->addSkippedTest($test, $t, $time); } public function startTest(Test $test): void { $this->trait->startTest($test); } public function addWarning(Test $test, Warning $e, float $time): void { $this->trait->addWarning($test, $e, $time); } public function endTest(Test $test, float $time): void { $this->trait->endTest($test, $time); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php000066400000000000000000000354471324732107100274010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; use PHPUnit\Util\Blacklist; use Symfony\Bridge\PhpUnit\ClockMock; use Symfony\Bridge\PhpUnit\DnsMock; /** * PHP 5.3 compatible trait-like shared implementation. * * @author Nicolas Grekas * * @internal */ class SymfonyTestsListenerTrait { private static $globallyEnabled = false; private $state = -1; private $skippedFile = false; private $wasSkipped = array(); private $isSkipped = array(); private $expectedDeprecations = array(); private $gatheredDeprecations = array(); private $previousErrorHandler; private $testsWithWarnings; private $reportUselessTests; private $error; private $runsInSeparateProcess = false; /** * @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive) */ public function __construct(array $mockedNamespaces = array()) { if (class_exists('PHPUnit_Util_Blacklist')) { \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; } else { Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; } $warn = false; foreach ($mockedNamespaces as $type => $namespaces) { if (!is_array($namespaces)) { $namespaces = array($namespaces); } if (is_int($type)) { // @deprecated BC with v2.8 to v3.0 $type = 'time-sensitive'; $warn = true; } if ('time-sensitive' === $type) { foreach ($namespaces as $ns) { ClockMock::register($ns.'\DummyClass'); } } if ('dns-sensitive' === $type) { foreach ($namespaces as $ns) { DnsMock::register($ns.'\DummyClass'); } } } if (self::$globallyEnabled) { $this->state = -2; } else { self::$globallyEnabled = true; if ($warn) { echo "Clock-mocked namespaces for SymfonyTestsListener need to be nested in a \"time-sensitive\" key. This will be enforced in Symfony 4.0.\n"; } } } public function __destruct() { if (0 < $this->state) { file_put_contents($this->skippedFile, 'isSkipped, true).';'); } } public function globalListenerDisabled() { self::$globallyEnabled = false; $this->state = -1; } public function startTestSuite($suite) { if (class_exists('PHPUnit_Util_Blacklist', false)) { $Test = 'PHPUnit_Util_Test'; } else { $Test = 'PHPUnit\Util\Test'; } $suiteName = $suite->getName(); $this->testsWithWarnings = array(); foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { continue; } if (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) { $test->setPreserveGlobalState(false); } } if (-1 === $this->state) { echo "Testing $suiteName\n"; $this->state = 0; if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { AnnotationRegistry::registerUniqueLoader('class_exists'); } else { AnnotationRegistry::registerLoader('class_exists'); } } if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; if (file_exists($this->skippedFile)) { $this->state = 2; if (!$this->wasSkipped = require $this->skippedFile) { echo "All tests already ran successfully.\n"; $suite->setTests(array()); } } } $testSuites = array($suite); for ($i = 0; isset($testSuites[$i]); ++$i) { foreach ($testSuites[$i]->tests() as $test) { if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) { if (!class_exists($test->getName(), false)) { $testSuites[] = $test; continue; } $groups = $Test::getGroups($test->getName()); if (in_array('time-sensitive', $groups, true)) { ClockMock::register($test->getName()); } if (in_array('dns-sensitive', $groups, true)) { DnsMock::register($test->getName()); } } } } } elseif (2 === $this->state) { $skipped = array(); foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) || isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName][$test->getName()])) { $skipped[] = $test; } } $suite->setTests($skipped); } } public function addSkippedTest($test, \Exception $e, $time) { if (0 < $this->state) { if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) { $class = get_class($test); $method = $test->getName(); } else { $class = $test->getName(); $method = '*'; } $this->isSkipped[$class][$method] = 1; } } public function startTest($test) { if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { if (null !== $test->getTestResultObject()) { $this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything(); } // This event is triggered before the test is re-run in isolation if ($this->willBeIsolated($test)) { $this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec'); putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess); } if (class_exists('PHPUnit_Util_Blacklist', false)) { $Test = 'PHPUnit_Util_Test'; $AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError'; } else { $Test = 'PHPUnit\Util\Test'; $AssertionFailedError = 'PHPUnit\Framework\AssertionFailedError'; } $groups = $Test::getGroups(get_class($test), $test->getName(false)); if (!$this->runsInSeparateProcess) { if (in_array('time-sensitive', $groups, true)) { ClockMock::register(get_class($test)); ClockMock::withClockMock(true); } if (in_array('dns-sensitive', $groups, true)) { DnsMock::register(get_class($test)); } } $annotations = $Test::parseTestMethodAnnotations(get_class($test), $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { $test->getTestResultObject()->addError($test, new $AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); } if (isset($annotations['method']['expectedDeprecation'])) { if (!in_array('legacy', $groups, true)) { $this->error = new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'); } $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false); $this->expectedDeprecations = $annotations['method']['expectedDeprecation']; $this->previousErrorHandler = set_error_handler(array($this, 'handleError')); } } } public function addWarning($test, $e, $time) { if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) { $this->testsWithWarnings[$test->getName()] = true; } } public function endTest($test, $time) { if (class_exists('PHPUnit_Util_Blacklist', false)) { $Test = 'PHPUnit_Util_Test'; $BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner'; $Warning = 'PHPUnit_Framework_Warning'; } else { $Test = 'PHPUnit\Util\Test'; $BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner'; $Warning = 'PHPUnit\Framework\Warning'; } $className = get_class($test); $classGroups = $Test::getGroups($className); $groups = $Test::getGroups($className, $test->getName(false)); if (null !== $this->reportUselessTests) { $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests); $this->reportUselessTests = null; } if ($errored = null !== $this->error) { $test->getTestResultObject()->addError($test, $this->error, 0); $this->error = null; } if ($this->runsInSeparateProcess) { $deprecations = file_get_contents($this->runsInSeparateProcess); unlink($this->runsInSeparateProcess); putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null)); if ($deprecation[0]) { trigger_error($error, E_USER_DEPRECATED); } else { @trigger_error($error, E_USER_DEPRECATED); } } $this->runsInSeparateProcess = false; } if ($this->expectedDeprecations) { if (!in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) { $test->addToAssertionCount(count($this->expectedDeprecations)); } restore_error_handler(); if (!$errored && !in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) { try { $prefix = "@expectedDeprecation:\n"; $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); } catch (AssertionFailedError $e) { $test->getTestResultObject()->addFailure($test, $e, $time); } catch (\PHPUnit_Framework_AssertionFailedError $e) { $test->getTestResultObject()->addFailure($test, $e, $time); } } $this->expectedDeprecations = $this->gatheredDeprecations = array(); $this->previousErrorHandler = null; } if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { if (in_array('time-sensitive', $groups, true)) { ClockMock::withClockMock(false); } if (in_array('dns-sensitive', $groups, true)) { DnsMock::withMockedHosts(array()); } } if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $groups, true)) { $result = $test->getTestResultObject(); if (method_exists($result, 'addWarning')) { $result->addWarning($test, new $Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); } } if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $classGroups, true)) { $result = $test->getTestResultObject(); if (method_exists($result, 'addWarning')) { $result->addWarning($test, new $Warning('Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); } } } public function handleError($type, $msg, $file, $line, $context = array()) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { $h = $this->previousErrorHandler; return $h ? $h($type, $msg, $file, $line, $context) : false; } // If the message is serialized we need to extract the message. This occurs when the error is triggered by // by the isolated test path in \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest(). $parsedMsg = @unserialize($msg); if (is_array($parsedMsg)) { $msg = $parsedMsg['deprecation']; } if (error_reporting()) { $msg = 'Unsilenced deprecation: '.$msg; } $this->gatheredDeprecations[] = $msg; } /** * @param TestCase $test * * @return bool */ private function willBeIsolated($test) { if ($test->isInIsolation()) { return false; } $r = new \ReflectionProperty($test, 'runTestInSeparateProcess'); $r->setAccessible(true); return $r->getValue($test); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Legacy/TestRunner.php000066400000000000000000000022101324732107100242670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Legacy; /** * {@inheritdoc} * * @internal */ class TestRunner extends \PHPUnit_TextUI_TestRunner { /** * {@inheritdoc} */ protected function handleConfiguration(array &$arguments) { $listener = new SymfonyTestsListenerForV5(); $result = parent::handleConfiguration($arguments); $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); $registeredLocally = false; foreach ($arguments['listeners'] as $registeredListener) { if ($registeredListener instanceof SymfonyTestsListenerForV5) { $registeredListener->globalListenerDisabled(); $registeredLocally = true; break; } } if (!$registeredLocally) { $arguments['listeners'][] = $listener; } return $result; } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/README.md000066400000000000000000000007641324732107100215340ustar00rootroot00000000000000PHPUnit Bridge ============== Provides utilities for PHPUnit, especially user deprecation notices management. Resources --------- * [Documentation](https://symfony.com/doc/current/components/phpunit_bridge.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php000066400000000000000000000015051324732107100251550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit; if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); } elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); } else { class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/000077500000000000000000000000001324732107100213505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/CoverageListenerTest.php000066400000000000000000000033761324732107100261730ustar00rootroot00000000000000markTestSkipped('This test cannot be run on Windows.'); } if (defined('HHVM_VERSION')) { $this->markTestSkipped('This test cannot be run on HHVM.'); } exec('type phpdbg', $output, $returnCode); if (\PHP_VERSION_ID >= 70000 && 0 === $returnCode) { $php = 'phpdbg -qrr'; } else { exec('php --ri xdebug -d zend_extension=xdebug.so 2> /dev/null', $output, $returnCode); if (0 !== $returnCode) { $this->markTestSkipped('Xdebug is required to run this test.'); } $php = 'php -d zend_extension=xdebug.so'; } $dir = __DIR__.'/../Tests/Fixtures/coverage'; $phpunit = $_SERVER['argv'][0]; exec("$php $phpunit -c $dir/phpunit-without-listener.xml.dist $dir/tests/ --coverage-text", $output); $output = implode("\n", $output); $this->assertContains('FooCov', $output); exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text", $output); $output = implode("\n", $output); $this->assertNotContains('FooCov', $output); $this->assertContains("SutNotFoundTest::test\nCould not find the tested class.", $output); $this->assertNotContains("CoversTest::test\nCould not find the tested class.", $output); $this->assertNotContains("CoversDefaultClassTest::test\nCould not find the tested class.", $output); $this->assertNotContains("CoversNothingTest::test\nCould not find the tested class.", $output); } } symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/000077500000000000000000000000001324732107100261155ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt000066400000000000000000000035251324732107100304430ustar00rootroot00000000000000--TEST-- Test DeprecationErrorHandler in default mode --FILE-- testLegacyFoo(); $foo->testNonLegacyBar(); register_shutdown_function(function () { exit('I get precedence over any exit statements inside the deprecation error handler.'); }); ?> --EXPECTF-- Unsilenced deprecation notices (3) 2x: unsilenced foo deprecation 2x in FooTestCase::testLegacyFoo 1x: unsilenced bar deprecation 1x in FooTestCase::testNonLegacyBar Remaining deprecation notices (1) 1x: silenced bar deprecation 1x in FooTestCase::testNonLegacyBar Legacy deprecation notices (1) Other deprecation notices (1) 1x: root deprecation I get precedence over any exit statements inside the deprecation error handler. symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/deprecation.phar000066400000000000000000000152541324732107100312750ustar00rootroot00000000000000 2, 'c' => 'text/plain', 'cc' => 'text/plain', 'cpp' => 'text/plain', 'c++' => 'text/plain', 'dtd' => 'text/plain', 'h' => 'text/plain', 'log' => 'text/plain', 'rng' => 'text/plain', 'txt' => 'text/plain', 'xsd' => 'text/plain', 'php' => 1, 'inc' => 1, 'avi' => 'video/avi', 'bmp' => 'image/bmp', 'css' => 'text/css', 'gif' => 'image/gif', 'htm' => 'text/html', 'html' => 'text/html', 'htmls' => 'text/html', 'ico' => 'image/x-ico', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'js' => 'application/x-javascript', 'midi' => 'audio/midi', 'mid' => 'audio/midi', 'mod' => 'audio/mod', 'mov' => 'movie/quicktime', 'mp3' => 'audio/mp3', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'pdf' => 'application/pdf', 'png' => 'image/png', 'swf' => 'application/shockwave-flash', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wav' => 'audio/wav', 'xbm' => 'image/xbm', 'xml' => 'text/xml', ); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $basename = basename(__FILE__); if (!strpos($_SERVER['REQUEST_URI'], $basename)) { chdir(Extract_Phar::$temp); include $web; return; } $pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename)); if (!$pt || $pt == '/') { $pt = $web; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt); exit; } $a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt); if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) { header('HTTP/1.0 404 Not Found'); echo "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>"; exit; } $b = pathinfo($a); if (!isset($b['extension'])) { header('Content-Type: text/plain'); header('Content-Length: ' . filesize($a)); readfile($a); exit; } if (isset($mimes[$b['extension']])) { if ($mimes[$b['extension']] === 1) { include $a; exit; } if ($mimes[$b['extension']] === 2) { highlight_file($a); exit; } header('Content-Type: ' .$mimes[$b['extension']]); header('Content-Length: ' . filesize($a)); readfile($a); exit; } } class Extract_Phar { static $temp; static $origdir; const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'index.php'; const LEN = 6653; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); $L = unpack('V', $a = fread($fp, 4)); $m = ''; do { $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } $last = fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); if (strlen($m) < $L[1]) { die('ERROR: manifest length read was "' . strlen($m) .'" should be "' . $L[1] . '"'); } $info = self::_unpack($m); $f = $info['c']; if ($f & self::GZ) { if (!function_exists('gzinflate')) { die('Error: zlib extension is not enabled -' . ' gzinflate() function needed for zlib-compressed .phars'); } } if ($f & self::BZ2) { if (!function_exists('bzdecompress')) { die('Error: bzip2 extension is not enabled -' . ' bzdecompress() function needed for bz2-compressed .phars'); } } $temp = self::tmpdir(); if (!$temp || !is_writable($temp)) { $sessionpath = session_save_path(); if (strpos ($sessionpath, ";") !== false) $sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1); if (!file_exists($sessionpath) || !is_dir($sessionpath)) { die('Could not locate temporary directory to extract phar'); } $temp = $sessionpath; } $temp .= '/pharextract/'.basename(__FILE__, '.phar'); self::$temp = $temp; self::$origdir = getcwd(); @mkdir($temp, 0777, true); $temp = realpath($temp); if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) { self::_removeTmpFiles($temp, getcwd()); @mkdir($temp, 0777, true); @file_put_contents($temp . '/' . md5_file(__FILE__), ''); foreach ($info['m'] as $path => $file) { $a = !file_exists(dirname($temp . '/' . $path)); @mkdir(dirname($temp . '/' . $path), 0777, true); clearstatcache(); if ($path[strlen($path) - 1] == '/') { @mkdir($temp . '/' . $path, 0777); } else { file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp)); @chmod($temp . '/' . $path, 0666); } } } chdir($temp); if (!$return) { include self::START; } } static function tmpdir() { if (strpos(PHP_OS, 'WIN') !== false) { if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) { return $var; } if (is_dir('/temp') || mkdir('/temp')) { return realpath('/temp'); } return false; } if ($var = getenv('TMPDIR')) { return $var; } return realpath('/tmp'); } static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); $l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { $len = unpack('V', substr($m, $start, 4)); $start += 4; $savepath = substr($m, $start, $len[1]); $start += $len[1]; $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; $o += $ret['m'][$savepath][2]; $start += 24 + $ret['m'][$savepath][5]; $ret['c'] |= $ret['m'][$savepath][4] & self::MASK; } return $ret; } static function extractFile($path, $entry, $fp) { $data = ''; $c = $entry[2]; while ($c) { if ($c < 8192) { $data .= @fread($fp, $c); $c = 0; } else { $c -= 8192; $data .= @fread($fp, 8192); } } if ($entry[4] & self::GZ) { $data = gzinflate($data); } elseif ($entry[4] & self::BZ2) { $data = bzdecompress($data); } if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . $stat[7] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { die("Invalid internal .phar file (checksum error)"); } return $data; } static function _removeTmpFiles($temp, $origdir) { chdir($temp); foreach (glob('*') as $f) { if (file_exists($f)) { is_dir($f) ? @rmdir($f) : @unlink($f); if (file_exists($f) && is_dir($f)) { self::_removeTmpFiles($f, getcwd()); } } } @rmdir($temp); clearstatcache(); chdir($origdir); } } Extract_Phar::go(); __HALT_COMPILER(); ?>M�������������deprecation.phar�������deprecation.phpD���7OZD���+"6n������<?php @trigger_error('I come from… afar! :D', E_USER_DEPRECATED); M=4B/]@UkM@Q���GBMB����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/deprecation/�����������������0000775�0000000�0000000�00000000000�13247321071�0030412�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/deprecation/deprecation.php��0000664�0000000�0000000�00000000105�13247321071�0033414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php @trigger_error('I come from… afar! :D', E_USER_DEPRECATED); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt����������������0000664�0000000�0000000�00000001057�13247321071�0030564�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak mode --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=disabled'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; echo (int) set_error_handler('var_dump'); echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false); ?> --EXPECTF-- 00 ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/�����������������0000775�0000000�0000000�00000000000�13247321071�0030400�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/������������0000775�0000000�0000000�00000000000�13247321071�0031305�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/��������0000775�0000000�0000000�00000000000�13247321071�0032053�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������deprecation_riddled.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000001477�13247321071�0036502�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib����������������������������������������������������������������������������<?php eval(<<<'EOPHP' namespace PHPUnit\Util; class Test { public static function getGroups() { return array(); } } EOPHP ); @trigger_error('root deprecation', E_USER_DEPRECATED); class FooTestCase { public function testLegacyFoo() { @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); } public function testNonLegacyBar() { @trigger_error('silenced bar deprecation', E_USER_DEPRECATED); trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); } } $foo = new FooTestCase(); $foo->testLegacyFoo(); $foo->testNonLegacyBar(); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/autoload.php�����0000664�0000000�0000000�00000000073�13247321071�0032721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php require_once __DIR__.'/composer/autoload_real.php'; ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/��������0000775�0000000�0000000�00000000000�13247321071�0032227�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������autoload_real.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000054�13247321071�0035473�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer����������������������������������������������������������������������������<?php class ComposerAutoloaderInitFake { } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������installed.json��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000043�13247321071�0035017�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer����������������������������������������������������������������������������{"just here": "for the detection"} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php������������0000664�0000000�0000000�00000000246�13247321071�0031434�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $phar = new Phar(__DIR__.DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar'); $phar->buildFromDirectory(__DIR__.DIRECTORY_SEPARATOR.'deprecation'); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/regexp.phpt������������������0000664�0000000�0000000�00000001600�13247321071�0030301�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak mode --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=/foo/'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; @trigger_error('root deprecation', E_USER_DEPRECATED); class FooTestCase { public function testLegacyFoo() { @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); } } $foo = new FooTestCase(); $foo->testLegacyFoo(); ?> --EXPECTF-- Legacy deprecation triggered by FooTestCase::testLegacyFoo: silenced foo deprecation Stack trace: #%A(%d): FooTestCase->testLegacyFoo() #%d {main} ��������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt���0000664�0000000�0000000�00000003526�13247321071�0033433�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in default mode --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; @trigger_error('root deprecation', E_USER_DEPRECATED); eval(<<<'EOPHP' namespace PHPUnit\Util; class Test { public static function getGroups() { return array(); } } EOPHP ); class PHPUnit_Util_Test { public static function getGroups() { return array(); } } class FooTestCase { public function testLegacyFoo() { @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); } public function testNonLegacyBar() { @trigger_error('silenced bar deprecation', E_USER_DEPRECATED); trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); } } $foo = new FooTestCase(); $foo->testLegacyFoo(); $foo->testNonLegacyBar(); register_shutdown_function(function () { @trigger_error('root deprecation during shutdown', E_USER_DEPRECATED); }); ?> --EXPECTF-- Unsilenced deprecation notices (3) 2x: unsilenced foo deprecation 2x in FooTestCase::testLegacyFoo 1x: unsilenced bar deprecation 1x in FooTestCase::testNonLegacyBar Remaining deprecation notices (1) 1x: silenced bar deprecation 1x in FooTestCase::testNonLegacyBar Legacy deprecation notices (1) Other deprecation notices (1) 1x: root deprecation Shutdown-time deprecations: Other deprecation notices (1) 1x: root deprecation during shutdown ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt��������������������0000664�0000000�0000000�00000001515�13247321071�0027743�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak mode --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=weak'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; @trigger_error('root deprecation', E_USER_DEPRECATED); class FooTestCase { public function testLegacyFoo() { @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); } } $foo = new FooTestCase(); $foo->testLegacyFoo(); ?> --EXPECTF-- Unsilenced deprecation notices (1) Legacy deprecation notices (1) Other deprecation notices (1) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weak_vendors_on_eval_d_deprecation.phpt�������������������������������������������������������������0000664�0000000�0000000�00000001141�13247321071�0036002�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler�������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);") ?> --EXPECTF-- Other deprecation notices (1) 1x: who knows where I come from? �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weak_vendors_on_non_vendor.phpt���������������������������������������������������������������������0000664�0000000�0000000�00000003071�13247321071�0034346�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler�������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak vendors mode on a non vendor file --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; @trigger_error('root deprecation', E_USER_DEPRECATED); eval(<<<'EOPHP' namespace PHPUnit\Util; class Test { public static function getGroups() { return array(); } } EOPHP ); class FooTestCase { public function testLegacyFoo() { @trigger_error('silenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); } public function testNonLegacyBar() { @trigger_error('silenced bar deprecation', E_USER_DEPRECATED); trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); } } $foo = new FooTestCase(); $foo->testLegacyFoo(); $foo->testNonLegacyBar(); ?> --EXPECTF-- Unsilenced deprecation notices (3) 2x: unsilenced foo deprecation 2x in FooTestCase::testLegacyFoo 1x: unsilenced bar deprecation 1x in FooTestCase::testNonLegacyBar Remaining deprecation notices (1) 1x: silenced bar deprecation 1x in FooTestCase::testNonLegacyBar Legacy deprecation notices (1) Other deprecation notices (1) 1x: root deprecation �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weak_vendors_on_phar_deprecation.phpt���������������������������������������������������������������0000664�0000000�0000000�00000001374�13247321071�0035512�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler�������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation The phar can be regenerated by running php src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; \Phar::loadPhar(__DIR__.'/deprecation.phar', 'deprecation.phar'); include 'phar://deprecation.phar/deprecation.php'; ?> --EXPECTF-- Other deprecation notices (1) 1x: I come from… afar! :D ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_vendor.phpt��0000664�0000000�0000000�00000001665�13247321071�0033562�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--TEST-- Test DeprecationErrorHandler in weak vendors mode on vendor file --FILE-- <?php putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); putenv('ANSICON'); putenv('ConEmuANSI'); putenv('TERM'); $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { $vendor = dirname($vendor); } define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; require_once __DIR__.'/../../bootstrap.php'; require __DIR__.'/fake_vendor/autoload.php'; require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php'; ?> --EXPECTF-- Unsilenced deprecation notices (3) 2x: unsilenced foo deprecation 2x in FooTestCase::testLegacyFoo 1x: unsilenced bar deprecation 1x in FooTestCase::testNonLegacyBar Remaining vendor deprecation notices (1) 1x: silenced bar deprecation 1x in FooTestCase::testNonLegacyBar Legacy deprecation notices (2) Other deprecation notices (1) 1x: root deprecation ���������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php��������������������������������������0000664�0000000�0000000�00000010662�13247321071�0024264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DnsMock; class DnsMockTest extends TestCase { protected function tearDown() { DnsMock::withMockedHosts(array()); } public function testCheckdnsrr() { DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'MX')))); $this->assertTrue(DnsMock::checkdnsrr('example.com')); DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A')))); $this->assertFalse(DnsMock::checkdnsrr('example.com')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'a')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'any')); $this->assertFalse(DnsMock::checkdnsrr('foobar.com', 'ANY')); } public function testGetmxrr() { DnsMock::withMockedHosts(array( 'example.com' => array(array( 'type' => 'MX', 'host' => 'mx.example.com', 'pri' => 10, )), )); $this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight)); $this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight)); $this->assertSame(array('mx.example.com'), $mxhosts); $this->assertSame(array(10), $weight); } public function testGethostbyaddr() { DnsMock::withMockedHosts(array( 'example.com' => array( array( 'type' => 'A', 'ip' => '1.2.3.4', ), array( 'type' => 'AAAA', 'ipv6' => '::12', ), ), )); $this->assertSame('::21', DnsMock::gethostbyaddr('::21')); $this->assertSame('example.com', DnsMock::gethostbyaddr('::12')); $this->assertSame('example.com', DnsMock::gethostbyaddr('1.2.3.4')); } public function testGethostbyname() { DnsMock::withMockedHosts(array( 'example.com' => array( array( 'type' => 'AAAA', 'ipv6' => '::12', ), array( 'type' => 'A', 'ip' => '1.2.3.4', ), ), )); $this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com')); $this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com')); } public function testGethostbynamel() { DnsMock::withMockedHosts(array( 'example.com' => array( array( 'type' => 'A', 'ip' => '1.2.3.4', ), array( 'type' => 'A', 'ip' => '2.3.4.5', ), ), )); $this->assertFalse(DnsMock::gethostbynamel('foobar.com')); $this->assertSame(array('1.2.3.4', '2.3.4.5'), DnsMock::gethostbynamel('example.com')); } public function testDnsGetRecord() { DnsMock::withMockedHosts(array( 'example.com' => array( array( 'type' => 'A', 'ip' => '1.2.3.4', ), array( 'type' => 'PTR', 'ip' => '2.3.4.5', ), ), )); $records = array( array( 'host' => 'example.com', 'class' => 'IN', 'ttl' => 1, 'type' => 'A', 'ip' => '1.2.3.4', ), $ptr = array( 'host' => 'example.com', 'class' => 'IN', 'ttl' => 1, 'type' => 'PTR', 'ip' => '2.3.4.5', ), ); $this->assertFalse(DnsMock::dns_get_record('foobar.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL)); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR)); $this->assertSame(array($ptr), DnsMock::dns_get_record('example.com', DNS_PTR)); } } ������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023161�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0024754�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/phpunit-with-listener.xml.dist�����0000664�0000000�0000000�00000001517�13247321071�0032727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php" failOnRisky="true" failOnWarning="true" > <testsuites> <testsuite name="Fixtures/coverage Test Suite"> <directory>tests</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>src</directory> </whitelist> </filter> <listeners> <listener class="Symfony\Bridge\PhpUnit\CoverageListener"> <arguments> <null/> <boolean>true</boolean> </arguments> </listener> </listeners> </phpunit> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/phpunit-without-listener.xml.dist��0000664�0000000�0000000�00000001145�13247321071�0033454�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php" failOnRisky="true" failOnWarning="true" > <testsuites> <testsuite name="Fixtures/coverage Test Suite"> <directory>tests</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>src</directory> </whitelist> </filter> </phpunit> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/src/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025543�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/src/BarCov.php���������������������0000664�0000000�0000000�00000000741�13247321071�0027432�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PhpUnitCoverageTest; class BarCov { private $foo; public function __construct(FooCov $foo) { $this->foo = $foo; } public function barZ() { $this->foo->fooZ(); return 'bar'; } } �������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/src/FooCov.php���������������������0000664�0000000�0000000�00000000534�13247321071�0027451�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PhpUnitCoverageTest; class FooCov { public function fooZ() { return 'foo'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/�����������������������������0000775�0000000�0000000�00000000000�13247321071�0026116�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/BarCovTest.php���������������0000664�0000000�0000000�00000001355�13247321071�0030647�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PhpUnitCoverageTest\Tests; use PHPUnit\Framework\TestCase; class BarCovTest extends TestCase { public function testBarCov() { if (!class_exists('PhpUnitCoverageTest\FooCov')) { $this->markTestSkipped('This test is not part of the main Symfony test suite. It\'s here to test the CoverageListener.'); } $foo = new \PhpUnitCoverageTest\FooCov(); $bar = new \PhpUnitCoverageTest\BarCov($foo); $this->assertSame('bar', $bar->barZ()); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php���0000664�0000000�0000000�00000000662�13247321071�0033227�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \DateTime */ class CoversDefaultClassTest extends TestCase { public function test() { $this->assertTrue(true); } } ������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversNothingTest.php��������0000664�0000000�0000000�00000000636�13247321071�0032264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use PHPUnit\Framework\TestCase; /** * @coversNothing */ class CoversNothingTest extends TestCase { public function test() { $this->assertTrue(true); } } ��������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversTest.php���������������0000664�0000000�0000000�00000000646�13247321071�0030736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use PHPUnit\Framework\TestCase; class CoversTest extends TestCase { /** * @covers \DateTime */ public function test() { $this->assertTrue(true); } } ������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/SutNotFindTest.php�����������0000664�0000000�0000000�00000000602�13247321071�0031522�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use PHPUnit\Framework\TestCase; class SutNotFoundTest extends TestCase { public function test() { $this->assertTrue(true); } } ������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/bootstrap.php����������������0000664�0000000�0000000�00000001524�13247321071�0030646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require __DIR__.'/../src/BarCov.php'; require __DIR__.'/../src/FooCov.php'; require __DIR__.'/../../../../Legacy/CoverageListenerTrait.php'; if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { require_once __DIR__.'/../../../../Legacy/CoverageListenerForV5.php'; } elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { require_once __DIR__.'/../../../../Legacy/CoverageListenerForV6.php'; } else { require_once __DIR__.'/../../../../Legacy/CoverageListenerForV7.php'; } require __DIR__.'/../../../../CoverageListener.php'; ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php�����������������������������0000664�0000000�0000000�00000002005�13247321071�0026216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bridge\PhpUnit\Tests; use PHPUnit\Framework\TestCase; /** * Don't remove this test case, it tests the legacy group. * * @group legacy * * @runTestsInSeparateProcesses */ class ProcessIsolationTest extends TestCase { /** * @expectedDeprecation Test abc */ public function testIsolation() { @trigger_error('Test abc', E_USER_DEPRECATED); $this->addToAssertionCount(1); } public function testCallingOtherErrorHandler() { $class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception'; if (method_exists($this, 'expectException')) { $this->expectException($class); $this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.'); } else { $this->setExpectedException($class, 'Test that PHPUnit\'s error handler fires.'); } trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/TextUI/����������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021430�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/TextUI/Command.php�����������������������������������������0000664�0000000�0000000�00000001475�13247321071�0023526�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\TextUI; use PHPUnit\TextUI\Command as BaseCommand; if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\Command', 'Symfony\Bridge\PhpUnit\TextUI\Command'); } else { /** * {@inheritdoc} * * @internal */ class Command extends BaseCommand { /** * {@inheritdoc} */ protected function createRunner() { return new TestRunner($this->arguments['loader']); } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php��������������������������������������0000664�0000000�0000000�00000003043�13247321071�0024252�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\PhpUnit\TextUI; use PHPUnit\TextUI\TestRunner as BaseRunner; use Symfony\Bridge\PhpUnit\SymfonyTestsListener; if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunner', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner'); } else { /** * {@inheritdoc} * * @internal */ class TestRunner extends BaseRunner { /** * {@inheritdoc} */ protected function handleConfiguration(array &$arguments) { $listener = new SymfonyTestsListener(); $result = parent::handleConfiguration($arguments); $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); $registeredLocally = false; foreach ($arguments['listeners'] as $registeredListener) { if ($registeredListener instanceof SymfonyTestsListener) { $registeredListener->globalListenerDisabled(); $registeredLocally = true; break; } } if (!$registeredLocally) { $arguments['listeners'][] = $listener; } return $result; } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/bin/�������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021016�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit�����������������������������������������0000775�0000000�0000000�00000023434�13247321071�0023730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env php <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Please update when phpunit needs to be reinstalled with fresh deps: // Cache-Id-Version: 2017-11-22 09:30 UTC error_reporting(-1); if (PHP_VERSION_ID >= 70200) { // PHPUnit 6 is required for PHP 7.2+ $PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '6.5'; } elseif (PHP_VERSION_ID >= 50600) { // PHPUnit 4 does not support PHP 7 $PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '5.7'; } else { // PHPUnit 5.1 requires PHP 5.6+ $PHPUNIT_VERSION = '4.8'; } $root = __DIR__; while (!file_exists($root.'/composer.json') || file_exists($root.'/DeprecationErrorHandler.php')) { if ($root === dirname($root)) { break; } $root = dirname($root); } $oldPwd = getcwd(); $PHPUNIT_DIR = getenv('SYMFONY_PHPUNIT_DIR') ?: ($root.'/vendor/bin/.phpunit'); $PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; $PHP = escapeshellarg($PHP); if ('phpdbg' === PHP_SAPI) { $PHP .= ' -qrr'; } $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar`)) ? $PHP.' '.escapeshellarg($COMPOSER) : 'composer'; if (false === $SYMFONY_PHPUNIT_REMOVE = getenv('SYMFONY_PHPUNIT_REMOVE')) { $SYMFONY_PHPUNIT_REMOVE = 'phpspec/prophecy symfony/yaml'; } if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__)."\n".$SYMFONY_PHPUNIT_REMOVE !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) { // Build a standalone phpunit without symfony/yaml nor prophecy by default @mkdir($PHPUNIT_DIR, 0777, true); chdir($PHPUNIT_DIR); if (file_exists("phpunit-$PHPUNIT_VERSION")) { passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION")); } if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) { $remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip"; $remoteZipStream = @fopen($remoteZip, 'rb'); if (!$remoteZipStream) { throw new \RuntimeException("Could not find $remoteZip"); } stream_copy_to_stream($remoteZipStream, fopen("$PHPUNIT_VERSION.zip", 'wb')); } else { @unlink("$PHPUNIT_VERSION.zip"); passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip"); } if (!class_exists('ZipArchive')) { throw new \Exception('simple-phpunit requires the "zip" PHP extension to be installed and enabled in order to uncompress the downloaded PHPUnit packages.'); } $zip = new ZipArchive(); $zip->open("$PHPUNIT_VERSION.zip"); $zip->extractTo(getcwd()); $zip->close(); chdir("phpunit-$PHPUNIT_VERSION"); if ($SYMFONY_PHPUNIT_REMOVE) { passthru("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); } if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); if ('\\' === DIRECTORY_SEPARATOR) { file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json'))); } } else { passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); } $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-suggest --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true))); putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); if ($exit) { exit($exit); } file_put_contents('phpunit', <<<'EOPHP' <?php define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; if (!class_exists('SymfonyBlacklistPhpunit', false)) { class SymfonyBlacklistPhpunit {} } if (class_exists('PHPUnit_Util_Blacklist')) { PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; } else { PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; } Symfony\Bridge\PhpUnit\TextUI\Command::main(); EOPHP ); chdir('..'); file_put_contents(".$PHPUNIT_VERSION.md5", md5_file(__FILE__)."\n".$SYMFONY_PHPUNIT_REMOVE); chdir($oldPwd); } global $argv, $argc; $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); $argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0; $components = array(); $cmd = array_map('escapeshellarg', $argv); $exit = 0; if (isset($argv[1]) && 'symfony' === $argv[1] && !file_exists('symfony') && file_exists('src/Symfony')) { $argv[1] = 'src/Symfony'; } if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.dist')) { // Find Symfony components in plain php for Windows portability $finder = new RecursiveDirectoryIterator($argv[1], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS); $finder = new RecursiveIteratorIterator($finder); $finder->setMaxDepth(getenv('SYMFONY_PHPUNIT_MAX_DEPTH') ?: 3); foreach ($finder as $file => $fileInfo) { if ('phpunit.xml.dist' === $file) { $components[] = dirname($fileInfo->getPathname()); } } if ($components) { array_shift($cmd); } } $cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")); $cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s'; if ('\\' === DIRECTORY_SEPARATOR) { $cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"'; } else { $cmd .= '%2$s'; } if ($components) { $skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false; $runningProcs = array(); foreach ($components as $component) { // Run phpunit tests in parallel if ($skippedTests) { putenv("SYMFONY_PHPUNIT_SKIPPED_TESTS=$component/$skippedTests"); } $c = escapeshellarg($component); if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) { $runningProcs[$component] = $proc; } else { $exit = 1; echo "\033[41mKO\033[0m $component\n\n"; } } // Fixes for colors support on appveyor // See https://github.com/appveyor/ci/issues/373 $colorFixes = array( array("S\033[0m\033[0m\033[36m\033[1mS", "E\033[0m\033[0m\033[31m\033[1mE", "I\033[0m\033[0m\033[33m\033[1mI", "F\033[0m\033[0m\033[41m\033[37mF"), array("SS", "EE", "II", "FF"), ); $colorFixes[0] = array_merge($colorFixes[0], $colorFixes[0]); $colorFixes[1] = array_merge($colorFixes[1], $colorFixes[1]); while ($runningProcs) { usleep(300000); $terminatedProcs = array(); foreach ($runningProcs as $component => $proc) { $procStatus = proc_get_status($proc); if (!$procStatus['running']) { $terminatedProcs[$component] = $procStatus['exitcode']; unset($runningProcs[$component]); proc_close($proc); } } foreach ($terminatedProcs as $component => $procStatus) { foreach (array('out', 'err') as $file) { $file = "$component/phpunit.std$file"; if ('\\' === DIRECTORY_SEPARATOR) { $h = fopen($file, 'rb'); while (false !== $line = fgets($h)) { echo str_replace($colorFixes[0], $colorFixes[1], preg_replace( '/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/', "$1m\033[$2$3$4$4", $line )); } fclose($h); } else { readfile($file); } unlink($file); } // Fail on any individual component failures but ignore some error codes on Windows when APCu is enabled: // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) { $exit = $procStatus; echo "\033[41mKO\033[0m $component\n\n"; } else { echo "\033[32mOK\033[0m $component\n\n"; } } } } elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) { if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) { class SymfonyBlacklistSimplePhpunit {} } array_splice($argv, 1, 0, array('--colors=always')); $_SERVER['argv'] = $argv; $_SERVER['argc'] = ++$argc; include "$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit"; } exit($exit); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/bootstrap.php����������������������������������������������0000664�0000000�0000000�00000002462�13247321071�0023000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { DeprecationErrorHandler::collectDeprecations($file); return; } // Detect if we're loaded by an actual run of phpunit if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { return; } // Enforce a consistent locale setlocale(LC_ALL, 'C'); if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { AnnotationRegistry::registerUniqueLoader('class_exists'); } else { AnnotationRegistry::registerLoader('class_exists'); } } if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/composer.json����������������������������������������������0000664�0000000�0000000�00000002570�13247321071�0022774�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "symfony/phpunit-bridge", "type": "symfony-bridge", "description": "Symfony PHPUnit Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Nicolas Grekas", "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": ">=5.3.3 EVEN ON LATEST SYMFONY VERSIONS TO ALLOW USING", "php": "THIS BRIDGE WHEN TESTING LOWEST SYMFONY VERSIONS.", "php": ">=5.3.3" }, "suggest": { "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader", "ext-zip": "Zip support is required when using bin/simple-phpunit" }, "conflict": { "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" }, "autoload": { "files": [ "bootstrap.php" ], "psr-4": { "Symfony\\Bridge\\PhpUnit\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "bin": [ "bin/simple-phpunit" ], "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" }, "thanks": { "name": "phpunit/phpunit", "url": "https://github.com/sebastianbergmann/phpunit" } } } ����������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist�������������������������������������������0000664�0000000�0000000�00000001622�13247321071�0023422�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" > <php> <ini name="error_reporting" value="-1" /> </php> <testsuites> <testsuite name="Symfony PHPUnit Bridge Test Suite"> <directory>./Tests/</directory> <directory suffix=".phpt">./Tests/DeprecationErrorHandler/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./</directory> <exclude> <directory>./Tests</directory> <directory>./vendor</directory> </exclude> </whitelist> </filter> </phpunit> ��������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021273�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/.gitignore��������������������������������������������0000664�0000000�0000000�00000000042�13247321071�0023257�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������vendor/ composer.lock phpunit.xml ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/CHANGELOG.md������������������������������������������0000664�0000000�0000000�00000000232�13247321071�0023101�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CHANGELOG ========= 3.3.0 ----- * [BC BREAK] The `ProxyDumper` class is now final 2.3.0 ----- * First introduction of `Symfony\Bridge\ProxyManager` ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LICENSE�����������������������������������������������0000664�0000000�0000000�00000002051�13247321071�0022276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2004-2018 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023254�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025733�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������LazyLoadingValueHolderFactoryV1.php�����������������������������������������������������������������0000664�0000000�0000000�00000001360�13247321071�0034474�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator���������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\LazyProxy\Instantiator; use ProxyManager\Factory\LazyLoadingValueHolderFactory as BaseFactory; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator; /** * @internal */ class LazyLoadingValueHolderFactoryV1 extends BaseFactory { private $generatorV1; /** * {@inheritdoc} */ protected function getGenerator() { return $this->generatorV1 ?: $this->generatorV1 = new LazyLoadingValueHolderGenerator(); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������LazyLoadingValueHolderFactoryV2.php�����������������������������������������������������������������0000664�0000000�0000000�00000001474�13247321071�0034503�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator���������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\LazyProxy\Instantiator; use ProxyManager\ProxyGenerator\ProxyGeneratorInterface; use ProxyManager\Factory\LazyLoadingValueHolderFactory as BaseFactory; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator; /** * @internal */ class LazyLoadingValueHolderFactoryV2 extends BaseFactory { private $generator; /** * {@inheritdoc} */ protected function getGenerator(): ProxyGeneratorInterface { return $this->generator ?: $this->generator = new LazyLoadingValueHolderGenerator(); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php��������0000664�0000000�0000000�00000003515�13247321071�0032473�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\LazyProxy\Instantiator; use ProxyManager\Configuration; use ProxyManager\Factory\LazyLoadingValueHolderFactory; use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; use ProxyManager\Proxy\LazyLoadingInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface; /** * Runtime lazy loading proxy generator. * * @author Marco Pivetta <ocramius@gmail.com> */ class RuntimeInstantiator implements InstantiatorInterface { /** * @var LazyLoadingValueHolderFactory */ private $factory; public function __construct() { $config = new Configuration(); $config->setGeneratorStrategy(new EvaluatingGeneratorStrategy()); if (method_exists('ProxyManager\Version', 'getVersion')) { $this->factory = new LazyLoadingValueHolderFactoryV2($config); } else { $this->factory = new LazyLoadingValueHolderFactoryV1($config); } } /** * {@inheritdoc} */ public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator) { return $this->factory->createProxy( $definition->getClass(), function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) { $wrappedInstance = call_user_func($realInstantiator); $proxy->setProxyInitializer(null); return true; } ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025160�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������LazyLoadingValueHolderGenerator.php�����������������������������������������������������������������0000664�0000000�0000000�00000002373�13247321071�0034036�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper; use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator as BaseGenerator; use Zend\Code\Generator\ClassGenerator; /** * @internal */ class LazyLoadingValueHolderGenerator extends BaseGenerator { /** * {@inheritdoc} */ public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator) { parent::generate($originalClass, $classGenerator); if ($classGenerator->hasMethod('__destruct')) { $destructor = $classGenerator->getMethod('__destruct'); $body = $destructor->getBody(); $newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body); if ($body === $newBody) { throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method %s::__destruct()', $originalClass->name)); } $destructor->setBody($newBody); } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php�������������������0000664�0000000�0000000�00000011616�13247321071�0030174�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper; use ProxyManager\Generator\ClassGenerator; use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy; use ProxyManager\Version; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface; /** * Generates dumped PHP code of proxies via reflection. * * @author Marco Pivetta <ocramius@gmail.com> * * @final since version 3.3 */ class ProxyDumper implements DumperInterface { private $salt; private $proxyGenerator; private $classGenerator; /** * @param string $salt */ public function __construct($salt = '') { $this->salt = $salt; $this->proxyGenerator = new LazyLoadingValueHolderGenerator(); $this->classGenerator = new BaseGeneratorStrategy(); } /** * {@inheritdoc} */ public function isProxyCandidate(Definition $definition) { return $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class); } /** * {@inheritdoc} */ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null) { $instantiation = 'return'; if ($definition->isShared()) { $instantiation .= " \$this->services['$id'] ="; } if (null === $factoryCode) { @trigger_error(sprintf('The "%s()" method expects a third argument defining the code to execute to construct your service since Symfony 3.4, providing it will be required in 4.0.', __METHOD__), E_USER_DEPRECATED); $factoryCode = '$this->get'.Container::camelize($id).'Service(false)'; } elseif (false === strpos($factoryCode, '(')) { @trigger_error(sprintf('The "%s()" method expects its third argument to define the code to execute to construct your service since Symfony 3.4, providing it will be required in 4.0.', __METHOD__), E_USER_DEPRECATED); $factoryCode = "\$this->$factoryCode(false)"; } $proxyClass = $this->getProxyClassName($definition); $hasStaticConstructor = $this->generateProxyClass($definition)->hasMethod('staticProxyConstructor'); $constructorCall = sprintf($hasStaticConstructor ? '%s::staticProxyConstructor' : 'new %s', '\\'.$proxyClass); return <<<EOF if (\$lazyLoad) { $instantiation \$this->createProxy('$proxyClass', function () { return $constructorCall(function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) { \$wrappedInstance = $factoryCode; \$proxy->setProxyInitializer(null); return true; }); }); } EOF; } /** * {@inheritdoc} */ public function getProxyCode(Definition $definition) { $code = $this->classGenerator->generate($this->generateProxyClass($definition)); $code = preg_replace( '/(\$this->initializer[0-9a-f]++) && \1->__invoke\(\$this->(valueHolder[0-9a-f]++), (.*?), \1\);/', '$1 && ($1->__invoke(\$$2, $3, $1) || 1) && $this->$2 = \$$2;', $code ); if (version_compare(self::getProxyManagerVersion(), '2.2', '<')) { $code = preg_replace( '/((?:\$(?:this|initializer|instance)->)?(?:publicProperties|initializer|valueHolder))[0-9a-f]++/', '${1}'.$this->getIdentifierSuffix($definition), $code ); } return $code; } /** * @return string */ private static function getProxyManagerVersion() { if (!\class_exists(Version::class)) { return '0.0.1'; } return defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(); } /** * Produces the proxy class name for the given definition. * * @return string */ private function getProxyClassName(Definition $definition) { return preg_replace('/^.*\\\\/', '', $definition->getClass()).'_'.$this->getIdentifierSuffix($definition); } /** * @return ClassGenerator */ private function generateProxyClass(Definition $definition) { $generatedClass = new ClassGenerator($this->getProxyClassName($definition)); $this->proxyGenerator->generate(new \ReflectionClass($definition->getClass()), $generatedClass); return $generatedClass; } /** * @return string */ private function getIdentifierSuffix(Definition $definition) { return substr(hash('sha256', $definition->getClass().$this->salt), -7); } } ������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/README.md���������������������������������������������0000664�0000000�0000000�00000000725�13247321071�0022556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ProxyManager Bridge =================== Provides integration for [ProxyManager][1] with various Symfony components. Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) [1]: https://github.com/Ocramius/ProxyManager �������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022375�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/��������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024356�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php��������������0000664�0000000�0000000�00000004260�13247321071�0031162�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy; require_once __DIR__.'/Fixtures/includes/foo.php'; use PHPUnit\Framework\TestCase; use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Integration tests for {@see \Symfony\Component\DependencyInjection\ContainerBuilder} combined * with the ProxyManager bridge. * * @author Marco Pivetta <ocramius@gmail.com> */ class ContainerBuilderTest extends TestCase { public function testCreateProxyServiceWithRuntimeInstantiator() { $builder = new ContainerBuilder(); $builder->setProxyInstantiator(new RuntimeInstantiator()); $builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true); $builder->getDefinition('foo1')->setLazy(true); $builder->compile(); /* @var $foo1 \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */ $foo1 = $builder->get('foo1'); $foo1->__destruct(); $this->assertSame(0, $foo1::$destructorCount); $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls'); $this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1); $this->assertInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1); $this->assertFalse($foo1->isProxyInitialized()); $foo1->initializeProxy(); $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved after initialization'); $this->assertTrue($foo1->isProxyInitialized()); $this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1->getWrappedValueHolderValue()); $this->assertNotInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1->getWrappedValueHolderValue()); $foo1->__destruct(); $this->assertSame(1, $foo1::$destructorCount); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025612�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php��������������0000664�0000000�0000000�00000004550�13247321071�0031073�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper; use PHPUnit\Framework\TestCase; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; /** * Integration tests for {@see \Symfony\Component\DependencyInjection\Dumper\PhpDumper} combined * with the ProxyManager bridge. * * @author Marco Pivetta <ocramius@gmail.com> */ class PhpDumperTest extends TestCase { public function testDumpContainerWithProxyService() { $this->assertStringMatchesFormatFile( __DIR__.'/../Fixtures/php/lazy_service_structure.txt', $this->dumpLazyServiceProjectServiceContainer(), '->dump() does generate proxy lazy loading logic.' ); } /** * Verifies that the generated container retrieves the same proxy instance on multiple subsequent requests. */ public function testDumpContainerWithProxyServiceWillShareProxies() { if (!class_exists('LazyServiceProjectServiceContainer', false)) { eval('?>'.$this->dumpLazyServiceProjectServiceContainer()); } $container = new \LazyServiceProjectServiceContainer(); $proxy = $container->get('foo'); $this->assertInstanceOf('stdClass', $proxy); $this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); $this->assertSame($proxy, $container->get('foo')); $this->assertFalse($proxy->isProxyInitialized()); $proxy->initializeProxy(); $this->assertTrue($proxy->isProxyInitialized()); $this->assertSame($proxy, $container->get('foo')); } private function dumpLazyServiceProjectServiceContainer() { $container = new ContainerBuilder(); $container->register('foo', 'stdClass')->setPublic(true); $container->getDefinition('foo')->setLazy(true); $container->compile(); $dumper = new PhpDumper($container); $dumper->setProxyDumper(new ProxyDumper()); return $dumper->dump(array('class' => 'LazyServiceProjectServiceContainer')); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/�����������������������������0000775�0000000�0000000�00000000000�13247321071�0026167�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/��������������������0000775�0000000�0000000�00000000000�13247321071�0027775�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/foo.php�������������0000664�0000000�0000000�00000001536�13247321071�0031276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php class ProxyManagerBridgeFooClass { public static $destructorCount = 0; public $foo; public $moo; public $bar = null; public $initialized = false; public $configured = false; public $called = false; public $arguments = array(); public function __construct($arguments = array()) { $this->arguments = $arguments; } public static function getInstance($arguments = array()) { $obj = new self($arguments); $obj->called = true; return $obj; } public function initialize() { $this->initialized = true; } public function configure() { $this->configured = true; } public function setBar($value = null) { $this->bar = $value; } public function __destruct() { ++self::$destructorCount; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/�������������������������0000775�0000000�0000000�00000000000�13247321071�0026756�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������lazy_service_structure.txt��������������������������������������������������������������������������0000664�0000000�0000000�00000001263�13247321071�0034261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php���������������������������������������������������������������������������������������������<?php use %a class LazyServiceProjectServiceContainer extends Container {%a protected function getFooService($lazyLoad = true) { if ($lazyLoad) { return $this->services['foo'] = $this->createProxy('stdClass_%s', function () { return %S\stdClass_%s(function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { $wrappedInstance = $this->getFooService(false); $proxy->setProxyInitializer(null); return true; }); }); } return new \stdClass(); } } class stdClass_%s extends %SstdClass implements \ProxyManager\%s {%a}%A ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/�������������������������0000775�0000000�0000000�00000000000�13247321071�0027035�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������RuntimeInstantiatorTest.php�������������������������������������������������������������������������0000664�0000000�0000000�00000003377�13247321071�0034364�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator���������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Instantiator; use PHPUnit\Framework\TestCase; use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Component\DependencyInjection\Definition; /** * Tests for {@see \Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator}. * * @author Marco Pivetta <ocramius@gmail.com> */ class RuntimeInstantiatorTest extends TestCase { /** * @var RuntimeInstantiator */ protected $instantiator; /** * {@inheritdoc} */ protected function setUp() { $this->instantiator = new RuntimeInstantiator(); } public function testInstantiateProxy() { $instance = new \stdClass(); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $definition = new Definition('stdClass'); $instantiator = function () use ($instance) { return $instance; }; /* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */ $proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator); $this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); $this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $proxy); $this->assertFalse($proxy->isProxyInitialized()); $proxy->initializeProxy(); $this->assertSame($instance, $proxy->getWrappedValueHolderValue()); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/����������������������������0000775�0000000�0000000�00000000000�13247321071�0026262�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php���������0000664�0000000�0000000�00000006172�13247321071�0032137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper; use PHPUnit\Framework\TestCase; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; use Symfony\Component\DependencyInjection\Definition; /** * Tests for {@see \Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper}. * * @author Marco Pivetta <ocramius@gmail.com> */ class ProxyDumperTest extends TestCase { /** * @var ProxyDumper */ protected $dumper; /** * {@inheritdoc} */ protected function setUp() { $this->dumper = new ProxyDumper(); } /** * @dataProvider getProxyCandidates * * @param Definition $definition * @param bool $expected */ public function testIsProxyCandidate(Definition $definition, $expected) { $this->assertSame($expected, $this->dumper->isProxyCandidate($definition)); } public function testGetProxyCode() { $definition = new Definition(__CLASS__); $definition->setLazy(true); $code = $this->dumper->getProxyCode($definition); $this->assertStringMatchesFormat( '%Aclass ProxyDumperTest%aextends%w' .'\Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\ProxyDumperTest%a', $code ); } public function testDeterministicProxyCode() { $definition = new Definition(__CLASS__); $definition->setLazy(true); $this->assertSame($this->dumper->getProxyCode($definition), $this->dumper->getProxyCode($definition)); } public function testGetProxyFactoryCode() { $definition = new Definition(__CLASS__); $definition->setLazy(true); $code = $this->dumper->getProxyFactoryCode($definition, 'foo', '$this->getFoo2Service(false)'); $this->assertStringMatchesFormat( '%A$wrappedInstance = $this->getFoo2Service(false);%w$proxy->setProxyInitializer(null);%A', $code ); } /** * @group legacy */ public function testLegacyGetProxyFactoryCode() { $definition = new Definition(__CLASS__); $definition->setLazy(true); $code = $this->dumper->getProxyFactoryCode($definition, 'foo'); $this->assertStringMatchesFormat( '%A$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);%A', $code ); } /** * @return array */ public function getProxyCandidates() { $definitions = array( array(new Definition(__CLASS__), true), array(new Definition('stdClass'), true), array(new Definition(uniqid('foo', true)), false), array(new Definition(), false), ); array_map( function ($definition) { $definition[0]->setLazy(true); }, $definitions ); return $definitions; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/composer.json�����������������������������������������0000664�0000000�0000000�00000001705�13247321071�0024020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "symfony/proxy-manager-bridge", "type": "symfony-bridge", "description": "Symfony ProxyManager Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/dependency-injection": "~3.4|~4.0", "ocramius/proxy-manager": "~0.4|~1.0|~2.0" }, "require-dev": { "symfony/config": "~2.8|~3.0|~4.0" }, "autoload": { "psr-4": { "Symfony\\Bridge\\ProxyManager\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } �����������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist��������������������������������������0000664�0000000�0000000�00000001567�13247321071�0024457�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" > <php> <ini name="error_reporting" value="-1" /> </php> <testsuites> <testsuite name="Symfony ProxyManager Bridge Test Suite"> <directory>./Tests/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./</directory> <exclude> <directory>./Resources</directory> <directory>./Tests</directory> <directory>./vendor</directory> </exclude> </whitelist> </filter> </phpunit> �����������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/��������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0017571�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/.gitignore����������������������������������������������������0000664�0000000�0000000�00000000042�13247321071�0021555�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������vendor/ composer.lock phpunit.xml ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/AppVariable.php�����������������������������������������������0000664�0000000�0000000�00000011046�13247321071�0022472�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** * Exposes some Symfony parameters and services as an "app" global variable. * * @author Fabien Potencier <fabien@symfony.com> */ class AppVariable { private $tokenStorage; private $requestStack; private $environment; private $debug; public function setTokenStorage(TokenStorageInterface $tokenStorage) { $this->tokenStorage = $tokenStorage; } public function setRequestStack(RequestStack $requestStack) { $this->requestStack = $requestStack; } public function setEnvironment($environment) { $this->environment = $environment; } public function setDebug($debug) { $this->debug = (bool) $debug; } /** * Returns the current token. * * @return TokenInterface|null * * @throws \RuntimeException When the TokenStorage is not available */ public function getToken() { if (null === $tokenStorage = $this->tokenStorage) { throw new \RuntimeException('The "app.token" variable is not available.'); } return $tokenStorage->getToken(); } /** * Returns the current user. * * @return mixed * * @see TokenInterface::getUser() */ public function getUser() { if (null === $tokenStorage = $this->tokenStorage) { throw new \RuntimeException('The "app.user" variable is not available.'); } if (!$token = $tokenStorage->getToken()) { return; } $user = $token->getUser(); if (is_object($user)) { return $user; } } /** * Returns the current request. * * @return Request|null The HTTP request object */ public function getRequest() { if (null === $this->requestStack) { throw new \RuntimeException('The "app.request" variable is not available.'); } return $this->requestStack->getCurrentRequest(); } /** * Returns the current session. * * @return Session|null The session */ public function getSession() { if (null === $this->requestStack) { throw new \RuntimeException('The "app.session" variable is not available.'); } if ($request = $this->getRequest()) { return $request->getSession(); } } /** * Returns the current app environment. * * @return string The current environment string (e.g 'dev') */ public function getEnvironment() { if (null === $this->environment) { throw new \RuntimeException('The "app.environment" variable is not available.'); } return $this->environment; } /** * Returns the current app debug mode. * * @return bool The current debug mode */ public function getDebug() { if (null === $this->debug) { throw new \RuntimeException('The "app.debug" variable is not available.'); } return $this->debug; } /** * Returns some or all the existing flash messages: * * getFlashes() returns all the flash messages * * getFlashes('notice') returns a simple array with flash messages of that type * * getFlashes(array('notice', 'error')) returns a nested array of type => messages. * * @return array */ public function getFlashes($types = null) { try { $session = $this->getSession(); if (null === $session) { return array(); } } catch (\RuntimeException $e) { return array(); } if (null === $types || '' === $types || array() === $types) { return $session->getFlashBag()->all(); } if (is_string($types)) { return $session->getFlashBag()->get($types); } $result = array(); foreach ($types as $type) { $result[$type] = $session->getFlashBag()->get($type); } return $result; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/CHANGELOG.md��������������������������������������������������0000664�0000000�0000000�00000006367�13247321071�0021416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CHANGELOG ========= 3.4.0 ----- * added an `only` keyword to `form_theme` tag to disable usage of default themes when rendering a form * deprecated `Symfony\Bridge\Twig\Form\TwigRenderer` * deprecated `DebugCommand::set/getTwigEnvironment`. Pass an instance of `Twig\Environment` as first argument of the constructor instead * deprecated `LintCommand::set/getTwigEnvironment`. Pass an instance of `Twig\Environment` as first argument of the constructor instead 3.3.0 ----- * added a `workflow_has_marked_place` function * added a `workflow_marked_places` function 3.2.0 ----- * added `AppVariable::getToken()` * Deprecated the possibility to inject the Form `TwigRenderer` into the `FormExtension`. * [BC BREAK] Registering the `FormExtension` without configuring a runtime loader for the `TwigRenderer` doesn't work anymore. Before: ```php use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRenderer; use Symfony\Bridge\Twig\Form\TwigRendererEngine; // ... $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig')); $rendererEngine->setEnvironment($twig); $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager))); ``` After: ```php // ... $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig); // require Twig 1.30+ $twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array( TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) { return new TwigRenderer($rendererEngine, $csrfTokenManager); }, ))); $twig->addExtension(new FormExtension()); ``` * Deprecated the `TwigRendererEngineInterface` interface. * added WorkflowExtension (provides `workflow_can` and `workflow_transitions`) 2.7.0 ----- * added LogoutUrlExtension (provides `logout_url` and `logout_path`) * added an HttpFoundation extension (provides the `absolute_url` and the `relative_path` functions) * added AssetExtension (provides the `asset` and `asset_version` functions) * Added possibility to extract translation messages from a file or files besides extracting from a directory 2.5.0 ----- * moved command `twig:lint` from `TwigBundle` 2.4.0 ----- * added stopwatch tag to time templates with the WebProfilerBundle 2.3.0 ----- * added helpers form(), form_start() and form_end() * deprecated form_enctype() in favor of form_start() 2.2.0 ----- * added a `controller` function to help generating controller references * added a `render_esi` and a `render_hinclude` function * [BC BREAK] restricted the `render` tag to only accept URIs or ControllerReference instances (the signature changed) * added a `render` function to render a request * The `app` global variable is now injected even when using the twig service directly. * Added an optional parameter to the `path` and `url` function which allows to generate relative paths (e.g. "../parent-file") and scheme-relative URLs (e.g. "//example.com/dir/file"). 2.1.0 ----- * added global variables access in a form theme * added TwigEngine * added TwigExtractor * added a csrf_token function * added a way to specify a default domain for a Twig template (via the 'trans_default_domain' tag) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Command/������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021147�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Command/DebugCommand.php��������������������������������������0000664�0000000�0000000�00000021735�13247321071�0024215�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Twig\Environment; use Twig\Loader\FilesystemLoader; /** * Lists twig functions, filters, globals and tests present in the current project. * * @author Jordi Boggiano <j.boggiano@seld.be> */ class DebugCommand extends Command { protected static $defaultName = 'debug:twig'; private $twig; private $projectDir; /** * @param Environment $twig * @param string|null $projectDir */ public function __construct($twig = null, $projectDir = null) { if (!$twig instanceof Environment) { @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); parent::__construct($twig); return; } parent::__construct(); $this->twig = $twig; $this->projectDir = $projectDir; } public function setTwigEnvironment(Environment $twig) { @trigger_error(sprintf('Method "%s" is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); $this->twig = $twig; } /** * @return Environment $twig */ protected function getTwigEnvironment() { @trigger_error(sprintf('Method "%s" is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); return $this->twig; } protected function configure() { $this ->setDefinition(array( new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'), )) ->setDescription('Shows a list of twig functions, filters, globals and tests') ->setHelp(<<<'EOF' The <info>%command.name%</info> command outputs a list of twig functions, filters, globals and tests. Output can be filtered with an optional argument. <info>php %command.full_name%</info> The command lists all functions, filters, etc. <info>php %command.full_name% date</info> The command lists everything that contains the word date. <info>php %command.full_name% --format=json</info> The command lists everything in a machine readable json format. EOF ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); // BC to be removed in 4.0 if (__CLASS__ !== get_class($this)) { $r = new \ReflectionMethod($this, 'getTwigEnvironment'); if (__CLASS__ !== $r->getDeclaringClass()->getName()) { @trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED); $this->twig = $this->getTwigEnvironment(); } } if (null === $this->twig) { throw new \RuntimeException('The Twig environment needs to be set.'); } $types = array('functions', 'filters', 'tests', 'globals'); if ('json' === $input->getOption('format')) { $data = array(); foreach ($types as $type) { foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) { $data[$type][$name] = $this->getMetadata($type, $entity); } } $data['tests'] = array_keys($data['tests']); $data['loader_paths'] = $this->getLoaderPaths(); $io->writeln(json_encode($data)); return 0; } $filter = $input->getArgument('filter'); foreach ($types as $index => $type) { $items = array(); foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) { if (!$filter || false !== strpos($name, $filter)) { $items[$name] = $name.$this->getPrettyMetadata($type, $entity); } } if (!$items) { continue; } $io->section(ucfirst($type)); ksort($items); $io->listing($items); } $rows = array(); foreach ($this->getLoaderPaths() as $namespace => $paths) { if (count($paths) > 1) { $rows[] = array('', ''); } foreach ($paths as $path) { $rows[] = array($namespace, '- '.$path); $namespace = ''; } if (count($paths) > 1) { $rows[] = array('', ''); } } array_pop($rows); $io->section('Loader Paths'); $io->table(array('Namespace', 'Paths'), $rows); return 0; } private function getLoaderPaths() { if (!($loader = $this->twig->getLoader()) instanceof FilesystemLoader) { return array(); } $loaderPaths = array(); foreach ($loader->getNamespaces() as $namespace) { $paths = array_map(function ($path) { if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) { $path = ltrim(substr($path, strlen($this->projectDir)), DIRECTORY_SEPARATOR); } return $path; }, $loader->getPaths($namespace)); if (FilesystemLoader::MAIN_NAMESPACE === $namespace) { $namespace = '(None)'; } else { $namespace = '@'.$namespace; } $loaderPaths[$namespace] = $paths; } return $loaderPaths; } private function getMetadata($type, $entity) { if ('globals' === $type) { return $entity; } if ('tests' === $type) { return; } if ('functions' === $type || 'filters' === $type) { $cb = $entity->getCallable(); if (null === $cb) { return; } if (is_array($cb)) { if (!method_exists($cb[0], $cb[1])) { return; } $refl = new \ReflectionMethod($cb[0], $cb[1]); } elseif (is_object($cb) && method_exists($cb, '__invoke')) { $refl = new \ReflectionMethod($cb, '__invoke'); } elseif (function_exists($cb)) { $refl = new \ReflectionFunction($cb); } elseif (is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) { $refl = new \ReflectionMethod($m[1], $m[2]); } else { throw new \UnexpectedValueException('Unsupported callback type'); } $args = $refl->getParameters(); // filter out context/environment args if ($entity->needsEnvironment()) { array_shift($args); } if ($entity->needsContext()) { array_shift($args); } if ('filters' === $type) { // remove the value the filter is applied on array_shift($args); } // format args $args = array_map(function ($param) { if ($param->isDefaultValueAvailable()) { return $param->getName().' = '.json_encode($param->getDefaultValue()); } return $param->getName(); }, $args); return $args; } } private function getPrettyMetadata($type, $entity) { if ('tests' === $type) { return ''; } try { $meta = $this->getMetadata($type, $entity); if (null === $meta) { return '(unknown?)'; } } catch (\UnexpectedValueException $e) { return ' <error>'.$e->getMessage().'</error>'; } if ('globals' === $type) { if (is_object($meta)) { return ' = object('.get_class($meta).')'; } return ' = '.substr(@json_encode($meta), 0, 50); } if ('functions' === $type) { return '('.implode(', ', $meta).')'; } if ('filters' === $type) { return $meta ? '('.implode(', ', $meta).')' : ''; } } } �����������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Command/LintCommand.php���������������������������������������0000664�0000000�0000000�00000021327�13247321071�0024072�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Finder\Finder; use Twig\Environment; use Twig\Error\Error; use Twig\Loader\ArrayLoader; use Twig\Source; /** * Command that will validate your template syntax and output encountered errors. * * @author Marc Weistroff <marc.weistroff@sensiolabs.com> * @author Jérôme Tamarelle <jerome@tamarelle.net> */ class LintCommand extends Command { protected static $defaultName = 'lint:twig'; private $twig; /** * @param Environment $twig */ public function __construct($twig = null) { if (!$twig instanceof Environment) { @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); parent::__construct($twig); return; } parent::__construct(); $this->twig = $twig; } public function setTwigEnvironment(Environment $twig) { @trigger_error(sprintf('Method "%s" is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); $this->twig = $twig; } /** * @return Environment $twig */ protected function getTwigEnvironment() { @trigger_error(sprintf('Method "%s" is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); return $this->twig; } protected function configure() { $this ->setDescription('Lints a template and outputs encountered errors') ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt') ->addArgument('filename', InputArgument::IS_ARRAY) ->setHelp(<<<'EOF' The <info>%command.name%</info> command lints a template and outputs to STDOUT the first encountered syntax error. You can validate the syntax of contents passed from STDIN: <info>cat filename | php %command.full_name%</info> Or the syntax of a file: <info>php %command.full_name% filename</info> Or of a whole directory: <info>php %command.full_name% dirname</info> <info>php %command.full_name% dirname --format=json</info> EOF ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); // BC to be removed in 4.0 if (__CLASS__ !== get_class($this)) { $r = new \ReflectionMethod($this, 'getTwigEnvironment'); if (__CLASS__ !== $r->getDeclaringClass()->getName()) { @trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED); $this->twig = $this->getTwigEnvironment(); } } if (null === $this->twig) { throw new \RuntimeException('The Twig environment needs to be set.'); } $filenames = $input->getArgument('filename'); if (0 === count($filenames)) { if (0 !== ftell(STDIN)) { throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.'); } $template = ''; while (!feof(STDIN)) { $template .= fread(STDIN, 1024); } return $this->display($input, $output, $io, array($this->validate($template, uniqid('sf_', true)))); } $filesInfo = $this->getFilesInfo($filenames); return $this->display($input, $output, $io, $filesInfo); } private function getFilesInfo(array $filenames) { $filesInfo = array(); foreach ($filenames as $filename) { foreach ($this->findFiles($filename) as $file) { $filesInfo[] = $this->validate(file_get_contents($file), $file); } } return $filesInfo; } protected function findFiles($filename) { if (is_file($filename)) { return array($filename); } elseif (is_dir($filename)) { return Finder::create()->files()->in($filename)->name('*.twig'); } throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename)); } private function validate($template, $file) { $realLoader = $this->twig->getLoader(); try { $temporaryLoader = new ArrayLoader(array((string) $file => $template)); $this->twig->setLoader($temporaryLoader); $nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file))); $this->twig->compile($nodeTree); $this->twig->setLoader($realLoader); } catch (Error $e) { $this->twig->setLoader($realLoader); return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e); } return array('template' => $template, 'file' => $file, 'valid' => true); } private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files) { switch ($input->getOption('format')) { case 'txt': return $this->displayTxt($output, $io, $files); case 'json': return $this->displayJson($output, $files); default: throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format'))); } } private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo) { $errors = 0; foreach ($filesInfo as $info) { if ($info['valid'] && $output->isVerbose()) { $io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : '')); } elseif (!$info['valid']) { ++$errors; $this->renderException($io, $info['template'], $info['exception'], $info['file']); } } if (0 === $errors) { $io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo))); } else { $io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors)); } return min($errors, 1); } private function displayJson(OutputInterface $output, $filesInfo) { $errors = 0; array_walk($filesInfo, function (&$v) use (&$errors) { $v['file'] = (string) $v['file']; unset($v['template']); if (!$v['valid']) { $v['message'] = $v['exception']->getMessage(); unset($v['exception']); ++$errors; } }); $output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); return min($errors, 1); } private function renderException(OutputInterface $output, $template, Error $exception, $file = null) { $line = $exception->getTemplateLine(); if ($file) { $output->text(sprintf('<error> ERROR </error> in %s (line %s)', $file, $line)); } else { $output->text(sprintf('<error> ERROR </error> (line %s)', $line)); } foreach ($this->getContext($template, $line) as $lineNumber => $code) { $output->text(sprintf( '%s %-6s %s', $lineNumber === $line ? '<error> >> </error>' : ' ', $lineNumber, $code )); if ($lineNumber === $line) { $output->text(sprintf('<error> >> %s</error> ', $exception->getRawMessage())); } } } private function getContext($template, $line, $context = 3) { $lines = explode("\n", $template); $position = max(0, $line - $context); $max = min(count($lines), $line - 1 + $context); $result = array(); while ($position < $max) { $result[$position + 1] = $lines[$position]; ++$position; } return $result; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/DataCollector/������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022311�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php���������������������������0000664�0000000�0000000�00000012416�13247321071�0026401�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\DataCollector; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; use Twig\Markup; use Twig\Profiler\Dumper\HtmlDumper; use Twig\Profiler\Profile; /** * TwigDataCollector. * * @author Fabien Potencier <fabien@symfony.com> */ class TwigDataCollector extends DataCollector implements LateDataCollectorInterface { private $profile; private $twig; private $computed; public function __construct(Profile $profile, Environment $twig = null) { $this->profile = $profile; $this->twig = $twig; } /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { } /** * {@inheritdoc} */ public function reset() { $this->profile->reset(); $this->computed = null; $this->data = array(); } /** * {@inheritdoc} */ public function lateCollect() { $this->data['profile'] = serialize($this->profile); $this->data['template_paths'] = array(); if (null === $this->twig) { return; } $templateFinder = function (Profile $profile) use (&$templateFinder) { if ($profile->isTemplate()) { try { $template = $this->twig->load($name = $profile->getName()); } catch (\Twig_Error_Loader $e) { $template = null; } if (null !== $template && '' !== $path = $template->getSourceContext()->getPath()) { $this->data['template_paths'][$name] = $path; } } foreach ($profile as $p) { $templateFinder($p); } }; $templateFinder($this->profile); } public function getTime() { return $this->getProfile()->getDuration() * 1000; } public function getTemplateCount() { return $this->getComputedData('template_count'); } public function getTemplatePaths() { return $this->data['template_paths']; } public function getTemplates() { return $this->getComputedData('templates'); } public function getBlockCount() { return $this->getComputedData('block_count'); } public function getMacroCount() { return $this->getComputedData('macro_count'); } public function getHtmlCallGraph() { $dumper = new HtmlDumper(); $dump = $dumper->dump($this->getProfile()); // needed to remove the hardcoded CSS styles $dump = str_replace(array( '<span style="background-color: #ffd">', '<span style="color: #d44">', '<span style="background-color: #dfd">', ), array( '<span class="status-warning">', '<span class="status-error">', '<span class="status-success">', ), $dump); return new Markup($dump, 'UTF-8'); } public function getProfile() { if (null === $this->profile) { if (\PHP_VERSION_ID >= 70000) { $this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile', 'Twig\Profiler\Profile'))); } else { $this->profile = unserialize($this->data['profile']); } } return $this->profile; } private function getComputedData($index) { if (null === $this->computed) { $this->computed = $this->computeData($this->getProfile()); } return $this->computed[$index]; } private function computeData(Profile $profile) { $data = array( 'template_count' => 0, 'block_count' => 0, 'macro_count' => 0, ); $templates = array(); foreach ($profile as $p) { $d = $this->computeData($p); $data['template_count'] += ($p->isTemplate() ? 1 : 0) + $d['template_count']; $data['block_count'] += ($p->isBlock() ? 1 : 0) + $d['block_count']; $data['macro_count'] += ($p->isMacro() ? 1 : 0) + $d['macro_count']; if ($p->isTemplate()) { if (!isset($templates[$p->getTemplate()])) { $templates[$p->getTemplate()] = 1; } else { ++$templates[$p->getTemplate()]; } } foreach ($d['templates'] as $template => $count) { if (!isset($templates[$template])) { $templates[$template] = $count; } else { $templates[$template] += $count; } } } $data['templates'] = $templates; return $data; } /** * {@inheritdoc} */ public function getName() { return 'twig'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/����������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021545�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/AssetExtension.php����������������������������������0000664�0000000�0000000�00000003711�13247321071�0025234�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Asset\Packages; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * Twig extension for the Symfony Asset component. * * @author Fabien Potencier <fabien@symfony.com> */ class AssetExtension extends AbstractExtension { private $packages; public function __construct(Packages $packages) { $this->packages = $packages; } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('asset', array($this, 'getAssetUrl')), new TwigFunction('asset_version', array($this, 'getAssetVersion')), ); } /** * Returns the public url/path of an asset. * * If the package used to generate the path is an instance of * UrlPackage, you will always get a URL and not a path. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string The public path of the asset */ public function getAssetUrl($path, $packageName = null) { return $this->packages->getUrl($path, $packageName); } /** * Returns the version of an asset. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string The asset version */ public function getAssetVersion($path, $packageName = null) { return $this->packages->getVersion($path, $packageName); } /** * Returns the name of the extension. * * @return string The extension name */ public function getName() { return 'asset'; } } �������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/CodeExtension.php�����������������������������������0000664�0000000�0000000�00000022272�13247321071�0025032�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; /** * Twig extension relate to PHP code and used by the profiler and the default exception templates. * * @author Fabien Potencier <fabien@symfony.com> */ class CodeExtension extends AbstractExtension { private $fileLinkFormat; private $rootDir; private $charset; /** * @param string|FileLinkFormatter $fileLinkFormat The format for links to source files * @param string $rootDir The project root directory * @param string $charset The charset */ public function __construct($fileLinkFormat, $rootDir, $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR; $this->charset = $charset; } /** * {@inheritdoc} */ public function getFilters() { return array( new TwigFilter('abbr_class', array($this, 'abbrClass'), array('is_safe' => array('html'))), new TwigFilter('abbr_method', array($this, 'abbrMethod'), array('is_safe' => array('html'))), new TwigFilter('format_args', array($this, 'formatArgs'), array('is_safe' => array('html'))), new TwigFilter('format_args_as_text', array($this, 'formatArgsAsText')), new TwigFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))), new TwigFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))), new TwigFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))), new TwigFilter('format_log_message', array($this, 'formatLogMessage'), array('is_safe' => array('html'))), new TwigFilter('file_link', array($this, 'getFileLink')), ); } public function abbrClass($class) { $parts = explode('\\', $class); $short = array_pop($parts); return sprintf('<abbr title="%s">%s</abbr>', $class, $short); } public function abbrMethod($method) { if (false !== strpos($method, '::')) { list($class, $method) = explode('::', $method, 2); $result = sprintf('%s::%s()', $this->abbrClass($class), $method); } elseif ('Closure' === $method) { $result = sprintf('<abbr title="%s">%1$s</abbr>', $method); } else { $result = sprintf('<abbr title="%s">%1$s</abbr>()', $method); } return $result; } /** * Formats an array as a string. * * @param array $args The argument array * * @return string */ public function formatArgs($args) { $result = array(); foreach ($args as $key => $item) { if ('object' === $item[0]) { $parts = explode('\\', $item[1]); $short = array_pop($parts); $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short); } elseif ('array' === $item[0]) { $formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); } elseif ('null' === $item[0]) { $formattedValue = '<em>null</em>'; } elseif ('boolean' === $item[0]) { $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>'; } elseif ('resource' === $item[0]) { $formattedValue = '<em>resource</em>'; } else { $formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset)); } $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); } return implode(', ', $result); } /** * Formats an array as a string. * * @param array $args The argument array * * @return string */ public function formatArgsAsText($args) { return strip_tags($this->formatArgs($args)); } /** * Returns an excerpt of a code file around the given line number. * * @param string $file A file path * @param int $line The selected line number * @param int $srcContext The number of displayed lines around or -1 for the whole file * * @return string An HTML string */ public function fileExcerpt($file, $line, $srcContext = 3) { if (is_readable($file)) { // highlight_file could throw warnings // see https://bugs.php.net/bug.php?id=25725 $code = @highlight_file($file, true); // remove main code/span tags $code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code); // split multiline spans $code = preg_replace_callback('#<span ([^>]++)>((?:[^<]*+<br \/>)++[^<]*+)</span>#', function ($m) { return "<span $m[1]>".str_replace('<br />', "</span><br /><span $m[1]>", $m[2]).'</span>'; }, $code); $content = explode('<br />', $code); $lines = array(); if (0 > $srcContext) { $srcContext = count($content); } for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, count($content)); $i <= $max; ++$i) { $lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><a class="anchor" name="line'.$i.'"></a><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>'; } return '<ol start="'.max($line - $srcContext, 1).'">'.implode("\n", $lines).'</ol>'; } } /** * Formats a file path. * * @param string $file An absolute file path * @param int $line The line number * @param string $text Use this text for the link rather than the file path * * @return string */ public function formatFile($file, $line, $text = null) { $file = trim($file); if (null === $text) { $text = str_replace('/', DIRECTORY_SEPARATOR, $file); if (0 === strpos($text, $this->rootDir)) { $text = substr($text, strlen($this->rootDir)); $text = explode(DIRECTORY_SEPARATOR, $text, 2); $text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : ''); } } $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text); } return $text; } /** * Returns the link for a given file/line pair. * * @param string $file An absolute file path * @param int $line The line number * * @return string|false A link or false */ public function getFileLink($file, $line) { if ($fmt = $this->fileLinkFormat) { return is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); } return false; } public function formatFileFromText($text) { return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { return 'in '.$this->formatFile($match[2], $match[3]); }, $text); } /** * @internal */ public function formatLogMessage($message, array $context) { if ($context && false !== strpos($message, '{')) { $replacements = array(); foreach ($context as $key => $val) { if (is_scalar($val)) { $replacements['{'.$key.'}'] = $val; } } if ($replacements) { $message = strtr($message, $replacements); } } return htmlspecialchars($message, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset); } /** * {@inheritdoc} */ public function getName() { return 'code'; } protected static function fixCodeMarkup($line) { // </span> ending tag from previous line $opening = strpos($line, '<span'); $closing = strpos($line, '</span>'); if (false !== $closing && (false === $opening || $closing < $opening)) { $line = substr_replace($line, '', $closing, 7); } // missing </span> tag at the end of line $opening = strpos($line, '<span'); $closing = strpos($line, '</span>'); if (false !== $opening && (false === $closing || $closing > $opening)) { $line .= '</span>'; } return trim($line); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/DumpExtension.php�����������������������������������0000664�0000000�0000000�00000004136�13247321071�0025064�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Bridge\Twig\TokenParser\DumpTokenParser; use Symfony\Component\VarDumper\Cloner\ClonerInterface; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Template; use Twig\TwigFunction; /** * Provides integration of the dump() function with Twig. * * @author Nicolas Grekas <p@tchwork.com> */ class DumpExtension extends AbstractExtension { private $cloner; private $dumper; public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null) { $this->cloner = $cloner; $this->dumper = $dumper; } public function getFunctions() { return array( new TwigFunction('dump', array($this, 'dump'), array('is_safe' => array('html'), 'needs_context' => true, 'needs_environment' => true)), ); } public function getTokenParsers() { return array(new DumpTokenParser()); } public function getName() { return 'dump'; } public function dump(Environment $env, $context) { if (!$env->isDebug()) { return; } if (2 === func_num_args()) { $vars = array(); foreach ($context as $key => $value) { if (!$value instanceof Template) { $vars[$key] = $value; } } $vars = array($vars); } else { $vars = func_get_args(); unset($vars[0], $vars[1]); } $dump = fopen('php://memory', 'r+b'); $this->dumper = $this->dumper ?: new HtmlDumper(); $this->dumper->setCharset($env->getCharset()); foreach ($vars as $value) { $this->dumper->dump($this->cloner->cloneVar($value), $dump); } return stream_get_contents($dump, -1, 0); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php�����������������������������0000664�0000000�0000000�00000002051�13247321071�0026310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\ExpressionLanguage\Expression; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * ExpressionExtension gives a way to create Expressions from a template. * * @author Fabien Potencier <fabien@symfony.com> */ class ExpressionExtension extends AbstractExtension { /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('expression', array($this, 'createExpression')), ); } public function createExpression($expression) { return new Expression($expression); } /** * Returns the name of the extension. * * @return string The extension name */ public function getName() { return 'expression'; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/FormExtension.php�����������������������������������0000664�0000000�0000000�00000015146�13247321071�0025065�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; use Symfony\Bridge\Twig\Form\TwigRendererInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormView; use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Extension\InitRuntimeInterface; use Twig\TwigFilter; use Twig\TwigFunction; use Twig\TwigTest; /** * FormExtension extends Twig with form capabilities. * * @author Fabien Potencier <fabien@symfony.com> * @author Bernhard Schussek <bschussek@gmail.com> */ class FormExtension extends AbstractExtension implements InitRuntimeInterface { /** * @deprecated since version 3.2, to be removed in 4.0 alongside with magic methods below */ private $renderer; public function __construct($renderer = null) { if ($renderer instanceof TwigRendererInterface) { @trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since Symfony 3.2 and won\'t be possible in 4.0. Pass the Twig\Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED); } elseif (null !== $renderer && !(is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) { throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__)); } $this->renderer = $renderer; } /** * {@inheritdoc} * * To be removed in 4.0 */ public function initRuntime(Environment $environment) { if ($this->renderer instanceof TwigRendererInterface) { $this->renderer->setEnvironment($environment); } elseif (is_array($this->renderer)) { $this->renderer[2] = $environment; } } /** * {@inheritdoc} */ public function getTokenParsers() { return array( // {% form_theme form "SomeBundle::widgets.twig" %} new FormThemeTokenParser(), ); } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('form_widget', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_errors', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_label', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_row', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_rest', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_start', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('form_end', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))), new TwigFunction('csrf_token', array('Symfony\Component\Form\FormRenderer', 'renderCsrfToken')), ); } /** * {@inheritdoc} */ public function getFilters() { return array( new TwigFilter('humanize', array('Symfony\Component\Form\FormRenderer', 'humanize')), ); } /** * {@inheritdoc} */ public function getTests() { return array( new TwigTest('selectedchoice', 'Symfony\Bridge\Twig\Extension\twig_is_selected_choice'), new TwigTest('rootform', 'Symfony\Bridge\Twig\Extension\twig_is_root_form'), ); } /** * @internal */ public function __get($name) { if ('renderer' === $name) { @trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since Symfony 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); if (is_array($this->renderer)) { $renderer = $this->renderer[0]->get($this->renderer[1]); if (isset($this->renderer[2]) && $renderer instanceof TwigRendererInterface) { $renderer->setEnvironment($this->renderer[2]); } $this->renderer = $renderer; } } return $this->$name; } /** * @internal */ public function __set($name, $value) { if ('renderer' === $name) { @trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since Symfony 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); } $this->$name = $value; } /** * @internal */ public function __isset($name) { if ('renderer' === $name) { @trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since Symfony 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); } return isset($this->$name); } /** * @internal */ public function __unset($name) { if ('renderer' === $name) { @trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since Symfony 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); } unset($this->$name); } /** * {@inheritdoc} */ public function getName() { return 'form'; } } /** * Returns whether a choice is selected for a given form value. * * This is a function and not callable due to performance reasons. * * @param string|array $selectedValue The selected value to compare * * @return bool Whether the choice is selected * * @see ChoiceView::isSelected() */ function twig_is_selected_choice(ChoiceView $choice, $selectedValue) { if (is_array($selectedValue)) { return in_array($choice->value, $selectedValue, true); } return $choice->value === $selectedValue; } /** * @internal */ function twig_is_root_form(FormView $formView) { return null === $formView->parent; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php�������������������������0000664�0000000�0000000�00000010304�13247321071�0027117�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RequestContext; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * Twig extension for the Symfony HttpFoundation component. * * @author Fabien Potencier <fabien@symfony.com> */ class HttpFoundationExtension extends AbstractExtension { private $requestStack; private $requestContext; public function __construct(RequestStack $requestStack, RequestContext $requestContext = null) { $this->requestStack = $requestStack; $this->requestContext = $requestContext; } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('absolute_url', array($this, 'generateAbsoluteUrl')), new TwigFunction('relative_path', array($this, 'generateRelativePath')), ); } /** * Returns the absolute URL for the given absolute or relative path. * * This method returns the path unchanged if no request is available. * * @param string $path The path * * @return string The absolute URL * * @see Request::getUriForPath() */ public function generateAbsoluteUrl($path) { if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) { return $path; } if (!$request = $this->requestStack->getMasterRequest()) { if (null !== $this->requestContext && '' !== $host = $this->requestContext->getHost()) { $scheme = $this->requestContext->getScheme(); $port = ''; if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) { $port = ':'.$this->requestContext->getHttpPort(); } elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) { $port = ':'.$this->requestContext->getHttpsPort(); } if ('#' === $path[0]) { $queryString = $this->requestContext->getQueryString(); $path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path; } elseif ('?' === $path[0]) { $path = $this->requestContext->getPathInfo().$path; } if ('/' !== $path[0]) { $path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path; } return $scheme.'://'.$host.$port.$path; } return $path; } if ('#' === $path[0]) { $path = $request->getRequestUri().$path; } elseif ('?' === $path[0]) { $path = $request->getPathInfo().$path; } if (!$path || '/' !== $path[0]) { $prefix = $request->getPathInfo(); $last = strlen($prefix) - 1; if ($last !== $pos = strrpos($prefix, '/')) { $prefix = substr($prefix, 0, $pos).'/'; } return $request->getUriForPath($prefix.$path); } return $request->getSchemeAndHttpHost().$path; } /** * Returns a relative path based on the current Request. * * This method returns the path unchanged if no request is available. * * @param string $path The path * * @return string The relative path * * @see Request::getRelativeUriForPath() */ public function generateRelativePath($path) { if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) { return $path; } if (!$request = $this->requestStack->getMasterRequest()) { return $path; } return $request->getRelativeUriForPath($path); } /** * Returns the name of the extension. * * @return string The extension name */ public function getName() { return 'request'; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php�����������������������������0000664�0000000�0000000�00000002403�13247321071�0026232�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * Provides integration with the HttpKernel component. * * @author Fabien Potencier <fabien@symfony.com> */ class HttpKernelExtension extends AbstractExtension { public function getFunctions() { return array( new TwigFunction('render', array(HttpKernelRuntime::class, 'renderFragment'), array('is_safe' => array('html'))), new TwigFunction('render_*', array(HttpKernelRuntime::class, 'renderFragmentStrategy'), array('is_safe' => array('html'))), new TwigFunction('controller', static::class.'::controller'), ); } public static function controller($controller, $attributes = array(), $query = array()) { return new ControllerReference($controller, $attributes, $query); } /** * {@inheritdoc} */ public function getName() { return 'http_kernel'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php�������������������������������0000664�0000000�0000000�00000003407�13247321071�0025706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpKernel\Controller\ControllerReference; /** * Provides integration with the HttpKernel component. * * @author Fabien Potencier <fabien@symfony.com> */ class HttpKernelRuntime { private $handler; public function __construct(FragmentHandler $handler) { $this->handler = $handler; } /** * Renders a fragment. * * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance * @param array $options An array of options * * @return string The fragment content * * @see FragmentHandler::render() */ public function renderFragment($uri, $options = array()) { $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); return $this->handler->render($uri, $strategy, $options); } /** * Renders a fragment. * * @param string $strategy A strategy name * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance * @param array $options An array of options * * @return string The fragment content * * @see FragmentHandler::render() */ public function renderFragmentStrategy($strategy, $uri, $options = array()) { return $this->handler->render($uri, $strategy, $options); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php������������������������������0000664�0000000�0000000�00000003364�13247321071�0026115�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * LogoutUrlHelper provides generator functions for the logout URL to Twig. * * @author Jeremy Mikola <jmikola@gmail.com> */ class LogoutUrlExtension extends AbstractExtension { private $generator; public function __construct(LogoutUrlGenerator $generator) { $this->generator = $generator; } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('logout_url', array($this, 'getLogoutUrl')), new TwigFunction('logout_path', array($this, 'getLogoutPath')), ); } /** * Generates the relative logout URL for the firewall. * * @param string|null $key The firewall key or null to use the current firewall key * * @return string The relative logout URL */ public function getLogoutPath($key = null) { return $this->generator->getLogoutPath($key); } /** * Generates the absolute logout URL for the firewall. * * @param string|null $key The firewall key or null to use the current firewall key * * @return string The absolute logout URL */ public function getLogoutUrl($key = null) { return $this->generator->getLogoutUrl($key); } /** * {@inheritdoc} */ public function getName() { return 'logout_url'; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/ProfilerExtension.php�������������������������������0000664�0000000�0000000�00000002603�13247321071�0025736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Stopwatch\Stopwatch; use Twig\Extension\ProfilerExtension as BaseProfilerExtension; use Twig\Profiler\Profile; /** * @author Fabien Potencier <fabien@symfony.com> */ class ProfilerExtension extends BaseProfilerExtension { private $stopwatch; private $events; public function __construct(Profile $profile, Stopwatch $stopwatch = null) { parent::__construct($profile); $this->stopwatch = $stopwatch; $this->events = new \SplObjectStorage(); } public function enter(Profile $profile) { if ($this->stopwatch && $profile->isTemplate()) { $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template'); } parent::enter($profile); } public function leave(Profile $profile) { parent::leave($profile); if ($this->stopwatch && $profile->isTemplate()) { $this->events[$profile]->stop(); unset($this->events[$profile]); } } /** * {@inheritdoc} */ public function getName() { return 'native_profiler'; } } �����������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php��������������������������������0000664�0000000�0000000�00000007727�13247321071�0025617�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\Extension\AbstractExtension; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Node; use Twig\TwigFunction; /** * Provides integration of the Routing component with Twig. * * @author Fabien Potencier <fabien@symfony.com> */ class RoutingExtension extends AbstractExtension { private $generator; public function __construct(UrlGeneratorInterface $generator) { $this->generator = $generator; } /** * Returns a list of functions to add to the existing list. * * @return array An array of functions */ public function getFunctions() { return array( new TwigFunction('url', array($this, 'getUrl'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), new TwigFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), ); } /** * @param string $name * @param array $parameters * @param bool $relative * * @return string */ public function getPath($name, $parameters = array(), $relative = false) { return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); } /** * @param string $name * @param array $parameters * @param bool $schemeRelative * * @return string */ public function getUrl($name, $parameters = array(), $schemeRelative = false) { return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); } /** * Determines at compile time whether the generated URL will be safe and thus * saving the unneeded automatic escaping for performance reasons. * * The URL generation process percent encodes non-alphanumeric characters. So there is no risk * that malicious/invalid characters are part of the URL. The only character within an URL that * must be escaped in html is the ampersand ("&") which separates query params. So we cannot mark * the URL generation as always safe, but only when we are sure there won't be multiple query * params. This is the case when there are none or only one constant parameter given. * E.g. we know beforehand this will be safe: * - path('route') * - path('route', {'param': 'value'}) * But the following may not: * - path('route', var) * - path('route', {'param': ['val1', 'val2'] }) // a sub-array * - path('route', {'param1': 'value1', 'param2': 'value2'}) * If param1 and param2 reference placeholder in the route, it would still be safe. But we don't know. * * @param Node $argsNode The arguments of the path/url function * * @return array An array with the contexts the URL is safe * * @final since version 3.4, type-hint to be changed to "\Twig\Node\Node" in 4.0 */ public function isUrlGenerationSafe(\Twig_Node $argsNode) { // support named arguments $paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : ( $argsNode->hasNode(1) ? $argsNode->getNode(1) : null ); if (null === $paramsNode || $paramsNode instanceof ArrayExpression && count($paramsNode) <= 2 && (!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression) ) { return array('html'); } return array(); } /** * {@inheritdoc} */ public function getName() { return 'routing'; } } �����������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php�������������������������������0000664�0000000�0000000�00000003173�13247321071�0025766�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Security\Acl\Voter\FieldVote; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * SecurityExtension exposes security context features. * * @author Fabien Potencier <fabien@symfony.com> */ class SecurityExtension extends AbstractExtension { private $securityChecker; public function __construct(AuthorizationCheckerInterface $securityChecker = null) { $this->securityChecker = $securityChecker; } public function isGranted($role, $object = null, $field = null) { if (null === $this->securityChecker) { return false; } if (null !== $field) { $object = new FieldVote($object, $field); } try { return $this->securityChecker->isGranted($role, $object); } catch (AuthenticationCredentialsNotFoundException $e) { return false; } } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('is_granted', array($this, 'isGranted')), ); } /** * {@inheritdoc} */ public function getName() { return 'security'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php������������������������������0000664�0000000�0000000�00000002361�13247321071�0026131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Bridge\Twig\TokenParser\StopwatchTokenParser; use Twig\Extension\AbstractExtension; /** * Twig extension for the stopwatch helper. * * @author Wouter J <wouter@wouterj.nl> */ class StopwatchExtension extends AbstractExtension { private $stopwatch; private $enabled; public function __construct(Stopwatch $stopwatch = null, $enabled = true) { $this->stopwatch = $stopwatch; $this->enabled = $enabled; } public function getStopwatch() { return $this->stopwatch; } public function getTokenParsers() { return array( /* * {% stopwatch foo %} * Some stuff which will be recorded on the timeline * {% endstopwatch %} */ new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled), ); } public function getName() { return 'stopwatch'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php����������������������������0000664�0000000�0000000�00000006440�13247321071�0026455�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Bridge\Twig\TokenParser\TransTokenParser; use Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser; use Symfony\Bridge\Twig\TokenParser\TransDefaultDomainTokenParser; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor; use Twig\Extension\AbstractExtension; use Twig\NodeVisitor\NodeVisitorInterface; use Twig\TokenParser\AbstractTokenParser; use Twig\TwigFilter; /** * Provides integration of the Translation component with Twig. * * @author Fabien Potencier <fabien@symfony.com> */ class TranslationExtension extends AbstractExtension { private $translator; private $translationNodeVisitor; public function __construct(TranslatorInterface $translator = null, NodeVisitorInterface $translationNodeVisitor = null) { $this->translator = $translator; $this->translationNodeVisitor = $translationNodeVisitor; } public function getTranslator() { return $this->translator; } /** * {@inheritdoc} */ public function getFilters() { return array( new TwigFilter('trans', array($this, 'trans')), new TwigFilter('transchoice', array($this, 'transchoice')), ); } /** * Returns the token parser instance to add to the existing list. * * @return AbstractTokenParser[] */ public function getTokenParsers() { return array( // {% trans %}Symfony is great!{% endtrans %} new TransTokenParser(), // {% transchoice count %} // {0} There is no apples|{1} There is one apple|]1,Inf] There is {{ count }} apples // {% endtranschoice %} new TransChoiceTokenParser(), // {% trans_default_domain "foobar" %} new TransDefaultDomainTokenParser(), ); } /** * {@inheritdoc} */ public function getNodeVisitors() { return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()); } public function getTranslationNodeVisitor() { return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor(); } public function trans($message, array $arguments = array(), $domain = null, $locale = null) { if (null === $this->translator) { return strtr($message, $arguments); } return $this->translator->trans($message, $arguments, $domain, $locale); } public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null) { if (null === $this->translator) { return strtr($message, $arguments); } return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale); } /** * {@inheritdoc} */ public function getName() { return 'translator'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php��������������������������������0000664�0000000�0000000�00000010444�13247321071�0025511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Fig\Link\GenericLinkProvider; use Fig\Link\Link; use Symfony\Component\HttpFoundation\RequestStack; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * Twig extension for the Symfony WebLink component. * * @author Kévin Dunglas <dunglas@gmail.com> */ class WebLinkExtension extends AbstractExtension { private $requestStack; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } /** * {@inheritdoc} */ public function getFunctions() { return array( new TwigFunction('link', array($this, 'link')), new TwigFunction('preload', array($this, 'preload')), new TwigFunction('dns_prefetch', array($this, 'dnsPrefetch')), new TwigFunction('preconnect', array($this, 'preconnect')), new TwigFunction('prefetch', array($this, 'prefetch')), new TwigFunction('prerender', array($this, 'prerender')), ); } /** * Adds a "Link" HTTP header. * * @param string $uri The relation URI * @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch") * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") * * @return string The relation URI */ public function link($uri, $rel, array $attributes = array()) { if (!$request = $this->requestStack->getMasterRequest()) { return $uri; } $link = new Link($rel, $uri); foreach ($attributes as $key => $value) { $link = $link->withAttribute($key, $value); } $linkProvider = $request->attributes->get('_links', new GenericLinkProvider()); $request->attributes->set('_links', $linkProvider->withLink($link)); return $uri; } /** * Preloads a resource. * * @param string $uri A public path * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('crossorigin' => 'use-credentials')") * * @return string The path of the asset */ public function preload($uri, array $attributes = array()) { return $this->link($uri, 'preload', $attributes); } /** * Resolves a resource origin as early as possible. * * @param string $uri A public path * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") * * @return string The path of the asset */ public function dnsPrefetch($uri, array $attributes = array()) { return $this->link($uri, 'dns-prefetch', $attributes); } /** * Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation). * * @param string $uri A public path * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") * * @return string The path of the asset */ public function preconnect($uri, array $attributes = array()) { return $this->link($uri, 'preconnect', $attributes); } /** * Indicates to the client that it should prefetch this resource. * * @param string $uri A public path * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") * * @return string The path of the asset */ public function prefetch($uri, array $attributes = array()) { return $this->link($uri, 'prefetch', $attributes); } /** * Indicates to the client that it should prerender this resource . * * @param string $uri A public path * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") * * @return string The path of the asset */ public function prerender($uri, array $attributes = array()) { return $this->link($uri, 'prerender', $attributes); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php�������������������������������0000664�0000000�0000000�00000006062�13247321071�0025771�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\Transition; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; /** * WorkflowExtension. * * @author Grégoire Pineau <lyrixx@lyrixx.info> */ class WorkflowExtension extends AbstractExtension { private $workflowRegistry; public function __construct(Registry $workflowRegistry) { $this->workflowRegistry = $workflowRegistry; } public function getFunctions() { return array( new TwigFunction('workflow_can', array($this, 'canTransition')), new TwigFunction('workflow_transitions', array($this, 'getEnabledTransitions')), new TwigFunction('workflow_has_marked_place', array($this, 'hasMarkedPlace')), new TwigFunction('workflow_marked_places', array($this, 'getMarkedPlaces')), ); } /** * Returns true if the transition is enabled. * * @param object $subject A subject * @param string $transitionName A transition * @param string $name A workflow name * * @return bool true if the transition is enabled */ public function canTransition($subject, $transitionName, $name = null) { return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName); } /** * Returns all enabled transitions. * * @param object $subject A subject * @param string $name A workflow name * * @return Transition[] All enabled transitions */ public function getEnabledTransitions($subject, $name = null) { return $this->workflowRegistry->get($subject, $name)->getEnabledTransitions($subject); } /** * Returns true if the place is marked. * * @param object $subject A subject * @param string $placeName A place name * @param string $name A workflow name * * @return bool true if the transition is enabled */ public function hasMarkedPlace($subject, $placeName, $name = null) { return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName); } /** * Returns marked places. * * @param object $subject A subject * @param bool $placesNameOnly If true, returns only places name. If false returns the raw representation * @param string $name A workflow name * * @return string[]|int[] */ public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null) { $places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces(); if ($placesNameOnly) { return array_keys($places); } return $places; } public function getName() { return 'workflow'; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Extension/YamlExtension.php�����������������������������������0000664�0000000�0000000�00000004054�13247321071�0025060�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Yaml\Dumper as YamlDumper; use Symfony\Component\Yaml\Yaml; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; /** * Provides integration of the Yaml component with Twig. * * @author Fabien Potencier <fabien@symfony.com> */ class YamlExtension extends AbstractExtension { /** * {@inheritdoc} */ public function getFilters() { return array( new TwigFilter('yaml_encode', array($this, 'encode')), new TwigFilter('yaml_dump', array($this, 'dump')), ); } public function encode($input, $inline = 0, $dumpObjects = 0) { static $dumper; if (null === $dumper) { $dumper = new YamlDumper(); } if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { if (is_bool($dumpObjects)) { @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); $flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0; } else { $flags = $dumpObjects; } return $dumper->dump($input, $inline, 0, $flags); } return $dumper->dump($input, $inline, 0, false, $dumpObjects); } public function dump($value, $inline = 0, $dumpObjects = false) { if (is_resource($value)) { return '%Resource%'; } if (is_array($value) || is_object($value)) { return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); } return $this->encode($value, $inline, $dumpObjects); } /** * {@inheritdoc} */ public function getName() { return 'yaml'; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Form/���������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0020474�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Form/TwigRenderer.php�����������������������������������������0000664�0000000�0000000�00000002570�13247321071�0023612�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Form; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use %s instead.', TwigRenderer::class, FormRenderer::class), E_USER_DEPRECATED); /** * @author Bernhard Schussek <bschussek@gmail.com> * * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\Form\FormRenderer instead. */ class TwigRenderer extends FormRenderer implements TwigRendererInterface { public function __construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface $csrfTokenManager = null) { parent::__construct($engine, $csrfTokenManager); } /** * Returns the engine used by this renderer. * * @return TwigRendererEngineInterface The renderer engine */ public function getEngine() { return parent::getEngine(); } /** * {@inheritdoc} */ public function setEnvironment(Environment $environment) { $this->getEngine()->setEnvironment($environment); } } ����������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php�����������������������������������0000664�0000000�0000000�00000020040�13247321071�0024730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Form; use Symfony\Component\Form\AbstractRendererEngine; use Symfony\Component\Form\FormView; use Twig\Environment; use Twig\Template; /** * @author Bernhard Schussek <bschussek@gmail.com> */ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererEngineInterface { /** * @var Environment */ private $environment; /** * @var Template */ private $template; public function __construct(array $defaultThemes = array(), Environment $environment = null) { if (null === $environment) { @trigger_error(sprintf('Not passing a Twig Environment as the second argument for "%s" constructor is deprecated since Symfony 3.2 and won\'t be possible in 4.0.', static::class), E_USER_DEPRECATED); } parent::__construct($defaultThemes); $this->environment = $environment; } /** * {@inheritdoc} * * @deprecated since version 3.3, to be removed in 4.0 */ public function setEnvironment(Environment $environment) { if ($this->environment) { @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass the Twig Environment as second argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED); } $this->environment = $environment; } /** * {@inheritdoc} */ public function renderBlock(FormView $view, $resource, $blockName, array $variables = array()) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; $context = $this->environment->mergeGlobals($variables); ob_start(); // By contract,This method can only be called after getting the resource // (which is passed to the method). Getting a resource for the first time // (with an empty cache) is guaranteed to invoke loadResourcesFromTheme(), // where the property $template is initialized. // We do not call renderBlock here to avoid too many nested level calls // (XDebug limits the level to 100 by default) $this->template->displayBlock($blockName, $context, $this->resources[$cacheKey]); return ob_get_clean(); } /** * Loads the cache with the resource for a given block name. * * This implementation eagerly loads all blocks of the themes assigned to the given view * and all of its ancestors views. This is necessary, because Twig receives the * list of blocks later. At that point, all blocks must already be loaded, for the * case that the function "block()" is used in the Twig template. * * @see getResourceForBlock() * * @param string $cacheKey The cache key of the form view * @param FormView $view The form view for finding the applying themes * @param string $blockName The name of the block to load * * @return bool True if the resource could be loaded, false otherwise */ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName) { // The caller guarantees that $this->resources[$cacheKey][$block] is // not set, but it doesn't have to check whether $this->resources[$cacheKey] // is set. If $this->resources[$cacheKey] is set, all themes for this // $cacheKey are already loaded (due to the eager population, see doc comment). if (isset($this->resources[$cacheKey])) { // As said in the previous, the caller guarantees that // $this->resources[$cacheKey][$block] is not set. Since the themes are // already loaded, it can only be a non-existing block. $this->resources[$cacheKey][$blockName] = false; return false; } // Recursively try to find the block in the themes assigned to $view, // then of its parent view, then of the parent view of the parent and so on. // When the root view is reached in this recursion, also the default // themes are taken into account. // Check each theme whether it contains the searched block if (isset($this->themes[$cacheKey])) { for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) { $this->loadResourcesFromTheme($cacheKey, $this->themes[$cacheKey][$i]); // CONTINUE LOADING (see doc comment) } } // Check the default themes once we reach the root view without success if (!$view->parent) { if (!isset($this->useDefaultThemes[$cacheKey]) || $this->useDefaultThemes[$cacheKey]) { for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) { $this->loadResourcesFromTheme($cacheKey, $this->defaultThemes[$i]); // CONTINUE LOADING (see doc comment) } } } // Proceed with the themes of the parent view if ($view->parent) { $parentCacheKey = $view->parent->vars[self::CACHE_KEY_VAR]; if (!isset($this->resources[$parentCacheKey])) { $this->loadResourceForBlockName($parentCacheKey, $view->parent, $blockName); } // EAGER CACHE POPULATION (see doc comment) foreach ($this->resources[$parentCacheKey] as $nestedBlockName => $resource) { if (!isset($this->resources[$cacheKey][$nestedBlockName])) { $this->resources[$cacheKey][$nestedBlockName] = $resource; } } } // Even though we loaded the themes, it can happen that none of them // contains the searched block if (!isset($this->resources[$cacheKey][$blockName])) { // Cache that we didn't find anything to speed up further accesses $this->resources[$cacheKey][$blockName] = false; } return false !== $this->resources[$cacheKey][$blockName]; } /** * Loads the resources for all blocks in a theme. * * @param string $cacheKey The cache key for storing the resource * @param mixed $theme The theme to load the block from. This parameter * is passed by reference, because it might be necessary * to initialize the theme first. Any changes made to * this variable will be kept and be available upon * further calls to this method using the same theme. */ protected function loadResourcesFromTheme($cacheKey, &$theme) { if (!$theme instanceof Template) { /* @var Template $theme */ $theme = $this->environment->loadTemplate($theme); } if (null === $this->template) { // Store the first Template instance that we find so that // we can call displayBlock() later on. It doesn't matter *which* // template we use for that, since we pass the used blocks manually // anyway. $this->template = $theme; } // Use a separate variable for the inheritance traversal, because // theme is a reference and we don't want to change it. $currentTheme = $theme; $context = $this->environment->mergeGlobals(array()); // The do loop takes care of template inheritance. // Add blocks from all templates in the inheritance tree, but avoid // overriding blocks already set. do { foreach ($currentTheme->getBlocks() as $block => $blockData) { if (!isset($this->resources[$cacheKey][$block])) { // The resource given back is the key to the bucket that // contains this block. $this->resources[$cacheKey][$block] = $blockData; } } } while (false !== $currentTheme = $currentTheme->getParent($context)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Form/TwigRendererEngineInterface.php��������������������������0000664�0000000�0000000�00000001245�13247321071�0026557�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Form; use Symfony\Component\Form\FormRendererEngineInterface; use Twig\Environment; // BC/FC with namespaced Twig class_exists('Twig\Environment'); /** * @author Bernhard Schussek <bschussek@gmail.com> * * @deprecated since version 3.2, to be removed in 4.0. */ interface TwigRendererEngineInterface extends FormRendererEngineInterface { public function setEnvironment(Environment $environment); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Form/TwigRendererInterface.php��������������������������������0000664�0000000�0000000�00000001223�13247321071�0025425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Form; use Symfony\Component\Form\FormRendererInterface; use Twig\Environment; // BC/FC with namespaced Twig class_exists('Twig\Environment'); /** * @author Bernhard Schussek <bschussek@gmail.com> * * @deprecated since version 3.2, to be removed in 4.0. */ interface TwigRendererInterface extends FormRendererInterface { public function setEnvironment(Environment $environment); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/LICENSE�������������������������������������������������������0000664�0000000�0000000�00000002051�13247321071�0020574�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2004-2018 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/���������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0020456�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/DumpNode.php���������������������������������������������0000664�0000000�0000000�00000005374�13247321071�0022713�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Node; /** * @author Julien Galenski <julien.galenski@gmail.com> */ class DumpNode extends Node { private $varPrefix; public function __construct($varPrefix, Node $values = null, $lineno, $tag = null) { $nodes = array(); if (null !== $values) { $nodes['values'] = $values; } parent::__construct($nodes, array(), $lineno, $tag); $this->varPrefix = $varPrefix; } /** * {@inheritdoc} */ public function compile(Compiler $compiler) { $compiler ->write("if (\$this->env->isDebug()) {\n") ->indent(); if (!$this->hasNode('values')) { // remove embedded templates (macros) from the context $compiler ->write(sprintf('$%svars = array();'."\n", $this->varPrefix)) ->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix)) ->indent() ->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix)) ->indent() ->write(sprintf('$%1$svars[$%1$skey] = $%1$sval;'."\n", $this->varPrefix)) ->outdent() ->write("}\n") ->outdent() ->write("}\n") ->addDebugInfo($this) ->write(sprintf('\Symfony\Component\VarDumper\VarDumper::dump($%svars);'."\n", $this->varPrefix)); } elseif (($values = $this->getNode('values')) && 1 === $values->count()) { $compiler ->addDebugInfo($this) ->write('\Symfony\Component\VarDumper\VarDumper::dump(') ->subcompile($values->getNode(0)) ->raw(");\n"); } else { $compiler ->addDebugInfo($this) ->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n") ->indent(); foreach ($values as $node) { $compiler->write(''); if ($node->hasAttribute('name')) { $compiler ->string($node->getAttribute('name')) ->raw(' => '); } $compiler ->subcompile($node) ->raw(",\n"); } $compiler ->outdent() ->write("));\n"); } $compiler ->outdent() ->write("}\n"); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/FormThemeNode.php����������������������������������������0000664�0000000�0000000�00000002667�13247321071�0023676�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Symfony\Bridge\Twig\Form\TwigRenderer; use Symfony\Component\Form\FormRenderer; use Twig\Compiler; use Twig\Error\RuntimeError; use Twig\Node\Node; /** * @author Fabien Potencier <fabien@symfony.com> */ class FormThemeNode extends Node { public function __construct(Node $form, Node $resources, $lineno, $tag = null, $only = false) { parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => (bool) $only), $lineno, $tag); } public function compile(Compiler $compiler) { try { $compiler->getEnvironment()->getRuntime(FormRenderer::class); $renderer = FormRenderer::class; } catch (RuntimeError $e) { $renderer = TwigRenderer::class; } $compiler ->addDebugInfo($this) ->write('$this->env->getRuntime(') ->string($renderer) ->raw(')->setTheme(') ->subcompile($this->getNode('form')) ->raw(', ') ->subcompile($this->getNode('resources')) ->raw(', ') ->raw(false === $this->getAttribute('only') ? 'true' : 'false') ->raw(");\n"); } } �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/RenderBlockNode.php��������������������������������������0000664�0000000�0000000�00000002416�13247321071�0024172�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Expression\FunctionExpression; /** * Compiles a call to {@link \Symfony\Component\Form\FormRendererInterface::renderBlock()}. * * The function name is used as block name. For example, if the function name * is "foo", the block "foo" will be rendered. * * @author Bernhard Schussek <bschussek@gmail.com> */ class RenderBlockNode extends FunctionExpression { public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); $arguments = iterator_to_array($this->getNode('arguments')); $compiler->write('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->renderBlock('); if (isset($arguments[0])) { $compiler->subcompile($arguments[0]); $compiler->raw(', \''.$this->getAttribute('name').'\''); if (isset($arguments[1])) { $compiler->raw(', '); $compiler->subcompile($arguments[1]); } } $compiler->raw(')'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php�����������������������������0000664�0000000�0000000�00000011015�13247321071�0025736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FunctionExpression; /** * @author Bernhard Schussek <bschussek@gmail.com> */ class SearchAndRenderBlockNode extends FunctionExpression { public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); $compiler->raw('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock('); preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches); $label = null; $arguments = iterator_to_array($this->getNode('arguments')); $blockNameSuffix = $matches[1]; if (isset($arguments[0])) { $compiler->subcompile($arguments[0]); $compiler->raw(', \''.$blockNameSuffix.'\''); if (isset($arguments[1])) { if ('label' === $blockNameSuffix) { // The "label" function expects the label in the second and // the variables in the third argument $label = $arguments[1]; $variables = isset($arguments[2]) ? $arguments[2] : null; $lineno = $label->getTemplateLine(); if ($label instanceof ConstantExpression) { // If the label argument is given as a constant, we can either // strip it away if it is empty, or integrate it into the array // of variables at compile time. $labelIsExpression = false; // Only insert the label into the array if it is not empty if (!twig_test_empty($label->getAttribute('value'))) { $originalVariables = $variables; $variables = new ArrayExpression(array(), $lineno); $labelKey = new ConstantExpression('label', $lineno); if (null !== $originalVariables) { foreach ($originalVariables->getKeyValuePairs() as $pair) { // Don't copy the original label attribute over if it exists if ((string) $labelKey !== (string) $pair['key']) { $variables->addElement($pair['value'], $pair['key']); } } } // Insert the label argument into the array $variables->addElement($label, $labelKey); } } else { // The label argument is not a constant, but some kind of // expression. This expression needs to be evaluated at runtime. // Depending on the result (whether it is null or not), the // label in the arguments should take precedence over the label // in the attributes or not. $labelIsExpression = true; } } else { // All other functions than "label" expect the variables // in the second argument $label = null; $variables = $arguments[1]; $labelIsExpression = false; } if (null !== $variables || $labelIsExpression) { $compiler->raw(', '); if (null !== $variables) { $compiler->subcompile($variables); } if ($labelIsExpression) { if (null !== $variables) { $compiler->raw(' + '); } // Check at runtime whether the label is empty. // If not, add it to the array at runtime. $compiler->raw('(twig_test_empty($_label_ = '); $compiler->subcompile($label); $compiler->raw(') ? array() : array("label" => $_label_))'); } } } } $compiler->raw(')'); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/StopwatchNode.php����������������������������������������0000664�0000000�0000000�00000002672�13247321071�0023760�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Node; /** * Represents a stopwatch node. * * @author Wouter J <wouter@wouterj.nl> */ class StopwatchNode extends Node { public function __construct(Node $name, Node $body, AssignNameExpression $var, $lineno = 0, $tag = null) { parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag); } public function compile(Compiler $compiler) { $compiler ->addDebugInfo($this) ->write('') ->subcompile($this->getNode('var')) ->raw(' = ') ->subcompile($this->getNode('name')) ->write(";\n") ->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->start(") ->subcompile($this->getNode('var')) ->raw(", 'template');\n") ->subcompile($this->getNode('body')) ->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->stop(") ->subcompile($this->getNode('var')) ->raw(");\n") ; } } ����������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php�������������������������������0000664�0000000�0000000�00000001417�13247321071�0025524�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; /** * @author Fabien Potencier <fabien@symfony.com> */ class TransDefaultDomainNode extends Node { public function __construct(AbstractExpression $expr, $lineno = 0, $tag = null) { parent::__construct(array('expr' => $expr), array(), $lineno, $tag); } public function compile(Compiler $compiler) { // noop as this node is just a marker for TranslationDefaultDomainNodeVisitor } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Node/TransNode.php��������������������������������������������0000664�0000000�0000000�00000010014�13247321071�0023060�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Node; use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\Node; use Twig\Node\TextNode; // BC/FC with namespaced Twig class_exists('Twig\Node\Expression\ArrayExpression'); /** * @author Fabien Potencier <fabien@symfony.com> */ class TransNode extends Node { public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null) { $nodes = array('body' => $body); if (null !== $domain) { $nodes['domain'] = $domain; } if (null !== $count) { $nodes['count'] = $count; } if (null !== $vars) { $nodes['vars'] = $vars; } if (null !== $locale) { $nodes['locale'] = $locale; } parent::__construct($nodes, array(), $lineno, $tag); } public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); $defaults = new ArrayExpression(array(), -1); if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof ArrayExpression) { $defaults = $this->getNode('vars'); $vars = null; } list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars); $method = !$this->hasNode('count') ? 'trans' : 'transChoice'; $compiler ->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->'.$method.'(') ->subcompile($msg) ; $compiler->raw(', '); if ($this->hasNode('count')) { $compiler ->subcompile($this->getNode('count')) ->raw(', ') ; } if (null !== $vars) { $compiler ->raw('array_merge(') ->subcompile($defaults) ->raw(', ') ->subcompile($this->getNode('vars')) ->raw(')') ; } else { $compiler->subcompile($defaults); } $compiler->raw(', '); if (!$this->hasNode('domain')) { $compiler->repr('messages'); } else { $compiler->subcompile($this->getNode('domain')); } if ($this->hasNode('locale')) { $compiler ->raw(', ') ->subcompile($this->getNode('locale')) ; } $compiler->raw(");\n"); } protected function compileString(Node $body, ArrayExpression $vars, $ignoreStrictCheck = false) { if ($body instanceof ConstantExpression) { $msg = $body->getAttribute('value'); } elseif ($body instanceof TextNode) { $msg = $body->getAttribute('data'); } else { return array($body, $vars); } preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches); foreach ($matches[1] as $var) { $key = new ConstantExpression('%'.$var.'%', $body->getTemplateLine()); if (!$vars->hasElement($key)) { if ('count' === $var && $this->hasNode('count')) { $vars->addElement($this->getNode('count'), $key); } else { $varExpr = new NameExpression($var, $body->getTemplateLine()); $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck); $vars->addElement($varExpr, $key); } } } return array(new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/NodeVisitor/��������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022036�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php�����������������������������������������0000664�0000000�0000000�00000004106�13247321071�0023621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\NodeVisitor; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> */ class Scope { private $parent; private $data = array(); private $left = false; public function __construct(Scope $parent = null) { $this->parent = $parent; } /** * Opens a new child scope. * * @return self */ public function enter() { return new self($this); } /** * Closes current scope and returns parent one. * * @return self|null */ public function leave() { $this->left = true; return $this->parent; } /** * Stores data into current scope. * * @param string $key * @param mixed $value * * @return $this * * @throws \LogicException */ public function set($key, $value) { if ($this->left) { throw new \LogicException('Left scope is not mutable.'); } $this->data[$key] = $value; return $this; } /** * Tests if a data is visible from current scope. * * @param string $key * * @return bool */ public function has($key) { if (array_key_exists($key, $this->data)) { return true; } if (null === $this->parent) { return false; } return $this->parent->has($key); } /** * Returns data visible from current scope. * * @param string $key * @param mixed $default * * @return mixed */ public function get($key, $default = null) { if (array_key_exists($key, $this->data)) { return $this->data[$key]; } if (null === $this->parent) { return $default; } return $this->parent->get($key, $default); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php�����������0000664�0000000�0000000�00000007506�13247321071�0031700�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\NodeVisitor; use Symfony\Bridge\Twig\Node\TransNode; use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; use Twig\Environment; use Twig\Node\BlockNode; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\ModuleNode; use Twig\Node\Node; use Twig\Node\SetNode; use Twig\NodeVisitor\AbstractNodeVisitor; /** * @author Fabien Potencier <fabien@symfony.com> */ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor { private $scope; public function __construct() { $this->scope = new Scope(); } /** * {@inheritdoc} */ protected function doEnterNode(Node $node, Environment $env) { if ($node instanceof BlockNode || $node instanceof ModuleNode) { $this->scope = $this->scope->enter(); } if ($node instanceof TransDefaultDomainNode) { if ($node->getNode('expr') instanceof ConstantExpression) { $this->scope->set('domain', $node->getNode('expr')); return $node; } else { $var = $this->getVarName(); $name = new AssignNameExpression($var, $node->getTemplateLine()); $this->scope->set('domain', new NameExpression($var, $node->getTemplateLine())); return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine()); } } if (!$this->scope->has('domain')) { return $node; } if ($node instanceof FilterExpression && in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) { $arguments = $node->getNode('arguments'); $ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2; if ($this->isNamedArguments($arguments)) { if (!$arguments->hasNode('domain') && !$arguments->hasNode($ind)) { $arguments->setNode('domain', $this->scope->get('domain')); } } else { if (!$arguments->hasNode($ind)) { if (!$arguments->hasNode($ind - 1)) { $arguments->setNode($ind - 1, new ArrayExpression(array(), $node->getTemplateLine())); } $arguments->setNode($ind, $this->scope->get('domain')); } } } elseif ($node instanceof TransNode) { if (!$node->hasNode('domain')) { $node->setNode('domain', $this->scope->get('domain')); } } return $node; } /** * {@inheritdoc} */ protected function doLeaveNode(Node $node, Environment $env) { if ($node instanceof TransDefaultDomainNode) { return false; } if ($node instanceof BlockNode || $node instanceof ModuleNode) { $this->scope = $this->scope->leave(); } return $node; } /** * {@inheritdoc} */ public function getPriority() { return -10; } /** * @return bool */ private function isNamedArguments($arguments) { foreach ($arguments as $name => $node) { if (!is_int($name)) { return true; } } return false; } private function getVarName() { return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php������������������������0000664�0000000�0000000�00000006740�13247321071�0027242�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\NodeVisitor; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Environment; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; use Twig\Node\Node; use Twig\NodeVisitor\AbstractNodeVisitor; /** * TranslationNodeVisitor extracts translation messages. * * @author Fabien Potencier <fabien@symfony.com> */ class TranslationNodeVisitor extends AbstractNodeVisitor { const UNDEFINED_DOMAIN = '_undefined'; private $enabled = false; private $messages = array(); public function enable() { $this->enabled = true; $this->messages = array(); } public function disable() { $this->enabled = false; $this->messages = array(); } public function getMessages() { return $this->messages; } /** * {@inheritdoc} */ protected function doEnterNode(Node $node, Environment $env) { if (!$this->enabled) { return $node; } if ( $node instanceof FilterExpression && 'trans' === $node->getNode('filter')->getAttribute('value') && $node->getNode('node') instanceof ConstantExpression ) { // extract constant nodes with a trans filter $this->messages[] = array( $node->getNode('node')->getAttribute('value'), $this->getReadDomainFromArguments($node->getNode('arguments'), 1), ); } elseif ( $node instanceof FilterExpression && 'transchoice' === $node->getNode('filter')->getAttribute('value') && $node->getNode('node') instanceof ConstantExpression ) { // extract constant nodes with a trans filter $this->messages[] = array( $node->getNode('node')->getAttribute('value'), $this->getReadDomainFromArguments($node->getNode('arguments'), 2), ); } elseif ($node instanceof TransNode) { // extract trans nodes $this->messages[] = array( $node->getNode('body')->getAttribute('data'), $node->hasNode('domain') ? $this->getReadDomainFromNode($node->getNode('domain')) : null, ); } return $node; } /** * {@inheritdoc} */ protected function doLeaveNode(Node $node, Environment $env) { return $node; } /** * {@inheritdoc} */ public function getPriority() { return 0; } /** * @param Node $arguments * @param int $index * * @return string|null */ private function getReadDomainFromArguments(Node $arguments, $index) { if ($arguments->hasNode('domain')) { $argument = $arguments->getNode('domain'); } elseif ($arguments->hasNode($index)) { $argument = $arguments->getNode($index); } else { return; } return $this->getReadDomainFromNode($argument); } /** * @return string|null */ private function getReadDomainFromNode(Node $node) { if ($node instanceof ConstantExpression) { return $node->getAttribute('value'); } return self::UNDEFINED_DOMAIN; } } ��������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/README.md�����������������������������������������������������0000664�0000000�0000000�00000000650�13247321071�0021051�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Twig Bridge =========== Provides integration for [Twig](http://twig.sensiolabs.org/) with various Symfony components. Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) ����������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/����������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021543�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022700�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/�����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023603�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig��0000664�0000000�0000000�00000003700�13247321071�0033547�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "bootstrap_3_layout.html.twig" %} {% block form_start -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} {{- parent() -}} {%- endblock form_start %} {# Labels #} {% block form_label -%} {%- if label is same as(false) -%} <div class="{{ block('form_label_class') }}"></div> {%- else -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) -%} {{- parent() -}} {%- endif -%} {%- endblock form_label %} {% block form_label_class -%} col-sm-2 {%- endblock form_label_class %} {# Rows #} {% block form_row -%} <div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}"> {{- form_label(form) -}} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} {{- form_errors(form) -}} </div> {##}</div> {%- endblock form_row %} {% block submit_row -%} <div class="form-group">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div>{#--#} </div> {%- endblock submit_row %} {% block reset_row -%} <div class="form-group">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div>{#--#} </div> {%- endblock reset_row %} {% block form_group_class -%} col-sm-10 {%- endblock form_group_class %} {% block checkbox_row -%} <div class="form-group{% if not valid %} has-error{% endif %}">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} {{- form_errors(form) -}} </div>{#--#} </div> {%- endblock checkbox_row %}����������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig�������������0000664�0000000�0000000�00000012044�13247321071�0031277�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "bootstrap_base_layout.html.twig" %} {# Widgets #} {% block form_widget_simple -%} {% if type is not defined or type not in ['file', 'hidden'] %} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {% block button_widget -%} {%- set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) -%} {{- parent() -}} {%- endblock button_widget %} {% block checkbox_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {% if 'checkbox-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} {% else -%} <div class="checkbox"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- endif -%} {%- endblock checkbox_widget %} {% block radio_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if 'radio-inline' in parent_label_class -%} {{- form_label(form, null, { widget: parent() }) -}} {%- else -%} <div class="radio"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- endif -%} {%- endblock radio_widget %} {# Labels #} {% block form_label -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%} {{- parent() -}} {%- endblock form_label %} {% block choice_label -%} {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%} {{- block('form_label') -}} {% endblock %} {% block checkbox_label -%} {%- set label_attr = label_attr|merge({'for': id}) -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {%- set label_attr = label_attr|merge({'for': id}) -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {% block checkbox_radio_label -%} {# Do not display the label if widget is not defined in order to prevent double label rendering #} {%- if widget is defined -%} {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} {%- if parent_label_class is defined -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) -%} {%- endif -%} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ '%name%': name, '%id%': id, }) -%} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> {{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} </label> {%- endif -%} {%- endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} <div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}"> {{- form_label(form) -}} {{- form_widget(form) -}} {{- form_errors(form) -}} </div> {%- endblock form_row %} {% block button_row -%} <div class="form-group"> {{- form_widget(form) -}} </div> {%- endblock button_row %} {% block choice_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock choice_row %} {% block date_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock date_row %} {% block time_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock time_row %} {% block datetime_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock datetime_row %} {% block checkbox_row -%} <div class="form-group{% if not valid %} has-error{% endif %}"> {{- form_widget(form) -}} {{- form_errors(form) -}} </div> {%- endblock checkbox_row %} {% block radio_row -%} <div class="form-group{% if not valid %} has-error{% endif %}"> {{- form_widget(form) -}} {{- form_errors(form) -}} </div> {%- endblock radio_row %} {# Errors #} {% block form_errors -%} {% if errors|length > 0 -%} {% if form is not rootform %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %} <ul class="list-unstyled"> {%- for error in errors -%} <li><span class="glyphicon glyphicon-exclamation-sign"></span> {{ error.message }}</li> {%- endfor -%} </ul> {% if form is not rootform %}</span>{% else %}</div>{% endif %} {%- endif %} {%- endblock form_errors %} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig��0000664�0000000�0000000�00000004716�13247321071�0033560�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "bootstrap_4_layout.html.twig" %} {# Labels #} {% block form_label -%} {%- if label is same as(false) -%} <div class="{{ block('form_label_class') }}"></div> {%- else -%} {%- if expanded is not defined or not expanded -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} {%- endif -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) -%} {{- parent() -}} {%- endif -%} {%- endblock form_label %} {% block form_label_class -%} col-sm-2 {%- endblock form_label_class %} {# Rows #} {% block form_row -%} {%- if expanded is defined and expanded -%} {{ block('fieldset_form_row') }} {%- else -%} <div class="form-group row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}"> {{- form_label(form) -}} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div> {##}</div> {%- endif -%} {%- endblock form_row %} {% block fieldset_form_row -%} <fieldset class="form-group"> <div class="row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}"> {{- form_label(form) -}} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div> </div> {##}</fieldset> {%- endblock fieldset_form_row %} {% block submit_row -%} <div class="form-group row">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div>{#--#} </div> {%- endblock submit_row %} {% block reset_row -%} <div class="form-group row">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} </div>{#--#} </div> {%- endblock reset_row %} {% block form_group_class -%} col-sm-10 {%- endblock form_group_class %} {% block checkbox_row -%} <div class="form-group row">{#--#} <div class="{{ block('form_label_class') }}"></div>{#--#} <div class="{{ block('form_group_class') }}"> {{- form_widget(form) -}} {{- form_errors(form) -}} </div>{#--#} </div> {%- endblock checkbox_row %} ��������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig�������������0000664�0000000�0000000�00000026366�13247321071�0031314�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "bootstrap_base_layout.html.twig" %} {# Widgets #} {% block money_widget -%} {%- set prepend = not (money_pattern starts with '{{') -%} {%- set append = not (money_pattern ends with '}}') -%} {%- if prepend or append -%} <div class="input-group{{ group_class|default('') }}"> {%- if prepend -%} <div class="input-group-prepend"> <span class="input-group-text">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> </div> {%- endif -%} {{- block('form_widget_simple') -}} {%- if append -%} <div class="input-group-append"> <span class="input-group-text">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> </div> {%- endif -%} </div> {%- else -%} {{- block('form_widget_simple') -}} {%- endif -%} {%- endblock money_widget %} {% block datetime_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock datetime_widget %} {% block date_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock date_widget %} {% block time_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock time_widget %} {% block dateinterval_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} <div {{ block('widget_container_attributes') }}> {%- if with_years -%} <div class="col-auto"> {{ form_label(form.years) }} {{ form_widget(form.years) }} </div> {%- endif -%} {%- if with_months -%} <div class="col-auto"> {{ form_label(form.months) }} {{ form_widget(form.months) }} </div> {%- endif -%} {%- if with_weeks -%} <div class="col-auto"> {{ form_label(form.weeks) }} {{ form_widget(form.weeks) }} </div> {%- endif -%} {%- if with_days -%} <div class="col-auto"> {{ form_label(form.days) }} {{ form_widget(form.days) }} </div> {%- endif -%} {%- if with_hours -%} <div class="col-auto"> {{ form_label(form.hours) }} {{ form_widget(form.hours) }} </div> {%- endif -%} {%- if with_minutes -%} <div class="col-auto"> {{ form_label(form.minutes) }} {{ form_widget(form.minutes) }} </div> {%- endif -%} {%- if with_seconds -%} <div class="col-auto"> {{ form_label(form.seconds) }} {{ form_widget(form.seconds) }} </div> {%- endif -%} {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} </div> {%- endif -%} {%- endblock dateinterval_widget %} {% block percent_widget -%} <div class="input-group{{ not valid ? ' form-control is-invalid' }}"> {% set valid = true %} {{- block('form_widget_simple') -}} <div class="input-group-append"> <span class="input-group-text">%</span> </div> </div> {%- endblock percent_widget %} {% block form_widget_simple -%} {% if type is not defined or type != 'hidden' %} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control' ~ (type|default('') == 'file' ? '-file' : ''))|trim}) -%} {% endif %} {%- if type is defined and (type == 'range' or type == 'color') %} {# Attribute "required" is not supported #} {%- set required = false -%} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {%- block widget_attributes -%} {%- if not valid %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' is-invalid')|trim}) %} {% endif -%} {{ parent() }} {%- endblock widget_attributes -%} {% block button_widget -%} {%- set attr = attr|merge({class: (attr.class|default('btn-secondary') ~ ' btn')|trim}) -%} {{- parent() -}} {%- endblock button_widget %} {% block checkbox_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if 'checkbox-custom' in parent_label_class -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%} <div class="custom-control custom-checkbox{{ 'checkbox-inline' in parent_label_class ? ' custom-control-inline' }}"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%} <div class="form-check{{ 'checkbox-inline' in parent_label_class ? ' form-check-inline' }}"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- endif -%} {%- endblock checkbox_widget %} {% block radio_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if 'radio-custom' in parent_label_class -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%} <div class="custom-control custom-radio{{ 'radio-inline' in parent_label_class ? ' custom-control-inline' }}"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%} <div class="form-check{{ 'radio-inline' in parent_label_class ? ' form-check-inline' }}"> {{- form_label(form, null, { widget: parent() }) -}} </div> {%- endif -%} {%- endblock radio_widget %} {% block choice_widget_expanded -%} <div {{ block('widget_container_attributes') }}> {%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, valid: valid, }) -}} {% endfor -%} </div> {%- endblock choice_widget_expanded %} {# Labels #} {% block form_label -%} {% if label is not same as(false) -%} {%- if compound is defined and compound -%} {%- set element = 'legend' -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} {%- else -%} {%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} {%- endif -%} {% if required -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} {%- endif -%} {% if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{{- form_errors(form) -}}</{{ element|default('label') }}> {%- endif -%} {%- endblock form_label %} {% block checkbox_radio_label -%} {#- Do not display the label if widget is not defined in order to prevent double label rendering -#} {%- if widget is defined -%} {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class) %} {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class) %} {%- if is_parent_custom or is_custom -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' custom-control-label')|trim}) -%} {%- else %} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-check-label')|trim}) -%} {%- endif %} {%- if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif -%} {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} {%- if parent_label_class is defined -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|replace({'checkbox-inline': '', 'radio-inline': '', 'checkbox-custom': '', 'radio-custom': ''})|trim}) -%} {%- endif -%} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ '%name%': name, '%id%': id, }) -%} {%- else -%} {%- set label = name|humanize -%} {%- endif -%} {%- endif -%} {{ widget|raw }} <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} {{- form_errors(form) -}} </label> {%- endif -%} {%- endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} {%- if compound is defined and compound -%} {%- set element = 'fieldset' -%} {%- endif -%} <{{ element|default('div') }} class="form-group"> {{- form_label(form) -}} {{- form_widget(form) -}} </{{ element|default('div') }}> {%- endblock form_row %} {# Errors #} {% block form_errors -%} {%- if errors|length > 0 -%} <div class="{% if form is not rootform %}invalid-feedback d-block{% else %}alert alert-danger{% endif %}"> <ul class="list-unstyled mb-0"> {%- for error in errors -%} <li><span class="initialism form-error-icon badge badge-danger">{{ 'Error'|trans({}, 'validators') }}</span> <span class="form-error-message">{{ error.message }}</span></li> {%- endfor -%} </ul> </div> {%- endif %} {%- endblock form_errors %} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig����������0000664�0000000�0000000�00000020475�13247321071�0032056�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "form_div_layout.html.twig" %} {# Widgets #} {% block textarea_widget -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} {{- parent() -}} {%- endblock textarea_widget %} {% block money_widget -%} {% set prepend = not (money_pattern starts with '{{') %} {% set append = not (money_pattern ends with '}}') %} {% if prepend or append %} <div class="input-group{{ group_class|default('') }}"> {% if prepend %} <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> {% endif %} {{- block('form_widget_simple') -}} {% if append %} <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> {% endif %} </div> {% else %} {{- block('form_widget_simple') -}} {% endif %} {%- endblock money_widget %} {% block percent_widget -%} <div class="input-group"> {{- block('form_widget_simple') -}} <span class="input-group-addon">%</span> </div> {%- endblock percent_widget %} {% block datetime_widget -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} <div {{ block('widget_container_attributes') }}> {{- form_errors(form.date) -}} {{- form_errors(form.time) -}} <div class="sr-only"> {%- if form.date.year is defined %}{{ form_label(form.date.year) }}{% endif -%} {%- if form.date.month is defined %}{{ form_label(form.date.month) }}{% endif -%} {%- if form.date.day is defined %}{{ form_label(form.date.day) }}{% endif -%} {%- if form.time.hour is defined %}{{ form_label(form.time.hour) }}{% endif -%} {%- if form.time.minute is defined %}{{ form_label(form.time.minute) }}{% endif -%} {%- if form.time.second is defined %}{{ form_label(form.time.second) }}{% endif -%} </div> {{- form_widget(form.date, { datetime: true } ) -}} {{- form_widget(form.time, { datetime: true } ) -}} </div> {%- endif -%} {%- endblock datetime_widget %} {% block date_widget -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {%- if datetime is not defined or not datetime -%} <div {{ block('widget_container_attributes') -}}> {%- endif %} <div class="sr-only"> {{ form_label(form.year) }} {{ form_label(form.month) }} {{ form_label(form.day) }} </div> {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), '{{ month }}': form_widget(form.month), '{{ day }}': form_widget(form.day), })|raw -}} {%- if datetime is not defined or not datetime -%} </div> {%- endif -%} {%- endif -%} {%- endblock date_widget %} {% block time_widget -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {%- if datetime is not defined or false == datetime -%} <div {{ block('widget_container_attributes') -}}> {%- endif -%} <div class="sr-only">{{ form_label(form.hour) }}</div> {{- form_widget(form.hour) -}} {%- if with_minutes -%}:<div class="sr-only">{{ form_label(form.minute) }}</div>{{ form_widget(form.minute) }}{%- endif -%} {%- if with_seconds -%}:<div class="sr-only">{{ form_label(form.second) }}</div>{{ form_widget(form.second) }}{%- endif -%} {%- if datetime is not defined or false == datetime -%} </div> {%- endif -%} {%- endif -%} {%- endblock time_widget %} {%- block dateinterval_widget -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} <div {{ block('widget_container_attributes') }}> {{- form_errors(form) -}} <div class="table-responsive"> <table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}" role="presentation"> <thead> <tr> {%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%} {%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%} {%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%} {%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%} {%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%} {%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%} {%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%} </tr> </thead> <tbody> <tr> {%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%} {%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%} {%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%} {%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%} {%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%} {%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%} {%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%} </tr> </tbody> </table> </div> {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} </div> {%- endif -%} {%- endblock dateinterval_widget -%} {% block choice_widget_collapsed -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} {{- parent() -}} {%- endblock choice_widget_collapsed %} {% block choice_widget_expanded -%} {%- if '-inline' in label_attr.class|default('') -%} {%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endfor -%} {%- else -%} <div {{ block('widget_container_attributes') }}> {%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {%- endfor -%} </div> {%- endif -%} {%- endblock choice_widget_expanded %} {# Labels #} {% block choice_label -%} {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': '', 'checkbox-custom': '', 'radio-custom': ''})|trim}) -%} {{- block('form_label') -}} {% endblock choice_label %} {% block checkbox_label -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {# Rows #} {% block button_row -%} <div class="form-group"> {{- form_widget(form) -}} </div> {%- endblock button_row %} {% block choice_row -%} {%- set force_error = true -%} {{- block('form_row') -}} {%- endblock choice_row %} {% block date_row -%} {%- set force_error = true -%} {{- block('form_row') -}} {%- endblock date_row %} {% block time_row -%} {%- set force_error = true -%} {{- block('form_row') -}} {%- endblock time_row %} {% block datetime_row -%} {%- set force_error = true -%} {{- block('form_row') -}} {%- endblock datetime_row %} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig����������������0000664�0000000�0000000�00000035274�13247321071�0030657�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{# Widgets #} {%- block form_widget -%} {% if compound %} {{- block('form_widget_compound') -}} {% else %} {{- block('form_widget_simple') -}} {% endif %} {%- endblock form_widget -%} {%- block form_widget_simple -%} {%- set type = type|default('text') -%} <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/> {%- endblock form_widget_simple -%} {%- block form_widget_compound -%} <div {{ block('widget_container_attributes') }}> {%- if form is rootform -%} {{ form_errors(form) }} {%- endif -%} {{- block('form_rows') -}} {{- form_rest(form) -}} </div> {%- endblock form_widget_compound -%} {%- block collection_widget -%} {% if prototype is defined %} {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} {% endif %} {{- block('form_widget') -}} {%- endblock collection_widget -%} {%- block textarea_widget -%} <textarea {{ block('widget_attributes') }}>{{ value }}</textarea> {%- endblock textarea_widget -%} {%- block choice_widget -%} {% if expanded %} {{- block('choice_widget_expanded') -}} {% else %} {{- block('choice_widget_collapsed') -}} {% endif %} {%- endblock choice_widget -%} {%- block choice_widget_expanded -%} <div {{ block('widget_container_attributes') }}> {%- for child in form %} {{- form_widget(child) -}} {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} {% endfor -%} </div> {%- endblock choice_widget_expanded -%} {%- block choice_widget_collapsed -%} {%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%} {% set required = false %} {%- endif -%} <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}> {%- if placeholder is not none -%} <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option> {%- endif -%} {%- if preferred_choices|length > 0 -%} {% set options = preferred_choices %} {{- block('choice_widget_options') -}} {%- if choices|length > 0 and separator is not none -%} <option disabled="disabled">{{ separator }}</option> {%- endif -%} {%- endif -%} {%- set options = choices -%} {{- block('choice_widget_options') -}} </select> {%- endblock choice_widget_collapsed -%} {%- block choice_widget_options -%} {% for group_label, choice in options %} {%- if choice is iterable -%} <optgroup label="{{ choice_translation_domain is same as(false) ? group_label : group_label|trans({}, choice_translation_domain) }}"> {% set options = choice %} {{- block('choice_widget_options') -}} </optgroup> {%- else -%} <option value="{{ choice.value }}"{% if choice.attr %}{% with { attr: choice.attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option> {%- endif -%} {% endfor %} {%- endblock choice_widget_options -%} {%- block checkbox_widget -%} <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> {%- endblock checkbox_widget -%} {%- block radio_widget -%} <input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> {%- endblock radio_widget -%} {%- block datetime_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {%- else -%} <div {{ block('widget_container_attributes') }}> {{- form_errors(form.date) -}} {{- form_errors(form.time) -}} {{- form_widget(form.date) -}} {{- form_widget(form.time) -}} </div> {%- endif -%} {%- endblock datetime_widget -%} {%- block date_widget -%} {%- if widget == 'single_text' -%} {{ block('form_widget_simple') }} {%- else -%} <div {{ block('widget_container_attributes') }}> {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), '{{ month }}': form_widget(form.month), '{{ day }}': form_widget(form.day), })|raw -}} </div> {%- endif -%} {%- endblock date_widget -%} {%- block time_widget -%} {%- if widget == 'single_text' -%} {{ block('form_widget_simple') }} {%- else -%} {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} <div {{ block('widget_container_attributes') }}> {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} </div> {%- endif -%} {%- endblock time_widget -%} {%- block dateinterval_widget -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} <div {{ block('widget_container_attributes') }}> {{- form_errors(form) -}} <table class="{{ table_class|default('') }}" role="presentation"> <thead> <tr> {%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%} {%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%} {%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%} {%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%} {%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%} {%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%} {%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%} </tr> </thead> <tbody> <tr> {%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%} {%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%} {%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%} {%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%} {%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%} {%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%} {%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%} </tr> </tbody> </table> {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} </div> {%- endif -%} {%- endblock dateinterval_widget -%} {%- block number_widget -%} {# type="number" doesn't work with floats #} {%- set type = type|default('text') -%} {{ block('form_widget_simple') }} {%- endblock number_widget -%} {%- block integer_widget -%} {%- set type = type|default('number') -%} {{ block('form_widget_simple') }} {%- endblock integer_widget -%} {%- block money_widget -%} {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }} {%- endblock money_widget -%} {%- block url_widget -%} {%- set type = type|default('url') -%} {{ block('form_widget_simple') }} {%- endblock url_widget -%} {%- block search_widget -%} {%- set type = type|default('search') -%} {{ block('form_widget_simple') }} {%- endblock search_widget -%} {%- block percent_widget -%} {%- set type = type|default('text') -%} {{ block('form_widget_simple') }} % {%- endblock percent_widget -%} {%- block password_widget -%} {%- set type = type|default('password') -%} {{ block('form_widget_simple') }} {%- endblock password_widget -%} {%- block hidden_widget -%} {%- set type = type|default('hidden') -%} {{ block('form_widget_simple') }} {%- endblock hidden_widget -%} {%- block email_widget -%} {%- set type = type|default('email') -%} {{ block('form_widget_simple') }} {%- endblock email_widget -%} {%- block range_widget -%} {% set type = type|default('range') %} {{- block('form_widget_simple') -}} {%- endblock range_widget %} {%- block button_widget -%} {%- if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- elseif label is same as(false) -%} {% set translation_domain = false %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} <button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</button> {%- endblock button_widget -%} {%- block submit_widget -%} {%- set type = type|default('submit') -%} {{ block('button_widget') }} {%- endblock submit_widget -%} {%- block reset_widget -%} {%- set type = type|default('reset') -%} {{ block('button_widget') }} {%- endblock reset_widget -%} {%- block tel_widget -%} {%- set type = type|default('tel') -%} {{ block('form_widget_simple') }} {%- endblock tel_widget -%} {%- block color_widget -%} {%- set type = type|default('color') -%} {{ block('form_widget_simple') }} {%- endblock color_widget -%} {# Labels #} {%- block form_label -%} {% if label is not same as(false) -%} {% if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif -%} {% if required -%} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {%- endif -%} {% if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}> {%- if translation_domain is same as(false) -%} {{- label -}} {%- else -%} {{- label|trans({}, translation_domain) -}} {%- endif -%} </{{ element|default('label') }}> {%- endif -%} {%- endblock form_label -%} {%- block button_label -%}{%- endblock -%} {# Rows #} {%- block repeated_row -%} {# No need to render the errors here, as all errors are mapped to the first child (see RepeatedTypeValidatorExtension). #} {{- block('form_rows') -}} {%- endblock repeated_row -%} {%- block form_row -%} <div> {{- form_label(form) -}} {{- form_errors(form) -}} {{- form_widget(form) -}} </div> {%- endblock form_row -%} {%- block button_row -%} <div> {{- form_widget(form) -}} </div> {%- endblock button_row -%} {%- block hidden_row -%} {{ form_widget(form) }} {%- endblock hidden_row -%} {# Misc #} {%- block form -%} {{ form_start(form) }} {{- form_widget(form) -}} {{ form_end(form) }} {%- endblock form -%} {%- block form_start -%} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} {% set form_method = method %} {%- else -%} {% set form_method = "POST" %} {%- endif -%} <form name="{{ name }}" method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}> {%- if form_method != method -%} <input type="hidden" name="_method" value="{{ method }}" /> {%- endif -%} {%- endblock form_start -%} {%- block form_end -%} {%- if not render_rest is defined or render_rest -%} {{ form_rest(form) }} {%- endif -%} </form> {%- endblock form_end -%} {%- block form_errors -%} {%- if errors|length > 0 -%} <ul> {%- for error in errors -%} <li>{{ error.message }}</li> {%- endfor -%} </ul> {%- endif -%} {%- endblock form_errors -%} {%- block form_rest -%} {% for child in form -%} {% if not child.rendered %} {{- form_row(child) -}} {% endif %} {%- endfor -%} {% if not form.methodRendered and form is rootform %} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} {% set form_method = method %} {%- else -%} {% set form_method = "POST" %} {%- endif -%} {%- if form_method != method -%} <input type="hidden" name="_method" value="{{ method }}" /> {%- endif -%} {% endif -%} {% endblock form_rest %} {# Support #} {%- block form_rows -%} {% for child in form %} {{- form_row(child) -}} {% endfor %} {%- endblock form_rows -%} {%- block widget_attributes -%} id="{{ id }}" name="{{ full_name }}" {%- if disabled %} disabled="disabled"{% endif -%} {%- if required %} required="required"{% endif -%} {{ block('attributes') }} {%- endblock widget_attributes -%} {%- block widget_container_attributes -%} {%- if id is not empty %}id="{{ id }}"{% endif -%} {{ block('attributes') }} {%- endblock widget_container_attributes -%} {%- block button_attributes -%} id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%} {{ block('attributes') }} {%- endblock button_attributes -%} {% block attributes -%} {%- for attrname, attrvalue in attr -%} {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}" {%- elseif attrvalue is same as(true) -%} {{- attrname }}="{{ attrname }}" {%- elseif attrvalue is not same as(false) -%} {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} {%- endblock attributes -%} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig��������������0000664�0000000�0000000�00000001757�13247321071�0031163�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use "form_div_layout.html.twig" %} {%- block form_row -%} <tr> <td> {{- form_label(form) -}} </td> <td> {{- form_errors(form) -}} {{- form_widget(form) -}} </td> </tr> {%- endblock form_row -%} {%- block button_row -%} <tr> <td></td> <td> {{- form_widget(form) -}} </td> </tr> {%- endblock button_row -%} {%- block hidden_row -%} <tr style="display: none"> <td colspan="2"> {{- form_widget(form) -}} </td> </tr> {%- endblock hidden_row -%} {%- block form_widget_compound -%} <table {{ block('widget_container_attributes') }}> {%- if form is rootform and errors|length > 0 -%} <tr> <td colspan="2"> {{- form_errors(form) -}} </td> </tr> {%- endif -%} {{- block('form_rows') -}} {{- form_rest(form) -}} </table> {%- endblock form_widget_compound -%} �����������������symfony-3.4.6/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig������������0000664�0000000�0000000�00000027266�13247321071�0031446�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% extends "form_div_layout.html.twig" %} {# Based on Foundation 5 Doc #} {# Widgets #} {% block form_widget_simple -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {% block textarea_widget -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock textarea_widget %} {% block button_widget -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' button')|trim}) %} {{- parent() -}} {%- endblock button_widget %} {% block money_widget -%} <div class="row collapse"> {% set prepend = '{{' == money_pattern[0:2] %} {% if not prepend %} <div class="small-3 large-2 columns"> <span class="prefix">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> </div> {% endif %} <div class="small-9 large-10 columns"> {{- block('form_widget_simple') -}} </div> {% if prepend %} <div class="small-3 large-2 columns"> <span class="postfix">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> </div> {% endif %} </div> {%- endblock money_widget %} {% block percent_widget -%} <div class="row collapse"> <div class="small-9 large-10 columns"> {{- block('form_widget_simple') -}} </div> <div class="small-3 large-2 columns"> <span class="postfix">%</span> </div> </div> {%- endblock percent_widget %} {% block datetime_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %} <div class="row"> <div class="large-7 columns">{{ form_errors(form.date) }}</div> <div class="large-5 columns">{{ form_errors(form.time) }}</div> </div> <div {{ block('widget_container_attributes') }}> <div class="large-7 columns">{{ form_widget(form.date, { datetime: true } ) }}</div> <div class="large-5 columns">{{ form_widget(form.time, { datetime: true } ) }}</div> </div> {% endif %} {%- endblock datetime_widget %} {% block date_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %} {% if datetime is not defined or not datetime %} <div {{ block('widget_container_attributes') }}> {% endif %} {{- date_pattern|replace({ '{{ year }}': '<div class="large-4 columns">' ~ form_widget(form.year) ~ '</div>', '{{ month }}': '<div class="large-4 columns">' ~ form_widget(form.month) ~ '</div>', '{{ day }}': '<div class="large-4 columns">' ~ form_widget(form.day) ~ '</div>', })|raw -}} {% if datetime is not defined or not datetime %} </div> {% endif %} {% endif %} {%- endblock date_widget %} {% block time_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %} {% if datetime is not defined or false == datetime %} <div {{ block('widget_container_attributes') -}}> {% endif %} {% if with_seconds %} <div class="large-4 columns">{{ form_widget(form.hour) }}</div> <div class="large-4 columns"> <div class="row collapse"> <div class="small-3 large-2 columns"> <span class="prefix">:</span> </div> <div class="small-9 large-10 columns"> {{ form_widget(form.minute) }} </div> </div> </div> <div class="large-4 columns"> <div class="row collapse"> <div class="small-3 large-2 columns"> <span class="prefix">:</span> </div> <div class="small-9 large-10 columns"> {{ form_widget(form.second) }} </div> </div> </div> {% else %} <div class="large-6 columns">{{ form_widget(form.hour) }}</div> <div class="large-6 columns"> <div class="row collapse"> <div class="small-3 large-2 columns"> <span class="prefix">:</span> </div> <div class="small-9 large-10 columns"> {{ form_widget(form.minute) }} </div> </div> </div> {% endif %} {% if datetime is not defined or false == datetime %} </div> {% endif %} {% endif %} {%- endblock time_widget %} {% block choice_widget_collapsed -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if multiple -%} {% set attr = attr|merge({style: (attr.style|default('') ~ ' height: auto; background-image: none;')|trim}) %} {% endif %} {% if required and placeholder is none and not placeholder_in_choices and not multiple -%} {% set required = false %} {%- endif -%} <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple" data-customforms="disabled"{% endif %}> {% if placeholder is not none -%} <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain) }}</option> {%- endif %} {%- if preferred_choices|length > 0 -%} {% set options = preferred_choices %} {{- block('choice_widget_options') -}} {% if choices|length > 0 and separator is not none -%} <option disabled="disabled">{{ separator }}</option> {%- endif %} {%- endif -%} {% set options = choices -%} {{- block('choice_widget_options') -}} </select> {%- endblock choice_widget_collapsed %} {% block choice_widget_expanded -%} {% if '-inline' in label_attr.class|default('') %} <ul class="inline-list"> {% for child in form %} <li>{{ form_widget(child, { parent_label_class: label_attr.class|default(''), }) }}</li> {% endfor %} </ul> {% else %} <div {{ block('widget_container_attributes') }}> {% for child in form %} {{ form_widget(child, { parent_label_class: label_attr.class|default(''), }) }} {% endfor %} </div> {% endif %} {%- endblock choice_widget_expanded %} {% block checkbox_widget -%} {% set parent_label_class = parent_label_class|default('') %} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if 'checkbox-inline' in parent_label_class %} {{ form_label(form, null, { widget: parent() }) }} {% else %} <div class="checkbox"> {{ form_label(form, null, { widget: parent() }) }} </div> {% endif %} {%- endblock checkbox_widget %} {% block radio_widget -%} {% set parent_label_class = parent_label_class|default('') %} {% if 'radio-inline' in parent_label_class %} {{ form_label(form, null, { widget: parent() }) }} {% else %} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} <div class="radio"> {{ form_label(form, null, { widget: parent() }) }} </div> {% endif %} {%- endblock radio_widget %} {# Labels #} {% block form_label -%} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock form_label %} {% block choice_label -%} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} {% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) %} {{- block('form_label') -}} {%- endblock choice_label %} {% block checkbox_label -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {% block checkbox_radio_label -%} {% if required %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if parent_label_class is defined %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %} {% endif %} {% if label is empty %} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {% endif %} <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> {{ widget|raw }} {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} </label> {%- endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} <div class="row"> <div class="large-12 columns{% if (not compound or force_error|default(false)) and not valid %} error{% endif %}"> {{ form_label(form) }} {{ form_widget(form) }} {{ form_errors(form) }} </div> </div> {%- endblock form_row %} {% block choice_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock choice_row %} {% block date_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock date_row %} {% block time_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock time_row %} {% block datetime_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock datetime_row %} {% block checkbox_row -%} <div class="row"> <div class="large-12 columns{% if not valid %} error{% endif %}"> {{ form_widget(form) }} {{ form_errors(form) }} </div> </div> {%- endblock checkbox_row %} {% block radio_row -%} <div class="row"> <div class="large-12 columns{% if not valid %} error{% endif %}"> {{ form_widget(form) }} {{ form_errors(form) }} </div> </div> {%- endblock radio_row %} {# Errors #} {% block form_errors -%} {% if errors|length > 0 -%} {% if form is not rootform %}<small class="error">{% else %}<div data-alert class="alert-box alert">{% endif %} {%- for error in errors -%} {{ error.message }} {% if not loop.last %}, {% endif %} {%- endfor -%} {% if form is not rootform %}</small>{% else %}</div>{% endif %} {%- endif %} {%- endblock form_errors %} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/��������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0020673�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php�������������������������������������0000664�0000000�0000000�00000021123�13247321071�0024431�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bridge\Twig\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\AppVariable; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Session; class AppVariableTest extends TestCase { /** * @var AppVariable */ protected $appVariable; protected function setUp() { $this->appVariable = new AppVariable(); } /** * @dataProvider debugDataProvider */ public function testDebug($debugFlag) { $this->appVariable->setDebug($debugFlag); $this->assertEquals($debugFlag, $this->appVariable->getDebug()); } public function debugDataProvider() { return array( 'debug on' => array(true), 'debug off' => array(false), ); } public function testEnvironment() { $this->appVariable->setEnvironment('dev'); $this->assertEquals('dev', $this->appVariable->getEnvironment()); } /** * @runInSeparateProcess */ public function testGetSession() { $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('getSession')->willReturn($session); $this->setRequestStack($request); $this->assertEquals($session, $this->appVariable->getSession()); } public function testGetSessionWithNoRequest() { $this->setRequestStack(null); $this->assertNull($this->appVariable->getSession()); } public function testGetRequest() { $this->setRequestStack($request = new Request()); $this->assertEquals($request, $this->appVariable->getRequest()); } public function testGetToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $tokenStorage->method('getToken')->willReturn($token); $this->assertEquals($token, $this->appVariable->getToken()); } public function testGetUser() { $this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); $this->assertEquals($user, $this->appVariable->getUser()); } public function testGetUserWithUsernameAsTokenUser() { $this->setTokenStorage($user = 'username'); $this->assertNull($this->appVariable->getUser()); } public function testGetTokenWithNoToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $this->assertNull($this->appVariable->getToken()); } public function testGetUserWithNoToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $this->assertNull($this->appVariable->getUser()); } /** * @expectedException \RuntimeException */ public function testEnvironmentNotSet() { $this->appVariable->getEnvironment(); } /** * @expectedException \RuntimeException */ public function testDebugNotSet() { $this->appVariable->getDebug(); } /** * @expectedException \RuntimeException */ public function testGetTokenWithTokenStorageNotSet() { $this->appVariable->getToken(); } /** * @expectedException \RuntimeException */ public function testGetUserWithTokenStorageNotSet() { $this->appVariable->getUser(); } /** * @expectedException \RuntimeException */ public function testGetRequestWithRequestStackNotSet() { $this->appVariable->getRequest(); } /** * @expectedException \RuntimeException */ public function testGetSessionWithRequestStackNotSet() { $this->appVariable->getSession(); } public function testGetFlashesWithNoRequest() { $this->setRequestStack(null); $this->assertEquals(array(), $this->appVariable->getFlashes()); } /** * @runInSeparateProcess */ public function testGetFlashesWithNoSessionStarted() { $flashMessages = $this->setFlashMessages(false); $this->assertEquals($flashMessages, $this->appVariable->getFlashes()); } /** * @runInSeparateProcess */ public function testGetFlashes() { $flashMessages = $this->setFlashMessages(); $this->assertEquals($flashMessages, $this->appVariable->getFlashes(null)); $flashMessages = $this->setFlashMessages(); $this->assertEquals($flashMessages, $this->appVariable->getFlashes('')); $flashMessages = $this->setFlashMessages(); $this->assertEquals($flashMessages, $this->appVariable->getFlashes(array())); $flashMessages = $this->setFlashMessages(); $this->assertEquals(array(), $this->appVariable->getFlashes('this-does-not-exist')); $flashMessages = $this->setFlashMessages(); $this->assertEquals( array('this-does-not-exist' => array()), $this->appVariable->getFlashes(array('this-does-not-exist')) ); $flashMessages = $this->setFlashMessages(); $this->assertEquals($flashMessages['notice'], $this->appVariable->getFlashes('notice')); $flashMessages = $this->setFlashMessages(); $this->assertEquals( array('notice' => $flashMessages['notice']), $this->appVariable->getFlashes(array('notice')) ); $flashMessages = $this->setFlashMessages(); $this->assertEquals( array('notice' => $flashMessages['notice'], 'this-does-not-exist' => array()), $this->appVariable->getFlashes(array('notice', 'this-does-not-exist')) ); $flashMessages = $this->setFlashMessages(); $this->assertEquals( array('notice' => $flashMessages['notice'], 'error' => $flashMessages['error']), $this->appVariable->getFlashes(array('notice', 'error')) ); $this->assertEquals( array('warning' => $flashMessages['warning']), $this->appVariable->getFlashes(array('warning')), 'After getting some flash types (e.g. "notice" and "error"), the rest of flash messages must remain (e.g. "warning").' ); $this->assertEquals( array('this-does-not-exist' => array()), $this->appVariable->getFlashes(array('this-does-not-exist')) ); } protected function setRequestStack($request) { $requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackMock->method('getCurrentRequest')->willReturn($request); $this->appVariable->setRequestStack($requestStackMock); } protected function setTokenStorage($user) { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $tokenStorage->method('getToken')->willReturn($token); $token->method('getUser')->willReturn($user); } private function setFlashMessages($sessionHasStarted = true) { $flashMessages = array( 'notice' => array('Notice #1 message'), 'warning' => array('Warning #1 message'), 'error' => array('Error #1 message', 'Error #2 message'), ); $flashBag = new FlashBag(); $flashBag->initialize($flashMessages); $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $session->method('isStarted')->willReturn($sessionHasStarted); $session->method('getFlashBag')->willReturn($flashBag); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('getSession')->willReturn($session); $this->setRequestStack($request); return $flashMessages; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Command/������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022251�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php�����������������������������0000664�0000000�0000000�00000007506�13247321071�0026037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Command\LintCommand; use Symfony\Component\Console\Application; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; use Twig\Loader\FilesystemLoader; use Twig\Environment; class LintCommandTest extends TestCase { private $files; public function testLintCorrectFile() { $tester = $this->createCommandTester(); $filename = $this->createFile('{{ foo }}'); $ret = $tester->execute(array('filename' => array($filename)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('OK in', trim($tester->getDisplay())); } public function testLintIncorrectFile() { $tester = $this->createCommandTester(); $filename = $this->createFile('{{ foo'); $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); $this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay())); } /** * @expectedException \RuntimeException */ public function testLintFileNotReadable() { $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); } public function testLintFileCompileTimeException() { $tester = $this->createCommandTester(); $filename = $this->createFile("{{ 2|number_format(2, decimal_point='.', ',') }}"); $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); $this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay())); } /** * @group legacy * @expectedDeprecation Passing a command name as the first argument of "Symfony\Bridge\Twig\Command\LintCommand::__construct" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead. * @expectedException \RuntimeException * @expectedExceptionMessage The Twig environment needs to be set. */ public function testLegacyLintCommand() { $command = new LintCommand(); $application = new Application(); $application->add($command); $command = $application->find('lint:twig'); $tester = new CommandTester($command); $tester->execute(array()); } /** * @return CommandTester */ private function createCommandTester() { $command = new LintCommand(new Environment(new FilesystemLoader())); $application = new Application(); $application->add($command); $command = $application->find('lint:twig'); return new CommandTester($command); } /** * @return string Path to the new file */ private function createFile($content) { $filename = tempnam(sys_get_temp_dir(), 'sf-'); file_put_contents($filename, $content); $this->files[] = $filename; return $filename; } protected function setUp() { $this->files = array(); } protected function tearDown() { foreach ($this->files as $file) { if (file_exists($file)) { unlink($file); } } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022647�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php�������������������������0000664�0000000�0000000�00000004120�13247321071�0026764�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\CodeExtension; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; class CodeExtensionTest extends TestCase { public function testFormatFile() { $expected = sprintf('<a href="proto://foobar%s#&line=25" title="Click to open this file" class="file_link">%s at line 25</a>', substr(__FILE__, 5), __FILE__); $this->assertEquals($expected, $this->getExtension()->formatFile(__FILE__, 25)); } /** * @dataProvider getClassNameProvider */ public function testGettingClassAbbreviation($class, $abbr) { $this->assertEquals($this->getExtension()->abbrClass($class), $abbr); } /** * @dataProvider getMethodNameProvider */ public function testGettingMethodAbbreviation($method, $abbr) { $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr); } public function getClassNameProvider() { return array( array('F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'), array('Bare', '<abbr title="Bare">Bare</abbr>'), ); } public function getMethodNameProvider() { return array( array('F\Q\N\Foo::Method', '<abbr title="F\Q\N\Foo">Foo</abbr>::Method()'), array('Bare::Method', '<abbr title="Bare">Bare</abbr>::Method()'), array('Closure', '<abbr title="Closure">Closure</abbr>'), array('Method', '<abbr title="Method">Method</abbr>()'), ); } public function testGetName() { $this->assertEquals('code', $this->getExtension()->getName()); } protected function getExtension() { return new CodeExtension(new FileLinkFormatter('proto://%f#&line=%l&'.substr(__FILE__, 0, 5).'>foobar'), '/root', 'UTF-8'); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php�������������������������0000664�0000000�0000000�00000011542�13247321071�0027025�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\DumpExtension; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Symfony\Component\VarDumper\VarDumper; use Symfony\Component\VarDumper\Cloner\VarCloner; use Twig\Environment; use Twig\Loader\ArrayLoader; class DumpExtensionTest extends TestCase { /** * @dataProvider getDumpTags */ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) { $extension = new DumpExtension(new VarCloner()); $twig = new Environment(new ArrayLoader(array('template' => $template)), array( 'debug' => $debug, 'cache' => false, 'optimizations' => 0, )); $twig->addExtension($extension); $dumped = null; $exception = null; $prevDumper = VarDumper::setHandler(function ($var) use (&$dumped) { $dumped = $var; }); try { $this->assertEquals($expectedOutput, $twig->render('template')); } catch (\Exception $exception) { } VarDumper::setHandler($prevDumper); if (null !== $exception) { throw $exception; } $this->assertSame($expectedDumped, $dumped); } public function getDumpTags() { return array( array('A{% dump %}B', true, 'AB', array()), array('A{% set foo="bar"%}B{% dump %}C', true, 'ABC', array('foo' => 'bar')), array('A{% dump %}B', false, 'AB', null), ); } /** * @dataProvider getDumpArgs */ public function testDump($context, $args, $expectedOutput, $debug = true) { $extension = new DumpExtension(new VarCloner()); $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array( 'debug' => $debug, 'cache' => false, 'optimizations' => 0, )); array_unshift($args, $context); array_unshift($args, $twig); $dump = call_user_func_array(array($extension, 'dump'), $args); if ($debug) { $this->assertStringStartsWith('<script>', $dump); $dump = preg_replace('/^.*?<pre/', '<pre', $dump); $dump = preg_replace('/sf-dump-\d+/', 'sf-dump', $dump); } $this->assertEquals($expectedOutput, $dump); } public function getDumpArgs() { return array( array(array(), array(), '', false), array(array(), array(), "<pre class=sf-dump id=sf-dump data-indent-pad=\" \">[]\n</pre><script>Sfdump(\"sf-dump\")</script>\n"), array( array(), array(123, 456), "<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>123</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n" ."<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>456</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n", ), array( array('foo' => 'bar'), array(), "<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-note>array:1</span> [<samp>\n" ." \"<span class=sf-dump-key>foo</span>\" => \"<span class=sf-dump-str title=\"3 characters\">bar</span>\"\n" ."</samp>]\n" ."</pre><script>Sfdump(\"sf-dump\")</script>\n", ), ); } public function testCustomDumper() { $output = ''; $lineDumper = function ($line) use (&$output) { $output .= $line; }; $dumper = new HtmlDumper($lineDumper); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries( '<pre class=sf-dump-test id=%s data-indent-pad="%s">', '</pre><script>Sfdump("%s")</script>' ); $extension = new DumpExtension(new VarCloner(), $dumper); $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array( 'debug' => true, 'cache' => false, 'optimizations' => 0, )); $dump = $extension->dump($twig, array(), 'foo'); $dump = preg_replace('/sf-dump-\d+/', 'sf-dump', $dump); $this->assertEquals( '<pre class=sf-dump-test id=sf-dump data-indent-pad=" ">"'. "<span class=sf-dump-str title=\"3 characters\">foo</span>\"\n". "</pre><script>Sfdump(\"sf-dump\")</script>\n", $dump, 'Custom dumper should be used to dump data.' ); $this->assertEmpty($output, 'Dumper output should be ignored.'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php�������������������0000664�0000000�0000000�00000001607�13247321071�0030260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\ExpressionExtension; use Twig\Environment; use Twig\Loader\ArrayLoader; class ExpressionExtensionTest extends TestCase { public function testExpressionCreation() { $template = "{{ expression('1 == 1') }}"; $twig = new Environment(new ArrayLoader(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new ExpressionExtension()); $output = $twig->render('template'); $this->assertEquals('1 == 1', $output); } } �������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024460�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php�������������0000664�0000000�0000000�00000001113�13247321071�0031276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures; use Twig\Loader\FilesystemLoader; class StubFilesystemLoader extends FilesystemLoader { protected function findTemplate($name, $throw = true) { // strip away bundle name $parts = explode(':', $name); return parent::findTemplate(end($parts), $throw); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php�������������������0000664�0000000�0000000�00000001452�13247321071�0030162�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures; use Symfony\Component\Translation\TranslatorInterface; class StubTranslator implements TranslatorInterface { public function trans($id, array $parameters = array(), $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } public function setLocale($locale) { } public function getLocale() { } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026456�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/����������������������0000775�0000000�0000000�00000000000�13247321071�0027421�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/child_label.html.twig�0000664�0000000�0000000�00000000126�13247321071�0033501�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% block form_label %} <label>{{ global }}child</label> {% endblock form_label %} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������custom_widgets.html.twig����������������������������������������������������������������������������0000664�0000000�0000000�00000001261�13247321071�0034241�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form������������������������������������������������������������������������������������������{% block _text_id_widget %} {% spaceless %} <div id="container"> {{ form_widget(form) }} </div> {% endspaceless %} {% endblock _text_id_widget %} {% block _names_entry_label %} {% spaceless %} {% if label is empty %} {% set label = name|humanize %} {% endif %} <label>Custom label: {{ label|trans({}, translation_domain) }}</label> {% endspaceless %} {% endblock _names_entry_label %} {% block _name_c_entry_label %} {% spaceless %} {% if label is empty %} {% set label = name|humanize %} {% endif %} <label>Custom name label: {{ label|trans({}, translation_domain) }}</label> {% endspaceless %} {% endblock _name_c_entry_label %} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������page_dynamic_extends.html.twig����������������������������������������������������������������������0000664�0000000�0000000�00000000063�13247321071�0035352�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form������������������������������������������������������������������������������������������{% extends dynamic_template_name ~ '.html.twig' %} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/parent_label.html.twig0000664�0000000�0000000�00000000113�13247321071�0033703�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% block form_label %} <label>parent</label> {% endblock form_label %} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme.html.twig�������0000664�0000000�0000000�00000000357�13247321071�0032367�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% block form_widget_simple %} {% spaceless %} {% set type = type|default('text') %} <input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" /> {% endspaceless %} {% endblock form_widget_simple %} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������theme_extends.html.twig�����������������������������������������������������������������������������0000664�0000000�0000000�00000000432�13247321071�0034034�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form������������������������������������������������������������������������������������������{% extends 'form_div_layout.html.twig' %} {% block form_widget_simple %} {% spaceless %} {% set type = type|default('text') %} <input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" /> {% endspaceless %} {% endblock form_widget_simple %} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_use.html.twig���0000664�0000000�0000000�00000000426�13247321071�0033240�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% use 'form_div_layout.html.twig' %} {% block form_widget_simple %} {% spaceless %} {% set type = type|default('text') %} <input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" /> {% endspaceless %} {% endblock form_widget_simple %} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������FormExtensionBootstrap3HorizontalLayoutTest.php�����������������������������������������������������0000664�0000000�0000000�00000006640�13247321071�0034200�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractBootstrap3HorizontalLayoutTest; use Twig\Environment; class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest { use RuntimeLoaderProvider; protected $testableFeatures = array( 'choice_attr', ); /** * @var FormRenderer */ private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'bootstrap_3_horizontal_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } } ������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php���������0000664�0000000�0000000�00000010106�13247321071�0032175�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractBootstrap3LayoutTest; use Twig\Environment; class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest { use RuntimeLoaderProvider; /** * @var FormRenderer */ private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������FormExtensionBootstrap4HorizontalLayoutTest.php�����������������������������������������������������0000664�0000000�0000000�00000006750�13247321071�0034203�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractBootstrap4HorizontalLayoutTest; /** * Class providing test cases for the Bootstrap 4 Twig form theme. * * @author Hidde Wieringa <hidde@hiddewieringa.nl> */ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTest { use RuntimeLoaderProvider; protected $testableFeatures = array( 'choice_attr', ); private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new \Twig_Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'bootstrap_4_horizontal_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } } ������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php���������0000664�0000000�0000000�00000010301�13247321071�0032173�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractBootstrap4LayoutTest; /** * Class providing test cases for the Bootstrap 4 horizontal Twig form theme. * * @author Hidde Wieringa <hidde@hiddewieringa.nl> */ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest { use RuntimeLoaderProvider; /** * @var FormRenderer */ private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new \Twig_Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'bootstrap_4_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php����������������0000664�0000000�0000000�00000016147�13247321071�0030672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractDivLayoutTest; use Twig\Environment; class FormExtensionDivLayoutTest extends AbstractDivLayoutTest { use RuntimeLoaderProvider; /** * @var FormRenderer */ private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); // the value can be any template that exists $environment->addGlobal('dynamic_template_name', 'child_label'); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'form_div_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testThemeBlockInheritanceUsingUse() { $view = $this->factory ->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType') ->createView() ; $this->setTheme($view, array('theme_use.html.twig')); $this->assertMatchesXpath( $this->renderWidget($view), '/input[@type="email"][@rel="theme"]' ); } public function testThemeBlockInheritanceUsingExtend() { $view = $this->factory ->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType') ->createView() ; $this->setTheme($view, array('theme_extends.html.twig')); $this->assertMatchesXpath( $this->renderWidget($view), '/input[@type="email"][@rel="theme"]' ); } public function testThemeBlockInheritanceUsingDynamicExtend() { $view = $this->factory ->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType') ->createView() ; $this->renderer->setTheme($view, array('page_dynamic_extends.html.twig')); $this->assertMatchesXpath( $this->renderer->searchAndRenderBlock($view, 'row'), '/div/label[text()="child"]' ); } public function isSelectedChoiceProvider() { return array( array(true, '0', '0'), array(true, '1', '1'), array(true, '', ''), array(true, '1.23', '1.23'), array(true, 'foo', 'foo'), array(true, 'foo10', 'foo10'), array(true, 'foo', array(1, 'foo', 'foo10')), array(false, 10, array(1, 'foo', 'foo10')), array(false, 0, array(1, 'foo', 'foo10')), ); } /** * @dataProvider isSelectedChoiceProvider */ public function testIsChoiceSelected($expected, $choice, $value) { $choice = new ChoiceView($choice, $choice, $choice.' label'); $this->assertSame($expected, \Symfony\Bridge\Twig\Extension\twig_is_selected_choice($choice, $value)); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } public function isRootFormProvider() { return array( array(true, new FormView()), array(false, new FormView(new FormView())), ); } /** * @dataProvider isRootFormProvider */ public function testIsRootForm($expected, FormView $formView) { $this->assertSame($expected, \Symfony\Bridge\Twig\Extension\twig_is_root_form($formView)); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } public static function themeBlockInheritanceProvider() { return array( array(array('theme.html.twig')), ); } public static function themeInheritanceProvider() { return array( array(array('parent_label.html.twig'), array('child_label.html.twig')), ); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php��������������0000664�0000000�0000000�00000010145�13247321071�0031167�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Component\Form\Tests\AbstractTableLayoutTest; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Twig\Environment; class FormExtensionTableLayoutTest extends AbstractTableLayoutTest { use RuntimeLoaderProvider; /** * @var FormRenderer */ private $renderer; protected function setUp() { parent::setUp(); $loader = new StubFilesystemLoader(array( __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', )); $environment = new Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); $environment->addExtension(new FormExtension()); $rendererEngine = new TwigRendererEngine(array( 'form_table_layout.html.twig', 'custom_widgets.html.twig', ), $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { if (null !== $label) { $vars += array('label' => $label); } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderErrors(FormView $view) { return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTest.php�������������������������0000664�0000000�0000000�00000005075�13247321071�0027027�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Form\FormRendererInterface; use Twig\Environment; /** * @group legacy */ class FormExtensionTest extends TestCase { /** * @dataProvider rendererDataProvider */ public function testInitRuntimeAndAccessRenderer($rendererConstructor, $expectedAccessedRenderer) { $extension = new FormExtension($rendererConstructor); $extension->initRuntime($this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock()); $this->assertSame($expectedAccessedRenderer, $extension->renderer); } /** * @dataProvider rendererDataProvider */ public function testAccessRendererAndInitRuntime($rendererConstructor, $expectedAccessedRenderer) { $extension = new FormExtension($rendererConstructor); $this->assertSame($expectedAccessedRenderer, $extension->renderer); $extension->initRuntime($this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock()); } public function rendererDataProvider() { $twigRenderer = $this->getMockBuilder(TwigRendererInterface::class)->getMock(); $twigRenderer->expects($this->once()) ->method('setEnvironment'); yield array($twigRenderer, $twigRenderer); $twigRenderer = $this->getMockBuilder(TwigRendererInterface::class)->getMock(); $twigRenderer->expects($this->once()) ->method('setEnvironment'); $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); $container->expects($this->once()) ->method('get') ->with('service_id') ->willReturn($twigRenderer); yield array(array($container, 'service_id'), $twigRenderer); $formRenderer = $this->getMockBuilder(FormRendererInterface::class)->getMock(); $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); $container->expects($this->once()) ->method('get') ->with('service_id') ->willReturn($formRenderer); yield array(array($container, 'service_id'), $formRenderer); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php���������������0000664�0000000�0000000�00000013515�13247321071�0031070�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\HttpFoundationExtension; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RequestContext; class HttpFoundationExtensionTest extends TestCase { /** * @dataProvider getGenerateAbsoluteUrlData() */ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); $extension = new HttpFoundationExtension($stack); $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } public function getGenerateAbsoluteUrlData() { return array( array('http://localhost/foo.png', '/foo.png', '/foo/bar.html'), array('http://localhost/foo/foo.png', 'foo.png', '/foo/bar.html'), array('http://localhost/foo/foo.png', 'foo.png', '/foo/bar'), array('http://localhost/foo/bar/foo.png', 'foo.png', '/foo/bar/'), array('http://example.com/baz', 'http://example.com/baz', '/'), array('https://example.com/baz', 'https://example.com/baz', '/'), array('//example.com/baz', '//example.com/baz', '/'), array('http://localhost/foo/bar?baz', '?baz', '/foo/bar'), array('http://localhost/foo/bar?baz=1', '?baz=1', '/foo/bar?foo=1'), array('http://localhost/foo/baz?baz=1', 'baz?baz=1', '/foo/bar?foo=1'), array('http://localhost/foo/bar#baz', '#baz', '/foo/bar'), array('http://localhost/foo/bar?0#baz', '#baz', '/foo/bar?0'), array('http://localhost/foo/bar?baz=1#baz', '?baz=1#baz', '/foo/bar?foo=1'), array('http://localhost/foo/baz?baz=1#baz', 'baz?baz=1#baz', '/foo/bar?foo=1'), ); } /** * @dataProvider getGenerateAbsoluteUrlRequestContextData */ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) { if (!class_exists('Symfony\Component\Routing\RequestContext')) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } $requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path); $extension = new HttpFoundationExtension(new RequestStack(), $requestContext); $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } /** * @dataProvider getGenerateAbsoluteUrlRequestContextData */ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) { if (!class_exists('Symfony\Component\Routing\RequestContext')) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } $extension = new HttpFoundationExtension(new RequestStack()); $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); } public function getGenerateAbsoluteUrlRequestContextData() { return array( array('/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'), array('foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo/foo.png'), array('foo.png', '/foo/bar/', 'localhost', 'http', 80, 443, 'http://localhost/foo/bar/foo.png'), array('/foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo.png'), array('foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo/foo.png'), array('foo.png', '/foo/bar/', 'localhost', 'https', 80, 443, 'https://localhost/foo/bar/foo.png'), array('/foo.png', '/foo', 'localhost', 'http', 443, 80, 'http://localhost:443/foo.png'), array('/foo.png', '/foo', 'localhost', 'https', 443, 80, 'https://localhost:80/foo.png'), ); } public function testGenerateAbsoluteUrlWithScriptFileName() { $request = Request::create('http://localhost/app/web/app_dev.php'); $request->server->set('SCRIPT_FILENAME', '/var/www/app/web/app_dev.php'); $stack = new RequestStack(); $stack->push($request); $extension = new HttpFoundationExtension($stack); $this->assertEquals( 'http://localhost/app/web/bundles/framework/css/structure.css', $extension->generateAbsoluteUrl('/app/web/bundles/framework/css/structure.css') ); } /** * @dataProvider getGenerateRelativePathData() */ public function testGenerateRelativePath($expected, $path, $pathinfo) { if (!method_exists('Symfony\Component\HttpFoundation\Request', 'getRelativeUriForPath')) { $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.'); } $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); $extension = new HttpFoundationExtension($stack); $this->assertEquals($expected, $extension->generateRelativePath($path)); } public function getGenerateRelativePathData() { return array( array('../foo.png', '/foo.png', '/foo/bar.html'), array('../baz/foo.png', '/baz/foo.png', '/foo/bar.html'), array('baz/foo.png', 'baz/foo.png', '/foo/bar.html'), array('http://example.com/baz', 'http://example.com/baz', '/'), array('https://example.com/baz', 'https://example.com/baz', '/'), array('//example.com/baz', '//example.com/baz', '/'), ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php�������������������0000664�0000000�0000000�00000006315�13247321071�0030202�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\HttpKernelExtension; use Symfony\Bridge\Twig\Extension\HttpKernelRuntime; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Twig\Environment; use Twig\Loader\ArrayLoader; class HttpKernelExtensionTest extends TestCase { /** * @expectedException \Twig\Error\RuntimeError */ public function testFragmentWithError() { $renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo'))); $this->renderTemplate($renderer); } public function testRenderFragment() { $renderer = $this->getFragmentHandler($this->returnValue(new Response('html'))); $response = $this->renderTemplate($renderer); $this->assertEquals('html', $response); } public function testUnknownFragmentRenderer() { $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') ->disableOriginalConstructor() ->getMock() ; $renderer = new FragmentHandler($context); if (method_exists($this, 'expectException')) { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('The "inline" renderer does not exist.'); } else { $this->setExpectedException('InvalidArgumentException', 'The "inline" renderer does not exist.'); } $renderer->render('/foo'); } protected function getFragmentHandler($return) { $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock(); $strategy->expects($this->once())->method('getName')->will($this->returnValue('inline')); $strategy->expects($this->once())->method('render')->will($return); $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') ->disableOriginalConstructor() ->getMock() ; $context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); return new FragmentHandler($context, array($strategy), false); } protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}') { $loader = new ArrayLoader(array('index' => $template)); $twig = new Environment($loader, array('debug' => true, 'cache' => false)); $twig->addExtension(new HttpKernelExtension()); $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); $loader->expects($this->any())->method('load')->will($this->returnValueMap(array( array('Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)), ))); $twig->addRuntimeLoader($loader); return $twig->render('index'); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php����������������������0000664�0000000�0000000�00000004162�13247321071�0027547�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\RoutingExtension; use Twig\Environment; use Twig\Node\Expression\FilterExpression; use Twig\Source; class RoutingExtensionTest extends TestCase { /** * @dataProvider getEscapingTemplates */ public function testEscaping($template, $mustBeEscaped) { $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock())); $nodes = $twig->parse($twig->tokenize(new Source($template, ''))); $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof FilterExpression); } public function getEscapingTemplates() { return array( array('{{ path("foo") }}', false), array('{{ path("foo", {}) }}', false), array('{{ path("foo", { foo: "foo" }) }}', false), array('{{ path("foo", foo) }}', true), array('{{ path("foo", { foo: foo }) }}', true), array('{{ path("foo", { foo: ["foo", "bar"] }) }}', true), array('{{ path("foo", { foo: "foo", bar: "bar" }) }}', true), array('{{ path(name = "foo", parameters = {}) }}', false), array('{{ path(name = "foo", parameters = { foo: "foo" }) }}', false), array('{{ path(name = "foo", parameters = foo) }}', true), array('{{ path(name = "foo", parameters = { foo: ["foo", "bar"] }) }}', true), array('{{ path(name = "foo", parameters = { foo: foo }) }}', true), array('{{ path(name = "foo", parameters = { foo: "foo", bar: "bar" }) }}', true), ); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php���������������������0000664�0000000�0000000�00000001453�13247321071�0027650�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Component\Form\FormRenderer; use Twig\Environment; trait RuntimeLoaderProvider { protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer) { $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); $loader->expects($this->any())->method('load')->will($this->returnValueMap(array( array('Symfony\Component\Form\FormRenderer', $renderer), ))); $environment->addRuntimeLoader($loader); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php��������������������0000664�0000000�0000000�00000005102�13247321071�0030067�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\StopwatchExtension; use Twig\Environment; use Twig\Error\RuntimeError; use Twig\Loader\ArrayLoader; class StopwatchExtensionTest extends TestCase { /** * @expectedException \Twig\Error\SyntaxError */ public function testFailIfStoppingWrongEvent() { $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', array()); } /** * @dataProvider getTimingTemplates */ public function testTiming($template, $events) { $twig = new Environment(new ArrayLoader(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new StopwatchExtension($this->getStopwatch($events))); try { $nodes = $twig->render('template'); } catch (RuntimeError $e) { throw $e->getPrevious(); } } public function getTimingTemplates() { return array( array('{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'), array('{% stopwatch "foo" %}symfony is fun{% endstopwatch %}{% stopwatch "bar" %}something{% endstopwatch %}', array('foo', 'bar')), array('{% set foo = "foo" %}{% stopwatch foo %}something{% endstopwatch %}', 'foo'), array('{% set foo = "foo" %}{% stopwatch foo %}something {% set foo = "bar" %}{% endstopwatch %}', 'foo'), array('{% stopwatch "foo.bar" %}something{% endstopwatch %}', 'foo.bar'), array('{% stopwatch "foo" %}something{% endstopwatch %}{% stopwatch "foo" %}something else{% endstopwatch %}', array('foo', 'foo')), ); } protected function getStopwatch($events = array()) { $events = is_array($events) ? $events : array($events); $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); $i = -1; foreach ($events as $eventName) { $stopwatch->expects($this->at(++$i)) ->method('start') ->with($this->equalTo($eventName), 'template') ; $stopwatch->expects($this->at(++$i)) ->method('stop') ->with($this->equalTo($eventName)) ; } return $stopwatch; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php������������������0000664�0000000�0000000�00000022436�13247321071�0030422�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\ArrayLoader; use Twig\Environment; use Twig\Loader\ArrayLoader as TwigArrayLoader; class TranslationExtensionTest extends TestCase { public function testEscaping() { $output = $this->getTemplate('{% trans %}Percent: %value%%% (%msg%){% endtrans %}')->render(array('value' => 12, 'msg' => 'approx.')); $this->assertEquals('Percent: 12% (approx.)', $output); } /** * @dataProvider getTransTests */ public function testTrans($template, $expected, array $variables = array()) { if ($expected != $this->getTemplate($template)->render($variables)) { echo $template."\n"; $loader = new TwigArrayLoader(array('index' => $template)); $twig = new Environment($loader, array('debug' => true, 'cache' => false)); $twig->addExtension(new TranslationExtension(new Translator('en'))); echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n"; $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } /** * @expectedException \Twig\Error\SyntaxError * @expectedExceptionMessage Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3. */ public function testTransUnknownKeyword() { $output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render(); } /** * @expectedException \Twig\Error\SyntaxError * @expectedExceptionMessage A message inside a trans tag must be a simple text in "index" at line 2. */ public function testTransComplexBody() { $output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); } /** * @expectedException \Twig\Error\SyntaxError * @expectedExceptionMessage A message inside a transchoice tag must be a simple text in "index" at line 2. */ public function testTransChoiceComplexBody() { $output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render(); } public function getTransTests() { return array( // trans tag array('{% trans %}Hello{% endtrans %}', 'Hello'), array('{% trans %}%name%{% endtrans %}', 'Symfony', array('name' => 'Symfony')), array('{% trans from elsewhere %}Hello{% endtrans %}', 'Hello'), array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony', array('name' => 'Symfony')), array('{% trans with { \'%name%\': \'Symfony\' } %}Hello %name%{% endtrans %}', 'Hello Symfony'), array('{% set vars = { \'%name%\': \'Symfony\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony'), array('{% trans into "fr"%}Hello{% endtrans %}', 'Hello'), // transchoice array( '{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is no apples', array('count' => 0), ), array( '{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is 5 apples', array('count' => 5), ), array( '{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', 'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony'), ), array( '{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', 'There is 5 apples (Symfony)', array('count' => 5), ), array( '{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is no apples', array('count' => 0), ), array( '{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is 5 apples', ), // trans filter array('{{ "Hello"|trans }}', 'Hello'), array('{{ name|trans }}', 'Symfony', array('name' => 'Symfony')), array('{{ hello|trans({ \'%name%\': \'Symfony\' }) }}', 'Hello Symfony', array('hello' => 'Hello %name%')), array('{% set vars = { \'%name%\': \'Symfony\' } %}{{ hello|trans(vars) }}', 'Hello Symfony', array('hello' => 'Hello %name%')), array('{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'), // transchoice filter array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}', 'There is 5 apples', array('count' => 5)), array('{{ text|transchoice(5, {\'%name%\': \'Symfony\'}) }}', 'There is 5 apples (Symfony)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')), array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {}, "messages", "fr") }}', 'There is 5 apples', array('count' => 5)), ); } public function testDefaultTranslationDomain() { $templates = array( 'index' => ' {%- extends "base" %} {%- trans_default_domain "foo" %} {%- block content %} {%- trans %}foo{% endtrans %} {%- trans from "custom" %}foo{% endtrans %} {{- "foo"|trans }} {{- "foo"|trans({}, "custom") }} {{- "foo"|transchoice(1) }} {{- "foo"|transchoice(1, {}, "custom") }} {% endblock %} ', 'base' => ' {%- block content "" %} ', ); $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', array('foo' => 'foo (messages)'), 'en'); $translator->addResource('array', array('foo' => 'foo (custom)'), 'en', 'custom'); $translator->addResource('array', array('foo' => 'foo (foo)'), 'en', 'foo'); $template = $this->getTemplate($templates, $translator); $this->assertEquals('foo (foo)foo (custom)foo (foo)foo (custom)foo (foo)foo (custom)', trim($template->render(array()))); } public function testDefaultTranslationDomainWithNamedArguments() { $templates = array( 'index' => ' {%- trans_default_domain "foo" %} {%- block content %} {{- "foo"|trans(arguments = {}, domain = "custom") }} {{- "foo"|transchoice(count = 1) }} {{- "foo"|transchoice(count = 1, arguments = {}, domain = "custom") }} {{- "foo"|trans({}, domain = "custom") }} {{- "foo"|trans({}, "custom", locale = "fr") }} {{- "foo"|transchoice(1, arguments = {}, domain = "custom") }} {{- "foo"|transchoice(1, {}, "custom", locale = "fr") }} {% endblock %} ', 'base' => ' {%- block content "" %} ', ); $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', array('foo' => 'foo (messages)'), 'en'); $translator->addResource('array', array('foo' => 'foo (custom)'), 'en', 'custom'); $translator->addResource('array', array('foo' => 'foo (foo)'), 'en', 'foo'); $translator->addResource('array', array('foo' => 'foo (fr)'), 'fr', 'custom'); $template = $this->getTemplate($templates, $translator); $this->assertEquals('foo (custom)foo (foo)foo (custom)foo (custom)foo (fr)foo (custom)foo (fr)', trim($template->render(array()))); } protected function getTemplate($template, $translator = null) { if (null === $translator) { $translator = new Translator('en'); } if (is_array($template)) { $loader = new TwigArrayLoader($template); } else { $loader = new TwigArrayLoader(array('index' => $template)); } $twig = new Environment($loader, array('debug' => true, 'cache' => false)); $twig->addExtension(new TranslationExtension($translator)); return $twig->loadTemplate('index'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/WebLinkExtensionTest.php����������������������0000664�0000000�0000000�00000006516�13247321071�0027460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use Fig\Link\Link; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\WebLinkExtension; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class WebLinkExtensionTest extends TestCase { /** * @var Request */ private $request; /** * @var WebLinkExtension */ private $extension; protected function setUp() { $this->request = new Request(); $requestStack = new RequestStack(); $requestStack->push($this->request); $this->extension = new WebLinkExtension($requestStack); } public function testLink() { $this->assertEquals('/foo.css', $this->extension->link('/foo.css', 'preload', array('as' => 'style', 'nopush' => true))); $link = (new Link('preload', '/foo.css'))->withAttribute('as', 'style')->withAttribute('nopush', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } public function testPreload() { $this->assertEquals('/foo.css', $this->extension->preload('/foo.css', array('as' => 'style', 'crossorigin' => true))); $link = (new Link('preload', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } public function testDnsPrefetch() { $this->assertEquals('/foo.css', $this->extension->dnsPrefetch('/foo.css', array('as' => 'style', 'crossorigin' => true))); $link = (new Link('dns-prefetch', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } public function testPreconnect() { $this->assertEquals('/foo.css', $this->extension->preconnect('/foo.css', array('as' => 'style', 'crossorigin' => true))); $link = (new Link('preconnect', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } public function testPrefetch() { $this->assertEquals('/foo.css', $this->extension->prefetch('/foo.css', array('as' => 'style', 'crossorigin' => true))); $link = (new Link('prefetch', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } public function testPrerender() { $this->assertEquals('/foo.css', $this->extension->prerender('/foo.css', array('as' => 'style', 'crossorigin' => true))); $link = (new Link('prerender', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php���������������������0000664�0000000�0000000�00000005417�13247321071�0027736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\WorkflowExtension; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\Workflow; class WorkflowExtensionTest extends TestCase { private $extension; protected function setUp() { $places = array('ordered', 'waiting_for_payment', 'processed'); $transitions = array( new Transition('t1', 'ordered', 'waiting_for_payment'), new Transition('t2', 'waiting_for_payment', 'processed'), ); $definition = new Definition($places, $transitions); $workflow = new Workflow($definition); $registry = new Registry(); $registry->add($workflow, new ClassInstanceSupportStrategy(\stdClass::class)); $this->extension = new WorkflowExtension($registry); } public function testCanTransition() { $subject = new \stdClass(); $subject->marking = array(); $this->assertTrue($this->extension->canTransition($subject, 't1')); $this->assertFalse($this->extension->canTransition($subject, 't2')); } public function testGetEnabledTransitions() { $subject = new \stdClass(); $subject->marking = array(); $transitions = $this->extension->getEnabledTransitions($subject); $this->assertCount(1, $transitions); $this->assertInstanceOf(Transition::class, $transitions[0]); $this->assertSame('t1', $transitions[0]->getName()); } public function testHasMarkedPlace() { $subject = new \stdClass(); $subject->marking = array(); $subject->marking = array('ordered' => 1, 'waiting_for_payment' => 1); $this->assertTrue($this->extension->hasMarkedPlace($subject, 'ordered')); $this->assertTrue($this->extension->hasMarkedPlace($subject, 'waiting_for_payment')); $this->assertFalse($this->extension->hasMarkedPlace($subject, 'processed')); } public function testGetMarkedPlaces() { $subject = new \stdClass(); $subject->marking = array(); $subject->marking = array('ordered' => 1, 'waiting_for_payment' => 1); $this->assertSame(array('ordered', 'waiting_for_payment'), $this->extension->getMarkedPlaces($subject)); $this->assertSame($subject->marking, $this->extension->getMarkedPlaces($subject, false)); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Fixtures/�����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022504�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Fixtures/extractor/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024517�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Fixtures/extractor/syntax_error.twig��������������������0000664�0000000�0000000�00000000020�13247321071�0030142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% syntax error ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Fixtures/extractor/with_translations.html.twig����������0000664�0000000�0000000�00000000033�13247321071�0032126�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<h1>{{ 'Hi!'|trans }}</h1> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Node/���������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021560�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php�����������������������������������0000664�0000000�0000000�00000006700�13247321071�0024647�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Node; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Node\DumpNode; use Twig\Compiler; use Twig\Environment; use Twig\Node\Expression\NameExpression; use Twig\Node\Node; class DumpNodeTest extends TestCase { public function testNoVar() { $node = new DumpNode('bar', null, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' if ($this->env->isDebug()) { $barvars = array(); foreach ($context as $barkey => $barval) { if (!$barval instanceof \Twig\Template) { $barvars[$barkey] = $barval; } } // line 7 \Symfony\Component\VarDumper\VarDumper::dump($barvars); } EOTXT; $this->assertSame($expected, $compiler->compile($node)->getSource()); } public function testIndented() { $node = new DumpNode('bar', null, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' if ($this->env->isDebug()) { $barvars = array(); foreach ($context as $barkey => $barval) { if (!$barval instanceof \Twig\Template) { $barvars[$barkey] = $barval; } } // line 7 \Symfony\Component\VarDumper\VarDumper::dump($barvars); } EOTXT; $this->assertSame($expected, $compiler->compile($node, 1)->getSource()); } public function testOneVar() { $vars = new Node(array( new NameExpression('foo', 7), )); $node = new DumpNode('bar', $vars, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' if ($this->env->isDebug()) { // line 7 \Symfony\Component\VarDumper\VarDumper::dump(%foo%); } EOTXT; if (\PHP_VERSION_ID >= 70000) { $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); } else { $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); } $this->assertSame($expected, $compiler->compile($node)->getSource()); } public function testMultiVars() { $vars = new Node(array( new NameExpression('foo', 7), new NameExpression('bar', 7), )); $node = new DumpNode('bar', $vars, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' if ($this->env->isDebug()) { // line 7 \Symfony\Component\VarDumper\VarDumper::dump(array( "foo" => %foo%, "bar" => %bar%, )); } EOTXT; if (\PHP_VERSION_ID >= 70000) { $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); } else { $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); } $this->assertSame($expected, $compiler->compile($node)->getSource()); } } ����������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php����������������������������������0000664�0000000�0000000�00000007276�13247321071�0025033�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Node; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Node\FormThemeNode; use Symfony\Bridge\Twig\Tests\Extension\RuntimeLoaderProvider; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormRendererEngineInterface; use Twig\Compiler; use Twig\Environment; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\Node; class FormThemeTest extends TestCase { use RuntimeLoaderProvider; public function testConstructor() { $form = new NameExpression('form', 0); $resources = new Node(array( new ConstantExpression('tpl1', 0), new ConstantExpression('tpl2', 0), )); $node = new FormThemeNode($form, $resources, 0); $this->assertEquals($form, $node->getNode('form')); $this->assertEquals($resources, $node->getNode('resources')); $this->assertFalse($node->getAttribute('only')); } public function testCompile() { $form = new NameExpression('form', 0); $resources = new ArrayExpression(array( new ConstantExpression(0, 0), new ConstantExpression('tpl1', 0), new ConstantExpression(1, 0), new ConstantExpression('tpl2', 0), ), 0); $node = new FormThemeNode($form, $resources, 0); $environment = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $formRenderer); $compiler = new Compiler($environment); $this->assertEquals( sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), true);', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); $node = new FormThemeNode($form, $resources, 0, null, true); $this->assertEquals( sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), false);', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); $resources = new ConstantExpression('tpl1', 0); $node = new FormThemeNode($form, $resources, 0); $this->assertEquals( sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", true);', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); $node = new FormThemeNode($form, $resources, 0, null, true); $this->assertEquals( sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", false);', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } protected function getVariableGetter($name) { if (\PHP_VERSION_ID >= 70000) { return sprintf('($context["%s"] ?? null)', $name); } return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php�������������������0000664�0000000�0000000�00000024226�13247321071�0027710�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Node; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode; use Twig\Compiler; use Twig\Environment; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConditionalExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\Node; class SearchAndRenderBlockNodeTest extends TestCase { public function testCompileWidget() { $arguments = new Node(array( new NameExpression('form', 0), )); $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\')', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileWidgetWithVariables() { $arguments = new Node(array( new NameExpression('form', 0), new ArrayExpression(array( new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), ), 0), )); $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\', array("foo" => "bar"))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithLabel() { $arguments = new Node(array( new NameExpression('form', 0), new ConstantExpression('my label', 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("label" => "my label"))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithNullLabel() { $arguments = new Node(array( new NameExpression('form', 0), new ConstantExpression(null, 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\')', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithEmptyStringLabel() { $arguments = new Node(array( new NameExpression('form', 0), new ConstantExpression('', 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\')', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithDefaultLabel() { $arguments = new Node(array( new NameExpression('form', 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\')', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithAttributes() { $arguments = new Node(array( new NameExpression('form', 0), new ConstantExpression(null, 0), new ArrayExpression(array( new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), ), 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. // https://github.com/symfony/symfony/issues/5029 $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar"))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithLabelAndAttributes() { $arguments = new Node(array( new NameExpression('form', 0), new ConstantExpression('value in argument', 0), new ArrayExpression(array( new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), new ConstantExpression('label', 0), new ConstantExpression('value in attributes', 0), ), 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in argument"))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithLabelThatEvaluatesToNull() { $arguments = new Node(array( new NameExpression('form', 0), new ConditionalExpression( // if new ConstantExpression(true, 0), // then new ConstantExpression(null, 0), // else new ConstantExpression(null, 0), 0 ), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. // https://github.com/symfony/symfony/issues/5029 $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() { $arguments = new Node(array( new NameExpression('form', 0), new ConditionalExpression( // if new ConstantExpression(true, 0), // then new ConstantExpression(null, 0), // else new ConstantExpression(null, 0), 0 ), new ArrayExpression(array( new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), new ConstantExpression('label', 0), new ConstantExpression('value in attributes', 0), ), 0), )); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. // https://github.com/symfony/symfony/issues/5029 $this->assertEquals( sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in attributes") + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))', $this->getVariableGetter('form') ), trim($compiler->compile($node)->getSource()) ); } protected function getVariableGetter($name) { if (\PHP_VERSION_ID >= 70000) { return sprintf('($context["%s"] ?? null)', $name); } return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php����������������������������������0000664�0000000�0000000�00000005035�13247321071�0025031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Node; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Compiler; use Twig\Environment; use Twig\Node\Expression\NameExpression; use Twig\Node\TextNode; /** * @author Asmir Mustafic <goetas@gmail.com> */ class TransNodeTest extends TestCase { public function testCompileStrict() { $body = new TextNode('trans %var%', 0); $vars = new NameExpression('foo', 0); $node = new TransNode($body, null, null, $vars); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('strict_variables' => true)); $compiler = new Compiler($env); $this->assertEquals( sprintf( 'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");', $this->getVariableGetterWithoutStrictCheck('var'), $this->getVariableGetterWithStrictCheck('foo') ), trim($compiler->compile($node)->getSource()) ); } protected function getVariableGetterWithoutStrictCheck($name) { if (\PHP_VERSION_ID >= 70000) { return sprintf('($context["%s"] ?? null)', $name); } return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name); } protected function getVariableGetterWithStrictCheck($name) { if (Environment::VERSION_ID > 20404) { return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name); } if (Environment::MAJOR_VERSION >= 2) { return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->getSourceContext()); })())', $name); } if (\PHP_VERSION_ID >= 70000) { return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name); } return sprintf('(isset($context["%s"]) ? $context["%1$s"] : $this->getContext($context, "%1$s"))', $name); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/NodeVisitor/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023140�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/NodeVisitor/ScopeTest.php�������������������������������0000664�0000000�0000000�00000001056�13247321071�0025564�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\NodeVisitor\Scope; class ScopeTest extends TestCase { public function testScopeInitiation() { $scope = new Scope(); $scope->enter(); $this->assertNull($scope->get('test')); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php�0000664�0000000�0000000�00000007014�13247321071�0033634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor; use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; use Twig\Environment; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Node; class TranslationDefaultDomainNodeVisitorTest extends TestCase { private static $message = 'message'; private static $domain = 'domain'; /** @dataProvider getDefaultDomainAssignmentTestData */ public function testDefaultDomainAssignment(Node $node) { $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag $defaultDomain = TwigNodeProvider::getTransDefaultDomainTag(self::$domain); $visitor->enterNode($defaultDomain, $env); $visitor->leaveNode($defaultDomain, $env); // visit tested node $enteredNode = $visitor->enterNode($node, $env); $leavedNode = $visitor->leaveNode($node, $env); $this->assertSame($node, $enteredNode); $this->assertSame($node, $leavedNode); // extracting tested node messages $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); $this->assertEquals(array(array(self::$message, self::$domain)), $visitor->getMessages()); } /** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(Node $node) { $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag $newModule = TwigNodeProvider::getModule('test'); $visitor->enterNode($newModule, $env); $visitor->leaveNode($newModule, $env); // visit tested node $enteredNode = $visitor->enterNode($node, $env); $leavedNode = $visitor->leaveNode($node, $env); $this->assertSame($node, $enteredNode); $this->assertSame($node, $leavedNode); // extracting tested node messages $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); $this->assertEquals(array(array(self::$message, null)), $visitor->getMessages()); } public function getDefaultDomainAssignmentTestData() { return array( array(TwigNodeProvider::getTransFilter(self::$message)), array(TwigNodeProvider::getTransChoiceFilter(self::$message)), array(TwigNodeProvider::getTransTag(self::$message)), // with named arguments array(TwigNodeProvider::getTransFilter(self::$message, null, array( 'arguments' => new ArrayExpression(array(), 0), ))), array(TwigNodeProvider::getTransChoiceFilter(self::$message), null, array( 'arguments' => new ArrayExpression(array(), 0), )), ); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php��������������0000664�0000000�0000000�00000004657�13247321071�0031211�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; use Twig\Environment; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\Node; class TranslationNodeVisitorTest extends TestCase { /** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(Node $node, array $expectedMessages) { $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); $this->assertEquals($expectedMessages, $visitor->getMessages()); } public function testMessageExtractionWithInvalidDomainNode() { $message = 'new key'; $node = new FilterExpression( new ConstantExpression($message, 0), new ConstantExpression('trans', 0), new Node(array( new ArrayExpression(array(), 0), new NameExpression('variable', 0), )), 0 ); $this->testMessagesExtraction($node, array(array($message, TranslationNodeVisitor::UNDEFINED_DOMAIN))); } public function getMessagesExtractionTestData() { $message = 'new key'; $domain = 'domain'; return array( array(TwigNodeProvider::getTransFilter($message), array(array($message, null))), array(TwigNodeProvider::getTransChoiceFilter($message), array(array($message, null))), array(TwigNodeProvider::getTransTag($message), array(array($message, null))), array(TwigNodeProvider::getTransFilter($message, $domain), array(array($message, $domain))), array(TwigNodeProvider::getTransChoiceFilter($message, $domain), array(array($message, $domain))), array(TwigNodeProvider::getTransTag($message, $domain), array(array($message, $domain))), ); } } ���������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php������������������������0000664�0000000�0000000�00000004626�13247321071�0027114�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Node\BodyNode; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; use Twig\Node\ModuleNode; use Twig\Node\Node; use Twig\Source; class TwigNodeProvider { public static function getModule($content) { return new ModuleNode( new ConstantExpression($content, 0), null, new ArrayExpression(array(), 0), new ArrayExpression(array(), 0), new ArrayExpression(array(), 0), null, new Source('', '') ); } public static function getTransFilter($message, $domain = null, $arguments = null) { if (!$arguments) { $arguments = $domain ? array( new ArrayExpression(array(), 0), new ConstantExpression($domain, 0), ) : array(); } return new FilterExpression( new ConstantExpression($message, 0), new ConstantExpression('trans', 0), new Node($arguments), 0 ); } public static function getTransChoiceFilter($message, $domain = null, $arguments = null) { if (!$arguments) { $arguments = $domain ? array( new ConstantExpression(0, 0), new ArrayExpression(array(), 0), new ConstantExpression($domain, 0), ) : array(); } return new FilterExpression( new ConstantExpression($message, 0), new ConstantExpression('transchoice', 0), new Node($arguments), 0 ); } public static function getTransTag($message, $domain = null) { return new TransNode( new BodyNode(array(), array('data' => $message)), $domain ? new ConstantExpression($domain, 0) : null ); } public static function getTransDefaultDomainTag($domain) { return new TransDefaultDomainNode( new ConstantExpression($domain, 0) ); } } ����������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/TokenParser/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023130�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php����������������0000664�0000000�0000000�00000010070�13247321071�0030543�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\TokenParser; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; use Symfony\Bridge\Twig\Node\FormThemeNode; use Twig\Environment; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\NameExpression; use Twig\Parser; use Twig\Source; class FormThemeTokenParserTest extends TestCase { /** * @dataProvider getTestsForFormTheme */ public function testCompile($source, $expected) { $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $env->addTokenParser(new FormThemeTokenParser()); $stream = $env->tokenize(new Source($source, '')); $parser = new Parser($env); $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); } public function getTestsForFormTheme() { return array( array( '{% form_theme form "tpl1" %}', new FormThemeNode( new NameExpression('form', 1), new ArrayExpression(array( new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), ), 1), 1, 'form_theme' ), ), array( '{% form_theme form "tpl1" "tpl2" %}', new FormThemeNode( new NameExpression('form', 1), new ArrayExpression(array( new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), ), 1), 1, 'form_theme' ), ), array( '{% form_theme form with "tpl1" %}', new FormThemeNode( new NameExpression('form', 1), new ConstantExpression('tpl1', 1), 1, 'form_theme' ), ), array( '{% form_theme form with ["tpl1"] %}', new FormThemeNode( new NameExpression('form', 1), new ArrayExpression(array( new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), ), 1), 1, 'form_theme' ), ), array( '{% form_theme form with ["tpl1", "tpl2"] %}', new FormThemeNode( new NameExpression('form', 1), new ArrayExpression(array( new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), ), 1), 1, 'form_theme' ), ), array( '{% form_theme form with ["tpl1", "tpl2"] only %}', new FormThemeNode( new NameExpression('form', 1), new ArrayExpression(array( new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), ), 1), 1, 'form_theme', true ), ), ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Translation/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023171�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php�����������������������0000664�0000000�0000000�00000014153�13247321071�0027354�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests\Translation; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Translation\TwigExtractor; use Symfony\Component\Translation\MessageCatalogue; use Twig\Environment; use Twig\Error\Error; use Twig\Loader\ArrayLoader; class TwigExtractorTest extends TestCase { /** * @dataProvider getExtractData */ public function testExtract($template, $messages) { $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); $twig = new Environment($loader, array( 'strict_variables' => true, 'debug' => true, 'cache' => false, 'autoescape' => false, )); $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())); $extractor = new TwigExtractor($twig); $extractor->setPrefix('prefix'); $catalogue = new MessageCatalogue('en'); $m = new \ReflectionMethod($extractor, 'extractTemplate'); $m->setAccessible(true); $m->invoke($extractor, $template, $catalogue); foreach ($messages as $key => $domain) { $this->assertTrue($catalogue->has($key, $domain)); $this->assertEquals('prefix'.$key, $catalogue->get($key, $domain)); } } public function getExtractData() { return array( array('{{ "new key" | trans() }}', array('new key' => 'messages')), array('{{ "new key" | trans() | upper }}', array('new key' => 'messages')), array('{{ "new key" | trans({}, "domain") }}', array('new key' => 'domain')), array('{{ "new key" | transchoice(1) }}', array('new key' => 'messages')), array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')), array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')), array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')), array('{% trans %} new key {% endtrans %}', array('new key' => 'messages')), array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')), array('{% set foo = "new key" | trans %}', array('new key' => 'messages')), array('{{ 1 ? "new key" | trans : "another key" | trans }}', array('new key' => 'messages', 'another key' => 'messages')), // make sure 'trans_default_domain' tag is supported array('{% trans_default_domain "domain" %}{{ "new key"|trans }}', array('new key' => 'domain')), array('{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', array('new key' => 'domain')), array('{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', array('new key' => 'domain')), // make sure this works with twig's named arguments array('{{ "new key" | trans(domain="domain") }}', array('new key' => 'domain')), array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')), ); } /** * @expectedException \Twig\Error\Error * @dataProvider resourcesWithSyntaxErrorsProvider */ public function testExtractSyntaxError($resources) { $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())); $extractor = new TwigExtractor($twig); try { $extractor->extract($resources, new MessageCatalogue('en')); } catch (Error $e) { if (method_exists($e, 'getSourceContext')) { $this->assertSame(dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', DIRECTORY_SEPARATOR), $e->getFile()); $this->assertSame(1, $e->getLine()); $this->assertSame('Unclosed "block".', $e->getMessage()); } else { $this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/'); } throw $e; } } /** * @return array */ public function resourcesWithSyntaxErrorsProvider() { return array( array(__DIR__.'/../Fixtures'), array(__DIR__.'/../Fixtures/extractor/syntax_error.twig'), array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')), ); } /** * @dataProvider resourceProvider */ public function testExtractWithFiles($resource) { $loader = new ArrayLoader(array()); $twig = new Environment($loader, array( 'strict_variables' => true, 'debug' => true, 'cache' => false, 'autoescape' => false, )); $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())); $extractor = new TwigExtractor($twig); $catalogue = new MessageCatalogue('en'); $extractor->extract($resource, $catalogue); $this->assertTrue($catalogue->has('Hi!', 'messages')); $this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages')); } /** * @return array */ public function resourceProvider() { $directory = __DIR__.'/../Fixtures/extractor/'; return array( array($directory.'with_translations.html.twig'), array(array($directory.'with_translations.html.twig')), array(array(new \SplFileInfo($directory.'with_translations.html.twig'))), array(new \ArrayObject(array($directory.'with_translations.html.twig'))), array(new \ArrayObject(array(new \SplFileInfo($directory.'with_translations.html.twig')))), ); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php��������������������������������������0000664�0000000�0000000�00000004203�13247321071�0024303�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\TwigEngine; use Symfony\Component\Templating\TemplateReference; use Twig\Environment; use Twig\Loader\ArrayLoader; class TwigEngineTest extends TestCase { public function testExistsWithTemplateInstances() { $engine = $this->getTwig(); $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', array(), '', false))); } public function testExistsWithNonExistentTemplates() { $engine = $this->getTwig(); $this->assertFalse($engine->exists('foobar')); $this->assertFalse($engine->exists(new TemplateReference('foorbar'))); } public function testExistsWithTemplateWithSyntaxErrors() { $engine = $this->getTwig(); $this->assertTrue($engine->exists('error')); $this->assertTrue($engine->exists(new TemplateReference('error'))); } public function testExists() { $engine = $this->getTwig(); $this->assertTrue($engine->exists('index')); $this->assertTrue($engine->exists(new TemplateReference('index'))); } public function testRender() { $engine = $this->getTwig(); $this->assertSame('foo', $engine->render('index')); $this->assertSame('foo', $engine->render(new TemplateReference('index'))); } /** * @expectedException \Twig\Error\SyntaxError */ public function testRenderWithError() { $engine = $this->getTwig(); $engine->render(new TemplateReference('error')); } protected function getTwig() { $twig = new Environment(new ArrayLoader(array( 'index' => 'foo', 'error' => '{{ foo }', ))); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); return new TwigEngine($twig, $parser); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/��������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022026�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php�������������������������������0000664�0000000�0000000�00000002256�13247321071�0025627�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\DumpNode; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; /** * Token Parser for the 'dump' tag. * * Dump variables with: * <pre> * {% dump %} * {% dump foo %} * {% dump foo, bar %} * </pre> * * @author Julien Galenski <julien.galenski@gmail.com> */ class DumpTokenParser extends AbstractTokenParser { /** * {@inheritdoc} */ public function parse(Token $token) { $values = null; if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) { $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); } $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); return new DumpNode($this->parser->getVarName(), $values, $token->getLine(), $this->getTag()); } /** * {@inheritdoc} */ public function getTag() { return 'dump'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php��������������������������0000664�0000000�0000000�00000003517�13247321071�0026611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\FormThemeNode; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Node; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; /** * Token Parser for the 'form_theme' tag. * * @author Fabien Potencier <fabien@symfony.com> */ class FormThemeTokenParser extends AbstractTokenParser { /** * Parses a token and returns a node. * * @return Node */ public function parse(Token $token) { $lineno = $token->getLine(); $stream = $this->parser->getStream(); $form = $this->parser->getExpressionParser()->parseExpression(); $only = false; if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) { $this->parser->getStream()->next(); $resources = $this->parser->getExpressionParser()->parseExpression(); if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) { $only = true; } } else { $resources = new ArrayExpression(array(), $stream->getCurrent()->getLine()); do { $resources->addElement($this->parser->getExpressionParser()->parseExpression()); } while (!$stream->test(Token::BLOCK_END_TYPE)); } $stream->expect(Token::BLOCK_END_TYPE); return new FormThemeNode($form, $resources, $lineno, $this->getTag(), $only); } /** * Gets the tag name associated with this token parser. * * @return string The tag name */ public function getTag() { return 'form_theme'; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php��������������������������0000664�0000000�0000000�00000003113�13247321071�0026667�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\StopwatchNode; use Twig\Node\Expression\AssignNameExpression; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; /** * Token Parser for the stopwatch tag. * * @author Wouter J <wouter@wouterj.nl> */ class StopwatchTokenParser extends AbstractTokenParser { protected $stopwatchIsAvailable; public function __construct($stopwatchIsAvailable) { $this->stopwatchIsAvailable = $stopwatchIsAvailable; } public function parse(Token $token) { $lineno = $token->getLine(); $stream = $this->parser->getStream(); // {% stopwatch 'bar' %} $name = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(Token::BLOCK_END_TYPE); // {% endstopwatch %} $body = $this->parser->subparse(array($this, 'decideStopwatchEnd'), true); $stream->expect(Token::BLOCK_END_TYPE); if ($this->stopwatchIsAvailable) { return new StopwatchNode($name, $body, new AssignNameExpression($this->parser->getVarName(), $token->getLine()), $lineno, $this->getTag()); } return $body; } public function decideStopwatchEnd(Token $token) { return $token->test('endstopwatch'); } public function getTag() { return 'stopwatch'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php������������������������0000664�0000000�0000000�00000004774�13247321071�0027133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Error\SyntaxError; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Node; use Twig\Node\TextNode; use Twig\Token; /** * Token Parser for the 'transchoice' tag. * * @author Fabien Potencier <fabien@symfony.com> */ class TransChoiceTokenParser extends TransTokenParser { /** * Parses a token and returns a node. * * @return Node * * @throws SyntaxError */ public function parse(Token $token) { $lineno = $token->getLine(); $stream = $this->parser->getStream(); $vars = new ArrayExpression(array(), $lineno); $count = $this->parser->getExpressionParser()->parseExpression(); $domain = null; $locale = null; if ($stream->test('with')) { // {% transchoice count with vars %} $stream->next(); $vars = $this->parser->getExpressionParser()->parseExpression(); } if ($stream->test('from')) { // {% transchoice count from "messages" %} $stream->next(); $domain = $this->parser->getExpressionParser()->parseExpression(); } if ($stream->test('into')) { // {% transchoice count into "fr" %} $stream->next(); $locale = $this->parser->getExpressionParser()->parseExpression(); } $stream->expect(Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true); if (!$body instanceof TextNode && !$body instanceof AbstractExpression) { throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName()); } $stream->expect(Token::BLOCK_END_TYPE); return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag()); } public function decideTransChoiceFork($token) { return $token->test(array('endtranschoice')); } /** * Gets the tag name associated with this token parser. * * @return string The tag name */ public function getTag() { return 'transchoice'; } } ����symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php�����������������0000664�0000000�0000000�00000002206�13247321071�0030441�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; use Twig\Node\Node; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; /** * Token Parser for the 'trans_default_domain' tag. * * @author Fabien Potencier <fabien@symfony.com> */ class TransDefaultDomainTokenParser extends AbstractTokenParser { /** * Parses a token and returns a node. * * @return Node */ public function parse(Token $token) { $expr = $this->parser->getExpressionParser()->parseExpression(); $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag()); } /** * Gets the tag name associated with this token parser. * * @return string The tag name */ public function getTag() { return 'trans_default_domain'; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php������������������������������0000664�0000000�0000000�00000005463�13247321071�0026014�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Error\SyntaxError; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Node; use Twig\Node\TextNode; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; /** * Token Parser for the 'trans' tag. * * @author Fabien Potencier <fabien@symfony.com> */ class TransTokenParser extends AbstractTokenParser { /** * Parses a token and returns a node. * * @return Node * * @throws SyntaxError */ public function parse(Token $token) { $lineno = $token->getLine(); $stream = $this->parser->getStream(); $vars = new ArrayExpression(array(), $lineno); $domain = null; $locale = null; if (!$stream->test(Token::BLOCK_END_TYPE)) { if ($stream->test('with')) { // {% trans with vars %} $stream->next(); $vars = $this->parser->getExpressionParser()->parseExpression(); } if ($stream->test('from')) { // {% trans from "messages" %} $stream->next(); $domain = $this->parser->getExpressionParser()->parseExpression(); } if ($stream->test('into')) { // {% trans into "fr" %} $stream->next(); $locale = $this->parser->getExpressionParser()->parseExpression(); } elseif (!$stream->test(Token::BLOCK_END_TYPE)) { throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName()); } } // {% trans %}message{% endtrans %} $stream->expect(Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideTransFork'), true); if (!$body instanceof TextNode && !$body instanceof AbstractExpression) { throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName()); } $stream->expect(Token::BLOCK_END_TYPE); return new TransNode($body, $domain, null, $vars, $locale, $lineno, $this->getTag()); } public function decideTransFork($token) { return $token->test(array('endtrans')); } /** * Gets the tag name associated with this token parser. * * @return string The tag name */ public function getTag() { return 'trans'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Translation/��������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022067�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php���������������������������������0000664�0000000�0000000�00000006226�13247321071�0025414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig\Translation; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\Translation\Extractor\AbstractFileExtractor; use Symfony\Component\Translation\Extractor\ExtractorInterface; use Symfony\Component\Translation\MessageCatalogue; use Twig\Environment; use Twig\Error\Error; use Twig\Source; /** * TwigExtractor extracts translation messages from a twig template. * * @author Michel Salib <michelsalib@hotmail.com> * @author Fabien Potencier <fabien@symfony.com> */ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface { /** * Default domain for found messages. * * @var string */ private $defaultDomain = 'messages'; /** * Prefix for found message. * * @var string */ private $prefix = ''; private $twig; public function __construct(Environment $twig) { $this->twig = $twig; } /** * {@inheritdoc} */ public function extract($resource, MessageCatalogue $catalogue) { $files = $this->extractFiles($resource); foreach ($files as $file) { try { $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue); } catch (Error $e) { if ($file instanceof \SplFileInfo) { $path = $file->getRealPath() ?: $file->getPathname(); $name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path; if (method_exists($e, 'setSourceContext')) { $e->setSourceContext(new Source('', $name, $path)); } else { $e->setTemplateName($name); } } throw $e; } } } /** * {@inheritdoc} */ public function setPrefix($prefix) { $this->prefix = $prefix; } protected function extractTemplate($template, MessageCatalogue $catalogue) { $visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor(); $visitor->enable(); $this->twig->parse($this->twig->tokenize(new Source($template, ''))); foreach ($visitor->getMessages() as $message) { $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain); } $visitor->disable(); } /** * @param string $file * * @return bool */ protected function canBeExtracted($file) { return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION); } /** * @param string|array $directory * * @return array */ protected function extractFromDirectory($directory) { $finder = new Finder(); return $finder->files()->name('*.twig')->in($directory); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/TwigEngine.php������������������������������������������������0000664�0000000�0000000�00000006646�13247321071�0022356�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig; use Symfony\Component\Templating\EngineInterface; use Symfony\Component\Templating\StreamingEngineInterface; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; use Twig\Environment; use Twig\Error\Error; use Twig\Error\LoaderError; use Twig\Loader\ExistsLoaderInterface; use Twig\Template; /** * This engine knows how to render Twig templates. * * @author Fabien Potencier <fabien@symfony.com> */ class TwigEngine implements EngineInterface, StreamingEngineInterface { protected $environment; protected $parser; public function __construct(Environment $environment, TemplateNameParserInterface $parser) { $this->environment = $environment; $this->parser = $parser; } /** * {@inheritdoc} * * It also supports Template as name parameter. * * @throws Error if something went wrong like a thrown exception while rendering the template */ public function render($name, array $parameters = array()) { return $this->load($name)->render($parameters); } /** * {@inheritdoc} * * It also supports Template as name parameter. * * @throws Error if something went wrong like a thrown exception while rendering the template */ public function stream($name, array $parameters = array()) { $this->load($name)->display($parameters); } /** * {@inheritdoc} * * It also supports Template as name parameter. */ public function exists($name) { if ($name instanceof Template) { return true; } $loader = $this->environment->getLoader(); if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) { return $loader->exists((string) $name); } try { // cast possible TemplateReferenceInterface to string because the // EngineInterface supports them but LoaderInterface does not $loader->getSourceContext((string) $name)->getCode(); } catch (LoaderError $e) { return false; } return true; } /** * {@inheritdoc} * * It also supports Template as name parameter. */ public function supports($name) { if ($name instanceof Template) { return true; } $template = $this->parser->parse($name); return 'twig' === $template->get('engine'); } /** * Loads the given template. * * @param string|TemplateReferenceInterface|Template $name A template name or an instance of * TemplateReferenceInterface or Template * * @return Template * * @throws \InvalidArgumentException if the template does not exist */ protected function load($name) { if ($name instanceof Template) { return $name; } try { return $this->environment->loadTemplate((string) $name); } catch (LoaderError $e) { throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } } } ������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php����������������������������������0000664�0000000�0000000�00000004464�13247321071�0025131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Twig; use Twig\Error\SyntaxError; /** * @internal */ class UndefinedCallableHandler { private static $filterComponents = array( 'humanize' => 'form', 'trans' => 'translation', 'transchoice' => 'translation', 'yaml_encode' => 'yaml', 'yaml_dump' => 'yaml', ); private static $functionComponents = array( 'asset' => 'asset', 'asset_version' => 'asset', 'dump' => 'debug-bundle', 'expression' => 'expression-language', 'form_widget' => 'form', 'form_errors' => 'form', 'form_label' => 'form', 'form_row' => 'form', 'form_rest' => 'form', 'form' => 'form', 'form_start' => 'form', 'form_end' => 'form', 'csrf_token' => 'form', 'logout_url' => 'security-http', 'logout_path' => 'security-http', 'is_granted' => 'security-core', 'link' => 'web-link', 'preload' => 'web-link', 'dns_prefetch' => 'web-link', 'preconnect' => 'web-link', 'prefetch' => 'web-link', 'prerender' => 'web-link', 'workflow_can' => 'workflow', 'workflow_transitions' => 'workflow', 'workflow_has_marked_place' => 'workflow', 'workflow_marked_places' => 'workflow', ); public static function onUndefinedFilter($name) { if (!isset(self::$filterComponents[$name])) { return false; } // Twig will append the source context to the message, so that it will end up being like "[...] Unknown filter "%s" in foo.html.twig on line 123." throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown filter "%s".', self::$filterComponents[$name], $name)); } public static function onUndefinedFunction($name) { if (!isset(self::$functionComponents[$name])) { return false; } throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown function "%s".', self::$functionComponents[$name], $name)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/composer.json�������������������������������������������������0000664�0000000�0000000�00000005076�13247321071�0022323�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "symfony/twig-bridge", "type": "symfony-bridge", "description": "Symfony Twig Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "twig/twig": "^1.35|^2.4.4" }, "require-dev": { "symfony/asset": "~2.8|~3.0|~4.0", "symfony/dependency-injection": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/form": "^3.4.5|^4.0.5", "symfony/http-foundation": "^3.3.11|~4.0", "symfony/http-kernel": "~3.2|~4.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "~2.8|~3.0|~4.0", "symfony/templating": "~2.8|~3.0|~4.0", "symfony/translation": "~2.8|~3.0|~4.0", "symfony/yaml": "~2.8|~3.0|~4.0", "symfony/security": "~2.8|~3.0|~4.0", "symfony/security-acl": "~2.8|~3.0", "symfony/stopwatch": "~2.8|~3.0|~4.0", "symfony/console": "~3.4|~4.0", "symfony/var-dumper": "~2.8.10|~3.1.4|~3.2|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/web-link": "~3.3|~4.0", "symfony/workflow": "~3.3|~4.0" }, "conflict": { "symfony/form": "<3.4.5|<4.0.5,>=4.0", "symfony/console": "<3.4" }, "suggest": { "symfony/finder": "", "symfony/asset": "For using the AssetExtension", "symfony/form": "For using the FormExtension", "symfony/http-kernel": "For using the HttpKernelExtension", "symfony/routing": "For using the RoutingExtension", "symfony/templating": "For using the TwigEngine", "symfony/translation": "For using the TranslationExtension", "symfony/yaml": "For using the YamlExtension", "symfony/security": "For using the SecurityExtension", "symfony/stopwatch": "For using the StopwatchExtension", "symfony/var-dumper": "For using the DumpExtension", "symfony/expression-language": "For using the ExpressionExtension", "symfony/web-link": "For using the WebLinkExtension" }, "autoload": { "psr-4": { "Symfony\\Bridge\\Twig\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bridge/Twig/phpunit.xml.dist����������������������������������������������0000664�0000000�0000000�00000001557�13247321071�0022754�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" > <php> <ini name="error_reporting" value="-1" /> </php> <testsuites> <testsuite name="Symfony Twig Bridge Test Suite"> <directory>./Tests/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./</directory> <exclude> <directory>./Resources</directory> <directory>./Tests</directory> <directory>./vendor</directory> </exclude> </whitelist> </filter> </phpunit> �������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0016674�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/�������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021054�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/.gitignore���������������������������������������������0000664�0000000�0000000�00000000042�13247321071�0023040�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������vendor/ composer.lock phpunit.xml ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DebugBundle.php����������������������������������������0000664�0000000�0000000�00000003416�13247321071�0023751�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle; use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\VarDumper\VarDumper; /** * @author Nicolas Grekas <p@tchwork.com> */ class DebugBundle extends Bundle { public function boot() { if ($this->container->getParameter('kernel.debug')) { $container = $this->container; // This code is here to lazy load the dump stack. This default // configuration is overridden in CLI mode on 'console.command' event. // The dump data collector is used by default, so dump output is sent to // the WDT. In a CLI context, if dump is used too soon, the data collector // will buffer it, and release it at the end of the script. VarDumper::setHandler(function ($var) use ($container) { $dumper = $container->get('data_collector.dump'); $cloner = $container->get('var_dumper.cloner'); $handler = function ($var) use ($dumper, $cloner) { $dumper->dump($cloner->cloneVar($var)); }; VarDumper::setHandler($handler); $handler($var); }); } } /** * {@inheritdoc} */ public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new DumpDataCollectorPass()); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DependencyInjection/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0024775�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DependencyInjection/Compiler/��������������������������0000775�0000000�0000000�00000000000�13247321071�0026547�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DependencyInjection/Compiler/DumpDataCollectorPass.php�0000664�0000000�0000000�00000002402�13247321071�0033453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle\DependencyInjection\Compiler; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Registers the file link format for the {@link \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector}. * * @author Christian Flothmann <christian.flothmann@xabbuh.de> */ class DumpDataCollectorPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('data_collector.dump')) { return; } $definition = $container->getDefinition('data_collector.dump'); if (!$container->hasParameter('web_profiler.debug_toolbar.mode') || WebDebugToolbarListener::DISABLED === $container->getParameter('web_profiler.debug_toolbar.mode')) { $definition->replaceArgument(3, null); } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php������������������0000664�0000000�0000000�00000003362�13247321071�0030321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; /** * DebugExtension configuration structure. * * @author Nicolas Grekas <p@tchwork.com> */ class Configuration implements ConfigurationInterface { /** * {@inheritdoc} */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('debug'); $rootNode ->children() ->integerNode('max_items') ->info('Max number of displayed items past the first level, -1 means no limit') ->min(-1) ->defaultValue(2500) ->end() ->integerNode('min_depth') ->info('Minimum tree depth to clone all the items, 1 is default') ->min(0) ->defaultValue(1) ->end() ->integerNode('max_string_length') ->info('Max length of displayed strings, -1 means no limit') ->min(-1) ->defaultValue(-1) ->end() ->scalarNode('dump_destination') ->info('A stream URL where dumps should be written to') ->example('php://stderr') ->defaultNull() ->end() ->end() ; return $treeBuilder; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php�����������������0000664�0000000�0000000�00000004154�13247321071�0030435�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; /** * DebugExtension. * * @author Nicolas Grekas <p@tchwork.com> */ class DebugExtension extends Extension { /** * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); $container->getDefinition('debug.dump_listener')->setPrivate(true); $container->getDefinition('var_dumper.cli_dumper')->setPrivate(true); $container->getDefinition('var_dumper.cloner') ->addMethodCall('setMaxItems', array($config['max_items'])) ->addMethodCall('setMinDepth', array($config['min_depth'])) ->addMethodCall('setMaxString', array($config['max_string_length'])); if (null !== $config['dump_destination']) { $container->getDefinition('var_dumper.cli_dumper') ->replaceArgument(0, $config['dump_destination']) ; $container->getDefinition('data_collector.dump') ->replaceArgument(4, new Reference('var_dumper.cli_dumper')) ; } } /** * {@inheritdoc} */ public function getXsdValidationBasePath() { return __DIR__.'/../Resources/config/schema'; } /** * {@inheritdoc} */ public function getNamespace() { return 'http://symfony.com/schema/dic/debug'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/LICENSE������������������������������������������������0000664�0000000�0000000�00000002051�13247321071�0022057�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2014-2018 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/���������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023026�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/config/��������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024273�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/config/schema/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025533�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/config/schema/debug-1.0.xsd������������������0000664�0000000�0000000�00000001160�13247321071�0027633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns="http://symfony.com/schema/dic/debug" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://symfony.com/schema/dic/debug" elementFormDefault="qualified"> <xsd:element name="config" type="config" /> <xsd:complexType name="config"> <xsd:attribute name="max-items" type="xsd:integer" /> <xsd:attribute name="min-depth" type="xsd:integer" /> <xsd:attribute name="max-string-length" type="xsd:integer" /> <xsd:attribute name="dump-destination" type="xsd:string" /> </xsd:complexType> </xsd:schema> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/config/services.xml��������������������������0000664�0000000�0000000�00000004714�13247321071�0026646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="twig.extension.dump" class="Symfony\Bridge\Twig\Extension\DumpExtension"> <tag name="twig.extension" /> <argument type="service" id="var_dumper.cloner" /> <argument type="service" id="var_dumper.html_dumper" /> </service> <service id="data_collector.dump" class="Symfony\Component\HttpKernel\DataCollector\DumpDataCollector" public="true"> <tag name="data_collector" id="dump" template="@Debug/Profiler/dump.html.twig" priority="240" /> <argument type="service" id="debug.stopwatch" on-invalid="ignore" /> <argument type="service" id="debug.file_link_formatter" on-invalid="ignore"></argument> <argument>%kernel.charset%</argument> <argument type="service" id="request_stack" /> <argument>null</argument><!-- var_dumper.cli_dumper when debug.dump_destination is set --> </service> <service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="var_dumper.cloner" /> <argument type="service" id="var_dumper.cli_dumper" /> </service> <service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" public="true" /> <service id="var_dumper.cli_dumper" class="Symfony\Component\VarDumper\Dumper\CliDumper"> <argument>null</argument><!-- debug.dump_destination --> <argument>%kernel.charset%</argument> <argument>0</argument> <!-- flags --> </service> <service id="var_dumper.html_dumper" class="Symfony\Component\VarDumper\Dumper\HtmlDumper"> <argument>null</argument> <argument>%kernel.charset%</argument> <argument>0</argument> <!-- flags --> <call method="setDisplayOptions"> <argument type="collection"> <argument key="fileLinkFormat" type="service" id="debug.file_link_formatter" on-invalid="ignore"></argument> </argument> </call> </service> </services> </container> ����������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/views/���������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024163�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/������������������������������0000775�0000000�0000000�00000000000�13247321071�0025745�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/dump.html.twig����������������0000664�0000000�0000000�00000005244�13247321071�0030556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% if collector.dumpsCount %} {% set icon %} {{ include('@Debug/Profiler/icon.svg') }} <span class="sf-toolbar-value">{{ collector.dumpsCount }}</span> {% endset %} {% set text %} {% for dump in collector.getDumps('html') %} <div class="sf-toolbar-info-piece"> <span> {% if dump.file %} {% set link = dump.file|file_link(dump.line) %} {% if link %} <a href="{{ link }}" title="{{ dump.file }}">{{ dump.name }}</a> {% else %} <abbr title="{{ dump.file }}">{{ dump.name }}</abbr> {% endif %} {% else %} {{ dump.name }} {% endif %} </span> <span class="sf-toolbar-file-line">line {{ dump.line }}</span> {{ dump.data|raw }} </div> {% endfor %} {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': true }) }} {% endif %} {% endblock %} {% block menu %} <span class="label {{ collector.dumpsCount == 0 ? 'disabled' }}"> <span class="icon">{{ include('@Debug/Profiler/icon.svg') }}</span> <strong>Debug</strong> </span> {% endblock %} {% block panel %} <h2>Dumped Contents</h2> {% for dump in collector.getDumps('html') %} <div class="sf-dump sf-reset"> <span class="metadata">In {% if dump.line %} {% set link = dump.file|file_link(dump.line) %} {% if link %} <a href="{{ link }}" title="{{ dump.file }}">{{ dump.name }}</a> {% else %} <abbr title="{{ dump.file }}">{{ dump.name }}</abbr> {% endif %} {% else %} {{ dump.name }} {% endif %} line <a class="text-small sf-toggle" data-toggle-selector="#sf-trace-{{ loop.index0 }}">{{ dump.line }}</a>: </span> <div class="sf-dump-compact hidden" id="sf-trace-{{ loop.index0 }}"> <div class="trace"> {{ dump.fileExcerpt ? dump.fileExcerpt|raw : dump.file|file_excerpt(dump.line) }} </div> </div> {{ dump.data|raw }} </div> {% else %} <div class="empty"> <p>No content was dumped.</p> </div> {% endfor %} {% endblock %} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/icon.svg����������������������0000664�0000000�0000000�00000001510�13247321071�0027413�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> <path fill="#AAAAAA" d="M12,22.6c-5.8,0-10.5-4.7-10.5-10.5C1.5,6.3,6.2,1.5,12,1.5s10.5,4.7,10.5,10.5C22.5,17.9,17.8,22.6,12,22.6z M12,4.5c-4.2,0-7.5,3.4-7.5,7.5c0,4.2,3.4,7.5,7.5,7.5s7.5-3.4,7.5-7.5C19.5,7.9,16.2,4.5,12,4.5z"/> <path fill="#AAAAAA" d="M12,9.1c-0.8,0-1.5-0.7-1.5-1.5v-6c0-0.8,0.7-1.5,1.5-1.5s1.5,0.7,1.5,1.5v6C13.5,8.4,12.8,9.1,12,9.1zM13.5,22.4v-6c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5v6c0,0.8,0.7,1.5,1.5,1.5S13.5,23.2,13.5,22.4z M23.9,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C23.2,13.5,23.9,12.8,23.9,12z M9.1,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C8.4,13.5,9.1,12.8,9.1,12z"/> </svg> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Tests/�������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022156�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/�����������������������������0000775�0000000�0000000�00000000000�13247321071�0026077�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/��������������������0000775�0000000�0000000�00000000000�13247321071�0027651�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������DumpDataCollectorPassTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000005541�13247321071�0035345�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler����������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpFoundation\RequestStack; class DumpDataCollectorPassTest extends TestCase { public function testProcessWithoutFileLinkFormatParameter() { $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, null)); $container->setDefinition('data_collector.dump', $definition); $container->compile(); $this->assertNull($definition->getArgument(1)); } public function testProcessWithToolbarEnabled() { $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); $requestStack = new RequestStack(); $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, $requestStack)); $container->setDefinition('data_collector.dump', $definition); $container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::ENABLED); $container->compile(); $this->assertSame($requestStack, $definition->getArgument(3)); } public function testProcessWithToolbarDisabled() { $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, new RequestStack())); $container->setDefinition('data_collector.dump', $definition); $container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::DISABLED); $container->compile(); $this->assertNull($definition->getArgument(3)); } public function testProcessWithoutToolbar() { $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, new RequestStack())); $container->setDefinition('data_collector.dump', $definition); $container->compile(); $this->assertNull($definition->getArgument(3)); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php�������0000664�0000000�0000000�00000003433�13247321071�0032376�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\DebugBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; class DebugExtensionTest extends TestCase { public function testLoadWithoutConfiguration() { $container = $this->createContainer(); $container->registerExtension(new DebugExtension()); $container->loadFromExtension('debug', array()); $this->compileContainer($container); $expectedTags = array( array( 'id' => 'dump', 'template' => '@Debug/Profiler/dump.html.twig', 'priority' => 240, ), ); $this->assertSame($expectedTags, $container->getDefinition('data_collector.dump')->getTag('data_collector')); } private function createContainer() { $container = new ContainerBuilder(new ParameterBag(array( 'kernel.cache_dir' => __DIR__, 'kernel.charset' => 'UTF-8', 'kernel.debug' => true, 'kernel.bundles' => array('DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'), ))); return $container; } private function compileContainer(ContainerBuilder $container) { $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/composer.json������������������������������������������0000664�0000000�0000000�00000002516�13247321071�0023602�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "symfony/debug-bundle", "type": "symfony-bundle", "description": "Symfony DebugBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "ext-xml": "*", "symfony/http-kernel": "~2.8|~3.0|~4.0", "symfony/twig-bridge": "~2.8|~3.0|~4.0", "symfony/var-dumper": "~3.4|~4.0" }, "require-dev": { "symfony/config": "~3.3|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/web-profiler-bundle": "~2.8|~3.0|~4.0" }, "conflict": { "symfony/dependency-injection": "<3.4" }, "suggest": { "symfony/config": "For service container configuration", "symfony/dependency-injection": "For using as a service from the container" }, "autoload": { "psr-4": { "Symfony\\Bundle\\DebugBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/DebugBundle/phpunit.xml.dist���������������������������������������0000664�0000000�0000000�00000001557�13247321071�0024237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" > <php> <ini name="error_reporting" value="-1" /> </php> <testsuites> <testsuite name="Symfony DebugBundle Test Suite"> <directory>./Tests/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./</directory> <exclude> <directory>./Resources</directory> <directory>./Tests</directory> <directory>./vendor</directory> </exclude> </whitelist> </filter> </phpunit> �������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/���������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021763�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/.gitignore�����������������������������������������0000664�0000000�0000000�00000000042�13247321071�0023747�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������vendor/ composer.lock phpunit.xml ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md���������������������������������������0000664�0000000�0000000�00000036651�13247321071�0023607�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CHANGELOG ========= 3.4.0 ----- * Added `translator.default_path` option and parameter * Session `use_strict_mode` is now enabled by default and the corresponding option has been deprecated * Made the `cache:clear` command to *not* clear "app" PSR-6 cache pools anymore, but to still clear "system" ones; use the `cache:pool:clear` command to clear "app" pools instead * Always register a minimalist logger that writes in `stderr` * Deprecated `profiler.matcher` option * Added support for `EventSubscriberInterface` on `MicroKernelTrait` * Removed `doctrine/cache` from the list of required dependencies in `composer.json` * Deprecated `validator.mapping.cache.doctrine.apc` service * The `symfony/stopwatch` dependency has been removed, require it via `composer require symfony/stopwatch` in your `dev` environment. * Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`. * Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods. * Deprecated `AddCacheClearerPass`, use tagged iterator arguments instead. * Deprecated `AddCacheWarmerPass`, use tagged iterator arguments instead. * Deprecated `TranslationDumperPass`, use `Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` instead * Deprecated `TranslationExtractorPass`, use `Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` instead * Deprecated `TranslatorPass`, use `Symfony\Component\Translation\DependencyInjection\TranslatorPass` instead * Added `command` attribute to the `console.command` tag which takes the command name as value, using it makes the command lazy * Added `cache:pool:prune` command to allow manual stale cache item pruning of supported PSR-6 and PSR-16 cache pool implementations * Deprecated `Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader`, use `Symfony\Component\Translation\Reader\TranslationReader` instead * Deprecated `translation.loader` service, use `translation.reader` instead * `AssetsInstallCommand::__construct()` now takes an instance of `Symfony\Component\Filesystem\Filesystem` as first argument * `CacheClearCommand::__construct()` now takes an instance of `Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface` as first argument * `CachePoolClearCommand::__construct()` now takes an instance of `Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer` as first argument * `EventDispatcherDebugCommand::__construct()` now takes an instance of `Symfony\Component\EventDispatcher\EventDispatcherInterface` as first argument * `RouterDebugCommand::__construct()` now takes an instance of `Symfony\Component\Routing\RouterInterface` as first argument * `RouterMatchCommand::__construct()` now takes an instance of `Symfony\Component\Routing\RouterInterface` as first argument * `TranslationDebugCommand::__construct()` now takes an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument * `TranslationUpdateCommand::__construct()` now takes an instance of `Symfony\Component\Translation\TranslatorInterface` as first argument * `AssetsInstallCommand`, `CacheClearCommand`, `CachePoolClearCommand`, `EventDispatcherDebugCommand`, `RouterDebugCommand`, `RouterMatchCommand`, `TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand` and `YamlLintCommand` classes have been marked as final * Added `asset.request_context.base_path` and `asset.request_context.secure` parameters to provide a default request context in case the stack is empty (similar to `router.request_context.*` parameters) * Display environment variables managed by `Dotenv` in `AboutCommand` 3.3.0 ----- * Not defining the `type` option of the `framework.workflows.*` configuration entries is deprecated. The default value will be `state_machine` in Symfony 4.0. * Deprecated the `CompilerDebugDumpPass` class * Deprecated the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter * Added a new new version strategy option called json_manifest_path that allows you to use the `JsonManifestVersionStrategy`. * Added `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`. It provides the same helpers as the `Controller` class, but does not allow accessing the dependency injection container, in order to encourage explicit dependency declarations. * Added support for the `controller.service_arguments` tag, for injecting services into controllers' actions * Changed default configuration for assets/forms/validation/translation/serialization/csrf from `canBeEnabled()` to `canBeDisabled()` when Flex is used * The server:* commands and their associated router files were moved to WebServerBundle * Translation related services are not loaded anymore when the `framework.translator` option is disabled. * Added `GlobalVariables::getToken()` * Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass`. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead. * Added configurable paths for validation files * Deprecated `SerializerPass`, use `Symfony\Component\Serializer\DependencyInjection\SerializerPass` instead * Deprecated `FormPass`, use `Symfony\Component\Form\DependencyInjection\FormPass` instead * Deprecated `SessionListener` * Deprecated `TestSessionListener` * Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass`. Use tagged iterator arguments instead. * Deprecated `PropertyInfoPass`, use `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` instead * Deprecated `ControllerArgumentValueResolverPass`. Use `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` instead * Deprecated `RoutingResolverPass`, use `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` instead * [BC BREAK] The `server:run`, `server:start`, `server:stop` and `server:status` console commands have been moved to a dedicated bundle. Require `symfony/web-server-bundle` in your composer.json and register `Symfony\Bundle\WebServerBundle\WebServerBundle` in your AppKernel to use them. * Added `$defaultLocale` as 3rd argument of `Translator::__construct()` making `Translator` works with any PSR-11 container * Added `framework.serializer.mapping` config option allowing to define custom serialization mapping files and directories * Deprecated `AddValidatorInitializersPass`, use `Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass` instead * Deprecated `AddConstraintValidatorsPass`, use `Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass` instead * Deprecated `ValidateWorkflowsPass`, use `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass` instead * Deprecated `ConstraintValidatorFactory`, use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead. * Deprecated `PhpStringTokenParser`, use `Symfony\Component\Translation\Extractor\PhpStringTokenParser` instead. * Deprecated `PhpExtractor`, use `Symfony\Component\Translation\Extractor\PhpExtractor` instead. 3.2.0 ----- * Removed `doctrine/annotations` from the list of required dependencies in `composer.json` * Removed `symfony/security-core` and `symfony/security-csrf` from the list of required dependencies in `composer.json` * Removed `symfony/templating` from the list of required dependencies in `composer.json` * Removed `symfony/translation` from the list of required dependencies in `composer.json` * Removed `symfony/asset` from the list of required dependencies in `composer.json` * The `Resources/public/images/*` files have been removed. * The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle). * Added possibility to prioritize form type extensions with `'priority'` attribute on tags `form.type_extension` 3.1.0 ----- * Added `Controller::json` to simplify creating JSON responses when using the Serializer component * Deprecated absolute template paths support in the template name parser * Deprecated using core form types without dependencies as services * Added `Symfony\Component\HttpHernel\DataCollector\RequestDataCollector::onKernelResponse()` * Added `Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector` * The `framework.serializer.cache` option and the service `serializer.mapping.cache.apc` have been deprecated. APCu should now be automatically used when available. 3.0.0 ----- * removed `validator.api` parameter * removed `alias` option of the `form.type` tag 2.8.0 ----- * Deprecated the `alias` option of the `form.type_extension` tag in favor of the `extended_type`/`extended-type` option * Deprecated the `alias` option of the `form.type` tag * Deprecated the Shell 2.7.0 ----- * Added possibility to extract translation messages from a file or files besides extracting from a directory * Added `TranslationsCacheWarmer` to create catalogues at warmup 2.6.0 ----- * Added helper commands (`server:start`, `server:stop` and `server:status`) to control the built-in web server in the background * Added `Controller::isCsrfTokenValid` helper * Added configuration for the PropertyAccess component * Added `Controller::redirectToRoute` helper * Added `Controller::addFlash` helper * Added `Controller::isGranted` helper * Added `Controller::denyAccessUnlessGranted` helper * Deprecated `app.security` in twig as `app.user` and `is_granted()` are already available 2.5.0 ----- * Added `translation:debug` command * Added `--no-backup` option to `translation:update` command * Added `config:debug` command * Added `yaml:lint` command * Deprecated the `RouterApacheDumperCommand` which will be removed in Symfony 3.0. 2.4.0 ----- * allowed multiple IP addresses in profiler matcher settings * added stopwatch helper to time templates with the WebProfilerBundle * added service definition for "security.secure_random" service * added service definitions for the new Security CSRF sub-component 2.3.0 ----- * [BC BREAK] added a way to disable the profiler (when disabling the profiler, it is now completely removed) To get the same "disabled" behavior as before, set `enabled` to `true` and `collect` to `false` * [BC BREAK] the `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass` was moved to `Component\HttpKernel\DependencyInjection\RegisterListenersPass` * added ControllerNameParser::build() which converts a controller short notation (a:b:c) to a class::method notation * added possibility to run PHP built-in server in production environment * added possibility to load the serializer component in the service container * added route debug information when using the `router:match` command * added `TimedPhpEngine` * added `--clean` option to the `translation:update` command * added `http_method_override` option * added support for default templates per render tag * added FormHelper::form(), FormHelper::start() and FormHelper::end() * deprecated FormHelper::enctype() in favor of FormHelper::start() * RedirectController actions now receive the Request instance via the method signature. 2.2.0 ----- * added a new `uri_signer` service to help sign URIs * deprecated `Symfony\Bundle\FrameworkBundle\HttpKernel::render()` and `Symfony\Bundle\FrameworkBundle\HttpKernel::forward()` * deprecated the `Symfony\Bundle\FrameworkBundle\HttpKernel` class in favor of `Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel` * added support for adding new HTTP content rendering strategies (like ESI and Hinclude) in the DIC via the `kernel.fragment_renderer` tag * [BC BREAK] restricted the `Symfony\Bundle\FrameworkBundle\HttpKernel::render()` method to only accept URIs or ControllerReference instances * `Symfony\Bundle\FrameworkBundle\HttpKernel::render()` method signature changed and the first argument must now be a URI or a ControllerReference instance (the `generateInternalUri()` method was removed) * The internal routes (`Resources/config/routing/internal.xml`) have been removed and replaced with a listener (`Symfony\Component\HttpKernel\EventListener\FragmentListener`) * The `render` method of the `actions` templating helper signature and arguments changed * replaced Symfony\Bundle\FrameworkBundle\Controller\TraceableControllerResolver by Symfony\Component\HttpKernel\Controller\TraceableControllerResolver * replaced Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher by Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher * added Client::enableProfiler() * a new parameter has been added to the DIC: `router.request_context.base_url` You can customize it for your functional tests or for generating URLs with the right base URL when your are in the CLI context. * added support for default templates per render tag 2.1.0 ----- * moved the translation files to the Form and Validator components * changed the default extension for XLIFF files from .xliff to .xlf * moved Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher to Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher * moved Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher to Symfony\Component\EventDispatcher\ContainerAwareTraceableEventDispatcher * added a router:match command * added a config:dump-reference command * added a server:run command * added kernel.event_subscriber tag * added a way to create relative symlinks when running assets:install command (--relative option) * added Controller::getUser() * [BC BREAK] assets_base_urls and base_urls merging strategy has changed * changed the default profiler storage to use the filesystem instead of SQLite * added support for placeholders in route defaults and requirements (replaced by the value set in the service container) * added Filesystem component as a dependency * added support for hinclude (use ``standalone: 'js'`` in render tag) * session options: lifetime, path, domain, secure, httponly were deprecated. Prefixed versions should now be used instead: cookie_lifetime, cookie_path, cookie_domain, cookie_secure, cookie_httponly * [BC BREAK] following session options: 'lifetime', 'path', 'domain', 'secure', 'httponly' are now prefixed with cookie_ when dumped to the container * Added `handler_id` configuration under `session` key to represent `session.handler` service, defaults to `session.handler.native_file`. * Added `gc_maxlifetime`, `gc_probability`, and `gc_divisor` to session configuration. This means session garbage collection has a `gc_probability`/`gc_divisor` chance of being run. The `gc_maxlifetime` defines how long a session can idle for. It is different from cookie lifetime which declares how long a cookie can be stored on the remote client. * Removed 'auto_start' configuration parameter from session config. The session will start on demand. * [BC BREAK] TemplateNameParser::parseFromFilename() has been moved to a dedicated parser: TemplateFilenameParser::parse(). * [BC BREAK] Kernel parameters are replaced by their value wherever they appear in Route patterns, requirements and defaults. Use '%%' as the escaped value for '%'. * [BC BREAK] Switched behavior of flash messages to expire flash messages on retrieval using Symfony\Component\HttpFoundation\Session\Flash\FlashBag as opposed to on next pageload regardless of whether they are displayed or not. ���������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/���������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024144�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php���������0000664�0000000�0000000�00000005462�13247321071�0032001�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; /** * @internal */ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface { private $phpArrayFile; private $fallbackPool; /** * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ public function __construct($phpArrayFile, CacheItemPoolInterface $fallbackPool) { $this->phpArrayFile = $phpArrayFile; if (!$fallbackPool instanceof AdapterInterface) { $fallbackPool = new ProxyAdapter($fallbackPool); } $this->fallbackPool = $fallbackPool; } /** * {@inheritdoc} */ public function isOptional() { return true; } /** * {@inheritdoc} */ public function warmUp($cacheDir) { $arrayAdapter = new ArrayAdapter(); spl_autoload_register(array(PhpArrayAdapter::class, 'throwOnRequiredClass')); try { if (!$this->doWarmUp($cacheDir, $arrayAdapter)) { return; } } finally { spl_autoload_unregister(array(PhpArrayAdapter::class, 'throwOnRequiredClass')); } // the ArrayAdapter stores the values serialized // to avoid mutation of the data after it was written to the cache // so here we un-serialize the values first $values = array_map(function ($val) { return null !== $val ? unserialize($val) : null; }, $arrayAdapter->getValues()); $this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, $this->fallbackPool), $values); foreach ($values as $k => $v) { $item = $this->fallbackPool->getItem($k); $this->fallbackPool->saveDeferred($item->set($v)); } $this->fallbackPool->commit(); } protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values) { $phpArrayAdapter->warmUp($values); } /** * @param string $cacheDir * @param ArrayAdapter $arrayAdapter * * @return bool false if there is nothing to warm-up */ abstract protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php�������������0000664�0000000�0000000�00000006520�13247321071�0031257�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\DoctrineProvider; /** * Warms up annotation caches for classes found in composer's autoload class map * and declared in DI bundle extensions using the addAnnotatedClassesToCache method. * * @author Titouan Galopin <galopintitouan@gmail.com> */ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer { private $annotationReader; private $excludeRegexp; /** * @param Reader $annotationReader * @param string $phpArrayFile The PHP file where annotations are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached */ public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null) { parent::__construct($phpArrayFile, $fallbackPool); $this->annotationReader = $annotationReader; $this->excludeRegexp = $excludeRegexp; } /** * {@inheritdoc} */ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) { $annotatedClassPatterns = $cacheDir.'/annotations.map'; if (!is_file($annotatedClassPatterns)) { return true; } $annotatedClasses = include $annotatedClassPatterns; $reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter)); foreach ($annotatedClasses as $class) { if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) { continue; } try { $this->readAllComponents($reader, $class); } catch (\ReflectionException $e) { // ignore failing reflection } catch (AnnotationException $e) { /* * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly * configured or could not be found / read / etc. * * In particular cases, an Annotation in your code can be used and defined only for a specific * environment but is always added to the annotations.map file by some Symfony default behaviors, * and you always end up with a not found Annotation. */ } } return true; } private function readAllComponents(Reader $reader, $class) { $reflectionClass = new \ReflectionClass($class); $reader->getClassAnnotations($reflectionClass); foreach ($reflectionClass->getMethods() as $reflectionMethod) { $reader->getMethodAnnotations($reflectionMethod); } foreach ($reflectionClass->getProperties() as $reflectionProperty) { $reader->getPropertyAnnotations($reflectionProperty); } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ClassCacheCacheWarmer.php��������������0000664�0000000�0000000�00000003362�13247321071�0030754�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Symfony\Component\ClassLoader\ClassCollectionLoader; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; /** * Generates the Class Cache (classes.php) file. * * @author Tugdual Saunier <tucksaun@gmail.com> * * @deprecated since version 3.3, to be removed in 4.0. */ class ClassCacheCacheWarmer implements CacheWarmerInterface { private $declaredClasses; public function __construct(array $declaredClasses = null) { if (\PHP_VERSION_ID >= 70000) { @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED); } $this->declaredClasses = $declaredClasses; } /** * Warms up the cache. * * @param string $cacheDir The cache directory */ public function warmUp($cacheDir) { $classmap = $cacheDir.'/classes.map'; if (!is_file($classmap)) { return; } if (file_exists($cacheDir.'/classes.php')) { return; } $declared = null !== $this->declaredClasses ? $this->declaredClasses : array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); ClassCollectionLoader::inline(include($classmap), $cacheDir.'/classes.php', $declared); } /** * Checks whether this warmer is optional or not. * * @return bool always true */ public function isOptional() { return true; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php������������������0000664�0000000�0000000�00000004550�13247321071�0030243�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\Routing\RouterInterface; /** * Generates the router matcher and generator classes. * * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { protected $router; /** * @param ContainerInterface $container */ public function __construct($container) { // As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected. if ($container instanceof ContainerInterface) { $this->router = $container->get('router'); // For BC, the $router property must be populated in the constructor } elseif ($container instanceof RouterInterface) { $this->router = $container; @trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since Symfony 3.4 and will be unsupported in version 4.0. Use a %s instead.', RouterInterface::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED); } else { throw new \InvalidArgumentException(sprintf('%s only accepts instance of Psr\Container\ContainerInterface as first argument.', __CLASS__)); } } /** * Warms up the cache. * * @param string $cacheDir The cache directory */ public function warmUp($cacheDir) { if ($this->router instanceof WarmableInterface) { $this->router->warmUp($cacheDir); } } /** * Checks whether this warmer is optional or not. * * @return bool always true */ public function isOptional() { return true; } /** * {@inheritdoc} */ public static function getSubscribedServices() { return array( 'router' => RouterInterface::class, ); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php��������������0000664�0000000�0000000�00000006120�13247321071�0031067�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Doctrine\Common\Annotations\AnnotationException; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Loader\LoaderChain; use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; /** * Warms up XML and YAML serializer metadata. * * @author Titouan Galopin <galopintitouan@gmail.com> */ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer { private $loaders; /** * @param LoaderInterface[] $loaders The serializer metadata loaders * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterface $fallbackPool) { parent::__construct($phpArrayFile, $fallbackPool); $this->loaders = $loaders; } /** * {@inheritdoc} */ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) { if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) { return false; } $metadataFactory = new CacheClassMetadataFactory(new ClassMetadataFactory(new LoaderChain($this->loaders)), $arrayAdapter); foreach ($this->extractSupportedLoaders($this->loaders) as $loader) { foreach ($loader->getMappedClasses() as $mappedClass) { try { $metadataFactory->getMetadataFor($mappedClass); } catch (\ReflectionException $e) { // ignore failing reflection } catch (AnnotationException $e) { // ignore failing annotations } } } return true; } /** * @param LoaderInterface[] $loaders * * @return XmlFileLoader[]|YamlFileLoader[] */ private function extractSupportedLoaders(array $loaders) { $supportedLoaders = array(); foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { $supportedLoaders[] = $loader; } elseif ($loader instanceof LoaderChain) { $supportedLoaders = array_merge($supportedLoaders, $this->extractSupportedLoaders($loader->getLoaders())); } } return $supportedLoaders; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php���������������������0000664�0000000�0000000�00000006333�13247321071�0027565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Finder\Finder; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface; /** * Finds all the templates. * * @author Victor Berchet <victor@suumit.com> */ class TemplateFinder implements TemplateFinderInterface { private $kernel; private $parser; private $rootDir; private $templates; /** * @param KernelInterface $kernel A KernelInterface instance * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance * @param string $rootDir The directory where global templates can be stored */ public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, $rootDir) { $this->kernel = $kernel; $this->parser = $parser; $this->rootDir = $rootDir; } /** * Find all the templates in the bundle and in the kernel Resources folder. * * @return TemplateReferenceInterface[] */ public function findAllTemplates() { if (null !== $this->templates) { return $this->templates; } $templates = array(); foreach ($this->kernel->getBundles() as $bundle) { $templates = array_merge($templates, $this->findTemplatesInBundle($bundle)); } $templates = array_merge($templates, $this->findTemplatesInFolder($this->rootDir.'/views')); return $this->templates = $templates; } /** * Find templates in the given directory. * * @param string $dir The folder where to look for templates * * @return TemplateReferenceInterface[] */ private function findTemplatesInFolder($dir) { $templates = array(); if (is_dir($dir)) { $finder = new Finder(); foreach ($finder->files()->followLinks()->in($dir) as $file) { $template = $this->parser->parse($file->getRelativePathname()); if (false !== $template) { $templates[] = $template; } } } return $templates; } /** * Find templates in the given bundle. * * @param BundleInterface $bundle The bundle where to look for templates * * @return TemplateReferenceInterface[] */ private function findTemplatesInBundle(BundleInterface $bundle) { $name = $bundle->getName(); $templates = array_merge( $this->findTemplatesInFolder($bundle->getPath().'/Resources/views'), $this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views') ); $templates = array_unique($templates); foreach ($templates as $i => $template) { $templates[$i] = $template->set('bundle', $name); } return $templates; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php������������0000664�0000000�0000000�00000001134�13247321071�0031400�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; /** * Interface for finding all the templates. * * @author Victor Berchet <victor@suumit.com> */ interface TemplateFinderInterface { /** * Find all the templates. * * @return array An array of templates of type TemplateReferenceInterface */ public function findAllTemplates(); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php�����������0000664�0000000�0000000�00000003241�13247321071�0031532�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; /** * Computes the association between template names and their paths on the disk. * * @author Fabien Potencier <fabien@symfony.com> */ class TemplatePathsCacheWarmer extends CacheWarmer { protected $finder; protected $locator; public function __construct(TemplateFinderInterface $finder, TemplateLocator $locator) { $this->finder = $finder; $this->locator = $locator; } /** * Warms up the cache. * * @param string $cacheDir The cache directory */ public function warmUp($cacheDir) { $filesystem = new Filesystem(); $templates = array(); foreach ($this->finder->findAllTemplates() as $template) { $templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/'); } $templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true)); $this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates)); } /** * Checks whether this warmer is optional or not. * * @return bool always true */ public function isOptional() { return true; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php������������0000664�0000000�0000000�00000004530�13247321071�0031442�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\Translation\TranslatorInterface; /** * Generates the catalogues for translations. * * @author Xavier Leune <xavier.leune@gmail.com> */ class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { private $container; private $translator; /** * TranslationsCacheWarmer constructor. * * @param ContainerInterface $container */ public function __construct($container) { // As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected. if ($container instanceof ContainerInterface) { $this->container = $container; } elseif ($container instanceof TranslatorInterface) { $this->translator = $container; @trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since Symfony 3.4 and will be unsupported in version 4.0. Use a %s instead.', TranslatorInterface::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED); } else { throw new \InvalidArgumentException(sprintf('%s only accepts instance of Psr\Container\ContainerInterface as first argument.', __CLASS__)); } } /** * {@inheritdoc} */ public function warmUp($cacheDir) { if (null === $this->translator) { $this->translator = $this->container->get('translator'); } if ($this->translator instanceof WarmableInterface) { $this->translator->warmUp($cacheDir); } } /** * {@inheritdoc} */ public function isOptional() { return true; } /** * {@inheritdoc} */ public static function getSubscribedServices() { return array( 'translator' => TranslatorInterface::class, ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php���������������0000664�0000000�0000000�00000006731�13247321071�0030713�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; use Doctrine\Common\Annotations\AnnotationException; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Validator\Mapping\Cache\Psr6Cache; use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\LoaderChain; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; use Symfony\Component\Validator\ValidatorBuilderInterface; /** * Warms up XML and YAML validator metadata. * * @author Titouan Galopin <galopintitouan@gmail.com> */ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer { private $validatorBuilder; /** * @param ValidatorBuilderInterface $validatorBuilder * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArrayFile, CacheItemPoolInterface $fallbackPool) { parent::__construct($phpArrayFile, $fallbackPool); $this->validatorBuilder = $validatorBuilder; } /** * {@inheritdoc} */ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) { if (!method_exists($this->validatorBuilder, 'getLoaders')) { return false; } $loaders = $this->validatorBuilder->getLoaders(); $metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayAdapter)); foreach ($this->extractSupportedLoaders($loaders) as $loader) { foreach ($loader->getMappedClasses() as $mappedClass) { try { if ($metadataFactory->hasMetadataFor($mappedClass)) { $metadataFactory->getMetadataFor($mappedClass); } } catch (\ReflectionException $e) { // ignore failing reflection } catch (AnnotationException $e) { // ignore failing annotations } } } return true; } protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values) { // make sure we don't cache null values parent::warmUpPhpArrayAdapter($phpArrayAdapter, array_filter($values)); } /** * @param LoaderInterface[] $loaders * * @return XmlFileLoader[]|YamlFileLoader[] */ private function extractSupportedLoaders(array $loaders) { $supportedLoaders = array(); foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { $supportedLoaders[] = $loader; } elseif ($loader instanceof LoaderChain) { $supportedLoaders = array_merge($supportedLoaders, $this->extractSupportedLoaders($loader->getLoaders())); } } return $supportedLoaders; } } ���������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Client.php�����������������������������������������0000664�0000000�0000000�00000012767�13247321071�0023727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Client as BaseClient; use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; /** * Client simulates a browser and makes requests to a Kernel object. * * @author Fabien Potencier <fabien@symfony.com> */ class Client extends BaseClient { private $hasPerformedRequest = false; private $profiler = false; private $reboot = true; /** * {@inheritdoc} */ public function __construct(KernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) { parent::__construct($kernel, $server, $history, $cookieJar); } /** * Returns the container. * * @return ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet */ public function getContainer() { return $this->kernel->getContainer(); } /** * Returns the kernel. * * @return KernelInterface */ public function getKernel() { return $this->kernel; } /** * Gets the profile associated with the current Response. * * @return HttpProfile|false A Profile instance */ public function getProfile() { if (!$this->kernel->getContainer()->has('profiler')) { return false; } return $this->kernel->getContainer()->get('profiler')->loadProfileFromResponse($this->response); } /** * Enables the profiler for the very next request. * * If the profiler is not enabled, the call to this method does nothing. */ public function enableProfiler() { if ($this->kernel->getContainer()->has('profiler')) { $this->profiler = true; } } /** * Disables kernel reboot between requests. * * By default, the Client reboots the Kernel for each request. This method * allows to keep the same kernel across requests. */ public function disableReboot() { $this->reboot = false; } /** * Enables kernel reboot between requests. */ public function enableReboot() { $this->reboot = true; } /** * {@inheritdoc} * * @param Request $request A Request instance * * @return Response A Response instance */ protected function doRequest($request) { // avoid shutting down the Kernel if no request has been performed yet // WebTestCase::createClient() boots the Kernel but do not handle a request if ($this->hasPerformedRequest && $this->reboot) { $this->kernel->shutdown(); } else { $this->hasPerformedRequest = true; } if ($this->profiler) { $this->profiler = false; $this->kernel->boot(); $this->kernel->getContainer()->get('profiler')->enable(); } return parent::doRequest($request); } /** * {@inheritdoc} * * @param Request $request A Request instance * * @return Response A Response instance */ protected function doRequestInProcess($request) { $response = parent::doRequestInProcess($request); $this->profiler = false; return $response; } /** * Returns the script to execute when the request must be insulated. * * It assumes that the autoloader is named 'autoload.php' and that it is * stored in the same directory as the kernel (this is the case for the * Symfony Standard Edition). If this is not your case, create your own * client and override this method. * * @param Request $request A Request instance * * @return string The script content */ protected function getScript($request) { $kernel = str_replace("'", "\\'", serialize($this->kernel)); $request = str_replace("'", "\\'", serialize($request)); $errorReporting = error_reporting(); $requires = ''; foreach (get_declared_classes() as $class) { if (0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $file = dirname(dirname($r->getFileName())).'/autoload.php'; if (file_exists($file)) { $requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; } } } if (!$requires) { throw new \RuntimeException('Composer autoloader not found.'); } $requires .= "require_once '".str_replace("'", "\\'", (new \ReflectionObject($this->kernel))->getFileName())."';\n"; $profilerCode = ''; if ($this->profiler) { $profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();'; } $code = <<<EOF <?php error_reporting($errorReporting); $requires \$kernel = unserialize('$kernel'); \$kernel->boot(); $profilerCode \$request = unserialize('$request'); EOF; return $code.$this->getHandleScript(); } } ���������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/�������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023341�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php���������������������������0000664�0000000�0000000�00000012526�13247321071�0026431�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelInterface; /** * A console command to display information about the current installation. * * @author Roland Franssen <franssen.roland@gmail.com> * * @final since version 3.4 */ class AboutCommand extends ContainerAwareCommand { protected static $defaultName = 'about'; /** * {@inheritdoc} */ protected function configure() { $this ->setDescription('Displays information about the current project') ->setHelp(<<<'EOT' The <info>%command.name%</info> command displays information about the current Symfony project. The <info>PHP</info> section displays important configuration that could affect your application. The values might be different between web and CLI. The <info>Environment</info> section displays the current environment variables managed by Symfony Dotenv. It will not be shown if no variables were found. The values might be different between web and CLI. EOT ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); /** @var $kernel KernelInterface */ $kernel = $this->getApplication()->getKernel(); $rows = array( array('<info>Symfony</>'), new TableSeparator(), array('Version', Kernel::VERSION), array('End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : '')), array('End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : '')), new TableSeparator(), array('<info>Kernel</>'), new TableSeparator(), array('Type', get_class($kernel)), array('Name', $kernel->getName()), array('Environment', $kernel->getEnvironment()), array('Debug', $kernel->isDebug() ? 'true' : 'false'), array('Charset', $kernel->getCharset()), array('Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())), array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'), array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'), new TableSeparator(), array('<info>PHP</>'), new TableSeparator(), array('Version', PHP_VERSION), array('Architecture', (PHP_INT_SIZE * 8).' bits'), array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'), array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'), array('OPcache', extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'), array('APCu', extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'), array('Xdebug', extension_loaded('xdebug') ? 'true' : 'false'), ); if ($dotenv = self::getDotenvVars()) { $rows = array_merge($rows, array( new TableSeparator(), array('<info>Environment (.env)</>'), new TableSeparator(), ), array_map(function ($value, $name) { return array($name, $value); }, $dotenv, array_keys($dotenv))); } $io->table(array(), $rows); } private static function formatPath($path, $baseDir = null) { return null !== $baseDir ? preg_replace('~^'.preg_quote($baseDir, '~').'~', '.', $path) : $path; } private static function formatFileSize($path) { if (is_file($path)) { $size = filesize($path) ?: 0; } else { $size = 0; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::FOLLOW_SYMLINKS)) as $file) { $size += $file->getSize(); } } return Helper::formatMemory($size); } private static function isExpired($date) { $date = \DateTime::createFromFormat('m/Y', $date); return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59'); } private static function getDotenvVars() { $vars = array(); foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) { if ('' !== $name && false !== $value = getenv($name)) { $vars[$name] = $value; } } return $vars; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php������������������0000664�0000000�0000000�00000010722�13247321071�0030244�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; /** * A console command for dumping available configuration reference. * * @author Kevin Bond <kevinbond@gmail.com> * @author Wouter J <waldio.webdesign@gmail.com> * @author Grégoire Pineau <lyrixx@lyrixx.info> */ abstract class AbstractConfigCommand extends ContainerDebugCommand { protected function listBundles($output) { $title = 'Available registered bundles with their extension alias if available'; $headers = array('Bundle name', 'Extension alias'); $rows = array(); $bundles = $this->getApplication()->getKernel()->getBundles(); usort($bundles, function ($bundleA, $bundleB) { return strcmp($bundleA->getName(), $bundleB->getName()); }); foreach ($bundles as $bundle) { $extension = $bundle->getContainerExtension(); $rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : ''); } if ($output instanceof StyleInterface) { $output->title($title); $output->table($headers, $rows); } else { $output->writeln($title); $table = new Table($output); $table->setHeaders($headers)->setRows($rows)->render(); } } protected function findExtension($name) { $bundles = $this->initializeBundles(); $minScore = INF; foreach ($bundles as $bundle) { if ($name === $bundle->getName()) { if (!$bundle->getContainerExtension()) { throw new \LogicException(sprintf('Bundle "%s" does not have a container extension.', $name)); } return $bundle->getContainerExtension(); } $distance = levenshtein($name, $bundle->getName()); if ($distance < $minScore) { $guess = $bundle->getName(); $minScore = $distance; } $extension = $bundle->getContainerExtension(); if ($extension) { if ($name === $extension->getAlias()) { return $extension; } $distance = levenshtein($name, $extension->getAlias()); if ($distance < $minScore) { $guess = $extension->getAlias(); $minScore = $distance; } } } if ('Bundle' !== substr($name, -6)) { $message = sprintf('No extensions with configuration available for "%s".', $name); } else { $message = sprintf('No extension with alias "%s" is enabled.', $name); } if (isset($guess) && $minScore < 3) { $message .= sprintf("\n\nDid you mean \"%s\"?", $guess); } throw new \LogicException($message); } public function validateConfiguration(ExtensionInterface $extension, $configuration) { if (!$configuration) { throw new \LogicException(sprintf('The extension with alias "%s" does not have its getConfiguration() method setup', $extension->getAlias())); } if (!$configuration instanceof ConfigurationInterface) { throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable', get_class($configuration))); } } private function initializeBundles() { // Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method // as this method is not called when the container is loaded from the cache. $container = $this->getContainerBuilder(); $bundles = $this->getApplication()->getKernel()->getBundles(); foreach ($bundles as $bundle) { if ($extension = $bundle->getContainerExtension()) { $container->registerExtension($extension); } } foreach ($bundles as $bundle) { $bundle->build($container); } return $bundles; } } ����������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php�������������������0000664�0000000�0000000�00000023774�13247321071�0030157�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; /** * Command that places bundle web assets into a given directory. * * @author Fabien Potencier <fabien@symfony.com> * @author Gábor Egyed <gabor.egyed@gmail.com> * * @final since version 3.4 */ class AssetsInstallCommand extends ContainerAwareCommand { const METHOD_COPY = 'copy'; const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink'; const METHOD_RELATIVE_SYMLINK = 'relative symlink'; protected static $defaultName = 'assets:install'; private $filesystem; /** * @param Filesystem $filesystem */ public function __construct($filesystem = null) { if (!$filesystem instanceof Filesystem) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, Filesystem::class), E_USER_DEPRECATED); parent::__construct($filesystem); return; } parent::__construct(); $this->filesystem = $filesystem; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'), )) ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks') ->setDescription('Installs bundles web assets under a public directory') ->setHelp(<<<'EOT' The <info>%command.name%</info> command installs bundle assets into a given directory (e.g. the <comment>public</comment> directory). <info>php %command.full_name% public</info> A "bundles" directory will be created inside the target directory and the "Resources/public" directory of each bundle will be copied into it. To create a symlink to each bundle instead of copying its assets, use the <info>--symlink</info> option (will fall back to hard copies when symbolic links aren't possible: <info>php %command.full_name% public --symlink</info> To make symlink relative, add the <info>--relative</info> option: <info>php %command.full_name% public --symlink --relative</info> EOT ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->filesystem) { $this->filesystem = $this->getContainer()->get('filesystem'); $baseDir = $this->getContainer()->getParameter('kernel.project_dir'); } $kernel = $this->getApplication()->getKernel(); $targetArg = rtrim($input->getArgument('target'), '/'); if (!is_dir($targetArg)) { $targetArg = (isset($baseDir) ? $baseDir : $kernel->getContainer()->getParameter('kernel.project_dir')).'/'.$targetArg; if (!is_dir($targetArg)) { // deprecated, logic to be removed in 4.0 // this allows the commands to work out of the box with web/ and public/ if (is_dir(dirname($targetArg).'/web')) { $targetArg = dirname($targetArg).'/web'; } else { throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target'))); } } } $bundlesDir = $targetArg.'/bundles/'; $io = new SymfonyStyle($input, $output); $io->newLine(); if ($input->getOption('relative')) { $expectedMethod = self::METHOD_RELATIVE_SYMLINK; $io->text('Trying to install assets as <info>relative symbolic links</info>.'); } elseif ($input->getOption('symlink')) { $expectedMethod = self::METHOD_ABSOLUTE_SYMLINK; $io->text('Trying to install assets as <info>absolute symbolic links</info>.'); } else { $expectedMethod = self::METHOD_COPY; $io->text('Installing assets as <info>hard copies</info>.'); } $io->newLine(); $rows = array(); $copyUsed = false; $exitCode = 0; $validAssetDirs = array(); /** @var BundleInterface $bundle */ foreach ($kernel->getBundles() as $bundle) { if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) { continue; } $assetDir = preg_replace('/bundle$/', '', strtolower($bundle->getName())); $targetDir = $bundlesDir.$assetDir; $validAssetDirs[] = $assetDir; if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $message = sprintf("%s\n-> %s", $bundle->getName(), $targetDir); } else { $message = $bundle->getName(); } try { $this->filesystem->remove($targetDir); if (self::METHOD_RELATIVE_SYMLINK === $expectedMethod) { $method = $this->relativeSymlinkWithFallback($originDir, $targetDir); } elseif (self::METHOD_ABSOLUTE_SYMLINK === $expectedMethod) { $method = $this->absoluteSymlinkWithFallback($originDir, $targetDir); } else { $method = $this->hardCopy($originDir, $targetDir); } if (self::METHOD_COPY === $method) { $copyUsed = true; } if ($method === $expectedMethod) { $rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method); } else { $rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method); } } catch (\Exception $e) { $exitCode = 1; $rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()); } } // remove the assets of the bundles that no longer exist if (is_dir($bundlesDir)) { $dirsToRemove = Finder::create()->depth(0)->directories()->exclude($validAssetDirs)->in($bundlesDir); $this->filesystem->remove($dirsToRemove); } if ($rows) { $io->table(array('', 'Bundle', 'Method / Error'), $rows); } if (0 !== $exitCode) { $io->error('Some errors occurred while installing assets.'); } else { if ($copyUsed) { $io->note('Some assets were installed via copy. If you make changes to these assets you have to run this command again.'); } $io->success($rows ? 'All assets were successfully installed.' : 'No assets were provided by any bundle.'); } return $exitCode; } /** * Try to create relative symlink. * * Falling back to absolute symlink and finally hard copy. * * @param string $originDir * @param string $targetDir * * @return string */ private function relativeSymlinkWithFallback($originDir, $targetDir) { try { $this->symlink($originDir, $targetDir, true); $method = self::METHOD_RELATIVE_SYMLINK; } catch (IOException $e) { $method = $this->absoluteSymlinkWithFallback($originDir, $targetDir); } return $method; } /** * Try to create absolute symlink. * * Falling back to hard copy. * * @param string $originDir * @param string $targetDir * * @return string */ private function absoluteSymlinkWithFallback($originDir, $targetDir) { try { $this->symlink($originDir, $targetDir); $method = self::METHOD_ABSOLUTE_SYMLINK; } catch (IOException $e) { // fall back to copy $method = $this->hardCopy($originDir, $targetDir); } return $method; } /** * Creates symbolic link. * * @param string $originDir * @param string $targetDir * @param bool $relative * * @throws IOException if link can not be created */ private function symlink($originDir, $targetDir, $relative = false) { if ($relative) { $this->filesystem->mkdir(dirname($targetDir)); $originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir))); } $this->filesystem->symlink($originDir, $targetDir); if (!file_exists($targetDir)) { throw new IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir); } } /** * Copies origin to target. * * @param string $originDir * @param string $targetDir * * @return string */ private function hardCopy($originDir, $targetDir) { $this->filesystem->mkdir($targetDir, 0777); // We use a custom iterator to ignore VCS files $this->filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir)); return self::METHOD_COPY; } } ����symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php����������������������0000664�0000000�0000000�00000030632�13247321071�0027327�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\RebootableInterface; use Symfony\Component\Finder\Finder; /** * Clear and Warmup the cache. * * @author Francis Besset <francis.besset@gmail.com> * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class CacheClearCommand extends ContainerAwareCommand { protected static $defaultName = 'cache:clear'; private $cacheClearer; private $filesystem; private $warning; /** * @param CacheClearerInterface $cacheClearer * @param Filesystem|null $filesystem */ public function __construct($cacheClearer = null, Filesystem $filesystem = null) { if (!$cacheClearer instanceof CacheClearerInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, CacheClearerInterface::class), E_USER_DEPRECATED); parent::__construct($cacheClearer); return; } parent::__construct(); $this->cacheClearer = $cacheClearer; $this->filesystem = $filesystem ?: new Filesystem(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'), new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Clears the cache') ->setHelp(<<<'EOF' The <info>%command.name%</info> command clears the application cache for a given environment and debug mode: <info>php %command.full_name% --env=dev</info> <info>php %command.full_name% --env=prod --no-debug</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->cacheClearer) { $this->cacheClearer = $this->getContainer()->get('cache_clearer'); $this->filesystem = $this->getContainer()->get('filesystem'); $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); } $fs = $this->filesystem; $io = new SymfonyStyle($input, $output); $kernel = $this->getApplication()->getKernel(); $realCacheDir = isset($realCacheDir) ? $realCacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'); // the old cache dir name must not be longer than the real one to avoid exceeding // the maximum length of a directory or file path within it (esp. Windows MAX_PATH) $oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~'); $fs->remove($oldCacheDir); if (!is_writable($realCacheDir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir)); } $io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); $this->cacheClearer->clear($realCacheDir); // The current event dispatcher is stale, let's not use it anymore $this->getApplication()->setDispatcher(new EventDispatcher()); $containerDir = new \ReflectionObject($kernel->getContainer()); $containerDir = basename(dirname($containerDir->getFileName())); // the warmup cache dir name must have the same length as the real one // to avoid the many problems in serialized resources files $warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_'); if ($output->isVerbose() && $fs->exists($warmupDir)) { $io->comment('Clearing outdated warmup directory...'); } $fs->remove($warmupDir); $fs->mkdir($warmupDir); if (!$input->getOption('no-warmup')) { if ($output->isVerbose()) { $io->comment('Warming up cache...'); } $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); if ($this->warning) { @trigger_error($this->warning, E_USER_DEPRECATED); $io->warning($this->warning); $this->warning = null; } } $containerDir = $fs->exists($warmupDir.'/'.$containerDir) ? false : $containerDir; $fs->rename($realCacheDir, $oldCacheDir); $fs->rename($warmupDir, $realCacheDir); if ($containerDir) { $fs->rename($oldCacheDir.'/'.$containerDir, $realCacheDir.'/'.$containerDir); touch($realCacheDir.'/'.$containerDir.'.legacy'); } if ($output->isVerbose()) { $io->comment('Removing old cache directory...'); } try { $fs->remove($oldCacheDir); } catch (IOException $e) { if ($output->isVerbose()) { $io->warning($e->getMessage()); } } if ($output->isVerbose()) { $io->comment('Finished'); } $io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); } /** * @param string $warmupDir * @param string $realCacheDir * @param bool $enableOptionalWarmers */ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true) { // create a temporary kernel $realKernel = $this->getApplication()->getKernel(); if ($realKernel instanceof RebootableInterface) { $realKernel->reboot($warmupDir); $tempKernel = $realKernel; } else { $this->warning = 'Calling "cache:clear" with a kernel that does not implement "Symfony\Component\HttpKernel\RebootableInterface" is deprecated since Symfony 3.4 and will be unsupported in 4.0.'; $realKernelClass = get_class($realKernel); $namespace = ''; if (false !== $pos = strrpos($realKernelClass, '\\')) { $namespace = substr($realKernelClass, 0, $pos); $realKernelClass = substr($realKernelClass, $pos + 1); } $tempKernel = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir); $tempKernel->boot(); $tempKernelReflection = new \ReflectionObject($tempKernel); $tempKernelFile = $tempKernelReflection->getFileName(); } // warmup temporary dir $warmer = $tempKernel->getContainer()->get('cache_warmer'); if ($enableOptionalWarmers) { $warmer->enableOptionalWarmers(); } $warmer->warmUp($warmupDir); // fix references to cached files with the real cache directory name $search = array($warmupDir, str_replace('\\', '\\\\', $warmupDir)); $replace = str_replace('\\', '/', $realCacheDir); foreach (Finder::create()->files()->in($warmupDir) as $file) { $content = str_replace($search, $replace, file_get_contents($file), $count); if ($count) { file_put_contents($file, $content); } } if ($realKernel instanceof RebootableInterface) { return; } // fix references to the Kernel in .meta files $safeTempKernel = str_replace('\\', '\\\\', get_class($tempKernel)); $realKernelFQN = get_class($realKernel); foreach (Finder::create()->files()->depth('<3')->name('*.meta')->in($warmupDir) as $file) { file_put_contents($file, preg_replace( '/(C\:\d+\:)"'.$safeTempKernel.'"/', sprintf('$1"%s"', $realKernelFQN), file_get_contents($file) )); } // fix references to container's class $tempContainerClass = $tempKernel->getContainerClass(); $realContainerClass = $tempKernel->getRealContainerClass(); foreach (Finder::create()->files()->depth('<2')->name($tempContainerClass.'*')->in($warmupDir) as $file) { $content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file)); file_put_contents($file, $content); rename($file, str_replace(DIRECTORY_SEPARATOR.$tempContainerClass, DIRECTORY_SEPARATOR.$realContainerClass, $file)); } if (is_dir($tempContainerDir = $warmupDir.'/'.get_class($tempKernel->getContainer()))) { foreach (Finder::create()->files()->in($tempContainerDir) as $file) { $content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file)); file_put_contents($file, $content); } } // remove temp kernel file after cache warmed up @unlink($tempKernelFile); } /** * @param KernelInterface $parent * @param string $namespace * @param string $parentClass * @param string $warmupDir * * @return KernelInterface */ protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir) { $projectDir = ''; $cacheDir = var_export($warmupDir, true); $rootDir = var_export(realpath($parent->getRootDir()), true); $logDir = var_export(realpath($parent->getLogDir()), true); // the temp kernel class name must have the same length than the real one // to avoid the many problems in serialized resources files $class = substr($parentClass, 0, -1).'_'; // the temp container class must be changed too $container = $parent->getContainer(); $realContainerClass = var_export($container->hasParameter('kernel.container_class') ? $container->getParameter('kernel.container_class') : get_class($parent->getContainer()), true); $containerClass = substr_replace($realContainerClass, '_', -2, 1); if (method_exists($parent, 'getProjectDir')) { $projectDir = var_export(realpath($parent->getProjectDir()), true); $projectDir = <<<EOF public function getProjectDir() { return $projectDir; } EOF; } $code = <<<EOF <?php namespace $namespace { class $class extends $parentClass { public function getCacheDir() { return $cacheDir; } public function getRootDir() { return $rootDir; } $projectDir public function getLogDir() { return $logDir; } public function getRealContainerClass() { return $realContainerClass; } public function getContainerClass() { return $containerClass; } protected function buildContainer() { \$container = parent::buildContainer(); // filter container's resources, removing reference to temp kernel file \$resources = \$container->getResources(); \$filteredResources = array(); foreach (\$resources as \$resource) { if ((string) \$resource !== __FILE__) { \$filteredResources[] = \$resource; } } \$container->setResources(\$filteredResources); return \$container; } } } EOF; $this->filesystem->mkdir($warmupDir); file_put_contents($file = $warmupDir.'/kernel.tmp', $code); require_once $file; $class = "$namespace\\$class"; return new $class($parent->getEnvironment(), $parent->isDebug()); } } ������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php������������������0000664�0000000�0000000�00000007271�13247321071�0030164�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; /** * Clear cache pools. * * @author Nicolas Grekas <p@tchwork.com> */ final class CachePoolClearCommand extends ContainerAwareCommand { protected static $defaultName = 'cache:pool:clear'; private $poolClearer; /** * @param Psr6CacheClearer $poolClearer */ public function __construct($poolClearer = null) { if (!$poolClearer instanceof Psr6CacheClearer) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, Psr6CacheClearer::class), E_USER_DEPRECATED); parent::__construct($poolClearer); return; } parent::__construct(); $this->poolClearer = $poolClearer; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'), )) ->setDescription('Clears cache pools') ->setHelp(<<<'EOF' The <info>%command.name%</info> command clears the given cache pools or cache pool clearers. %command.full_name% <cache pool or clearer 1> [...<cache pool or clearer N>] EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->poolClearer) { $this->poolClearer = $this->getContainer()->get('cache.global_clearer'); $cacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); } $io = new SymfonyStyle($input, $output); $kernel = $this->getApplication()->getKernel(); $pools = array(); $clearers = array(); foreach ($input->getArgument('pools') as $id) { if ($this->poolClearer->hasPool($id)) { $pools[$id] = $id; } else { $pool = $kernel->getContainer()->get($id); if ($pool instanceof CacheItemPoolInterface) { $pools[$id] = $pool; } elseif ($pool instanceof Psr6CacheClearer) { $clearers[$id] = $pool; } else { throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id)); } } } foreach ($clearers as $id => $clearer) { $io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id)); $clearer->clear(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir')); } foreach ($pools as $id => $pool) { $io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id)); if ($pool instanceof CacheItemPoolInterface) { $pool->clear(); } else { $this->poolClearer->clearPool($id); } } $io->success('Cache was successfully cleared.'); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php������������������0000664�0000000�0000000�00000003210�13247321071�0030214�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; /** * Cache pool pruner command. * * @author Rob Frawley 2nd <rmf@src.run> */ final class CachePoolPruneCommand extends Command { protected static $defaultName = 'cache:pool:prune'; private $pools; /** * @param iterable|PruneableInterface[] $pools */ public function __construct($pools) { parent::__construct(); $this->pools = $pools; } /** * {@inheritdoc} */ protected function configure() { $this ->setDescription('Prune cache pools') ->setHelp(<<<'EOF' The <info>%command.name%</info> command deletes all expired items from all pruneable pools. %command.full_name% EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); foreach ($this->pools as $name => $pool) { $io->comment(sprintf('Pruning cache pool: <info>%s</info>', $name)); $pool->prune(); } $io->success('Successfully pruned cache pool(s).'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php���������������������0000664�0000000�0000000�00000006277�13247321071�0027564�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; /** * Warmup the cache. * * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class CacheWarmupCommand extends ContainerAwareCommand { protected static $defaultName = 'cache:warmup'; private $cacheWarmer; /** * @param CacheWarmerAggregate $cacheWarmer */ public function __construct($cacheWarmer = null) { if (!$cacheWarmer instanceof CacheWarmerAggregate) { @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); parent::__construct($cacheWarmer); return; } parent::__construct(); $this->cacheWarmer = $cacheWarmer; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Warms up an empty cache') ->setHelp(<<<'EOF' The <info>%command.name%</info> command warms up the cache. Before running this command, the cache must be empty. This command does not generate the classes cache (as when executing this command, too many classes that should be part of the cache are already loaded in memory). Use <comment>curl</comment> or any other similar tool to warm up the classes cache if you want. EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->cacheWarmer) { $this->cacheWarmer = $this->getContainer()->get('cache_warmer'); $cacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); } $io = new SymfonyStyle($input, $output); $kernel = $this->getApplication()->getKernel(); $io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); if (!$input->getOption('no-optional-warmers')) { $this->cacheWarmer->enableOptionalWarmers(); } $this->cacheWarmer->warmUp(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir')); $io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php���������������������0000664�0000000�0000000�00000011627�13247321071�0027534�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Yaml\Yaml; /** * A console command for dumping available configuration reference. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * * @final since version 3.4 */ class ConfigDebugCommand extends AbstractConfigCommand { protected static $defaultName = 'debug:config'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'), new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), )) ->setDescription('Dumps the current configuration for an extension') ->setHelp(<<<'EOF' The <info>%command.name%</info> command dumps the current configuration for an extension/bundle. Either the extension alias or bundle name can be used: <info>php %command.full_name% framework</info> <info>php %command.full_name% FrameworkBundle</info> For dumping a specific option, add its path as second argument: <info>php %command.full_name% framework serializer.enabled</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); if (null === $name = $input->getArgument('name')) { $this->listBundles($errorIo); $errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)'); $errorIo->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)'); return; } $extension = $this->findExtension($name); $container = $this->compileContainer(); $extensionAlias = $extension->getAlias(); $configs = $container->getExtensionConfig($extensionAlias); $configuration = $extension->getConfiguration($configs, $container); $this->validateConfiguration($extension, $configuration); $configs = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($configs)); $processor = new Processor(); $config = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($processor->processConfiguration($configuration, $configs))); if (null === $path = $input->getArgument('path')) { $io->title( sprintf('Current configuration for %s', ($name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))) ); $io->writeln(Yaml::dump(array($extensionAlias => $config), 10)); return; } try { $config = $this->getConfigForPath($config, $path, $extensionAlias); } catch (LogicException $e) { $errorIo->error($e->getMessage()); return; } $io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path)); $io->writeln(Yaml::dump($config, 10)); } private function compileContainer() { $kernel = clone $this->getApplication()->getKernel(); $kernel->boot(); $method = new \ReflectionMethod($kernel, 'buildContainer'); $method->setAccessible(true); $container = $method->invoke($kernel); $container->getCompiler()->compile($container); return $container; } /** * Iterate over configuration until the last step of the given path. * * @param array $config A bundle configuration * * @throws LogicException If the configuration does not exist * * @return mixed */ private function getConfigForPath(array $config, $path, $alias) { $steps = explode('.', $path); foreach ($steps as $step) { if (!array_key_exists($step, $config)) { throw new LogicException(sprintf('Unable to find configuration for "%s.%s"', $alias, $path)); } $config = $config[$step]; } return $config; } } ���������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php�������������0000664�0000000�0000000�00000011240�13247321071�0031221�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; /** * A console command for dumping available configuration reference. * * @author Kevin Bond <kevinbond@gmail.com> * @author Wouter J <waldio.webdesign@gmail.com> * @author Grégoire Pineau <lyrixx@lyrixx.info> * * @final since version 3.4 */ class ConfigDumpReferenceCommand extends AbstractConfigCommand { protected static $defaultName = 'config:dump-reference'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'), new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'), )) ->setDescription('Dumps the default configuration for an extension') ->setHelp(<<<'EOF' The <info>%command.name%</info> command dumps the default configuration for an extension/bundle. Either the extension alias or bundle name can be used: <info>php %command.full_name% framework</info> <info>php %command.full_name% FrameworkBundle</info> With the <info>--format</info> option specifies the format of the configuration, this is either <comment>yaml</comment> or <comment>xml</comment>. When the option is not provided, <comment>yaml</comment> is used. <info>php %command.full_name% FrameworkBundle --format=xml</info> For dumping a specific option, add its path as second argument (only available for the yaml format): <info>php %command.full_name% framework profiler.matcher</info> EOF ) ; } /** * {@inheritdoc} * * @throws \LogicException */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); if (null === $name = $input->getArgument('name')) { $this->listBundles($errorIo); $errorIo->comment(array( 'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)', 'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)', )); return; } $extension = $this->findExtension($name); $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder()); $this->validateConfiguration($extension, $configuration); $format = $input->getOption('format'); $path = $input->getArgument('path'); if (null !== $path && 'yaml' !== $format) { $errorIo->error('The "path" option is only available for the "yaml" format.'); return 1; } if ($name === $extension->getAlias()) { $message = sprintf('Default configuration for extension with alias: "%s"', $name); } else { $message = sprintf('Default configuration for "%s"', $name); } if (null !== $path) { $message .= sprintf(' at path "%s"', $path); } switch ($format) { case 'yaml': $io->writeln(sprintf('# %s', $message)); $dumper = new YamlReferenceDumper(); break; case 'xml': $io->writeln(sprintf('<!-- %s -->', $message)); $dumper = new XmlReferenceDumper(); break; default: $io->writeln($message); throw new \InvalidArgumentException('Only the yaml and xml formats are supported.'); } $io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path)); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php������������������0000664�0000000�0000000�00000002564�13247321071�0030262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; /** * Command. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface { /** * @var ContainerInterface|null */ private $container; /** * @return ContainerInterface * * @throws \LogicException */ protected function getContainer() { if (null === $this->container) { $application = $this->getApplication(); if (null === $application) { throw new \LogicException('The container cannot be retrieved as the application instance is not yet set.'); } $this->container = $application->getKernel()->getContainer(); } return $this->container; } /** * {@inheritdoc} */ public function setContainer(ContainerInterface $container = null) { $this->container = $container; } } ��������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php������������������0000664�0000000�0000000�00000023665�13247321071�0030256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\Config\FileLocator; /** * A console command for retrieving information about services. * * @author Ryan Weaver <ryan@thatsquality.com> * * @internal since version 3.4 */ class ContainerDebugCommand extends ContainerAwareCommand { protected static $defaultName = 'debug:container'; /** * @var ContainerBuilder|null */ protected $containerBuilder; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'), new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services'), new InputOption('show-arguments', null, InputOption::VALUE_NONE, 'Used to show arguments in services'), new InputOption('tag', null, InputOption::VALUE_REQUIRED, 'Shows all services with a specific tag'), new InputOption('tags', null, InputOption::VALUE_NONE, 'Displays tagged services for an application'), new InputOption('parameter', null, InputOption::VALUE_REQUIRED, 'Displays a specific parameter for an application'), new InputOption('parameters', null, InputOption::VALUE_NONE, 'Displays parameters for an application'), new InputOption('types', null, InputOption::VALUE_NONE, 'Displays types (classes/interfaces) available in the container'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'), )) ->setDescription('Displays current services for an application') ->setHelp(<<<'EOF' The <info>%command.name%</info> command displays all configured <comment>public</comment> services: <info>php %command.full_name%</info> To get specific information about a service, specify its name: <info>php %command.full_name% validator</info> To see available types that can be used for autowiring, use the <info>--types</info> flag: <info>php %command.full_name% --types</info> By default, private services are hidden. You can display all services by using the <info>--show-private</info> flag: <info>php %command.full_name% --show-private</info> Use the --tags option to display tagged <comment>public</comment> services grouped by tag: <info>php %command.full_name% --tags</info> Find all services with a specific tag by specifying the tag name with the <info>--tag</info> option: <info>php %command.full_name% --tag=form.type</info> Use the <info>--parameters</info> option to display all parameters: <info>php %command.full_name% --parameters</info> Display a specific parameter by specifying its name with the <info>--parameter</info> option: <info>php %command.full_name% --parameter=kernel.debug</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); $this->validateInput($input); $object = $this->getContainerBuilder(); if ($input->getOption('types')) { $options = array('show_private' => true); $options['filter'] = array($this, 'filterToServiceTypes'); } elseif ($input->getOption('parameters')) { $parameters = array(); foreach ($object->getParameterBag()->all() as $k => $v) { $parameters[$k] = $object->resolveEnvPlaceholders($v); } $object = new ParameterBag($parameters); $options = array(); } elseif ($parameter = $input->getOption('parameter')) { $options = array('parameter' => $parameter); } elseif ($input->getOption('tags')) { $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private')); } elseif ($tag = $input->getOption('tag')) { $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private')); } elseif ($name = $input->getArgument('name')) { $name = $this->findProperServiceName($input, $errorIo, $object, $name); $options = array('id' => $name); } else { $options = array('show_private' => $input->getOption('show-private')); } $helper = new DescriptorHelper(); $options['format'] = $input->getOption('format'); $options['show_arguments'] = $input->getOption('show-arguments'); $options['raw_text'] = $input->getOption('raw'); $options['output'] = $io; $helper->describe($io, $object, $options); if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) { if ($input->getOption('tags')) { $errorIo->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)'); } elseif ($input->getOption('parameters')) { $errorIo->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)'); } else { $errorIo->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)'); } } } /** * Validates input arguments and options. * * @throws \InvalidArgumentException */ protected function validateInput(InputInterface $input) { $options = array('tags', 'tag', 'parameters', 'parameter'); $optionsCount = 0; foreach ($options as $option) { if ($input->getOption($option)) { ++$optionsCount; } } $name = $input->getArgument('name'); if ((null !== $name) && ($optionsCount > 0)) { throw new \InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined with the service name argument.'); } elseif ((null === $name) && $optionsCount > 1) { throw new \InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined together.'); } } /** * Loads the ContainerBuilder from the cache. * * @return ContainerBuilder * * @throws \LogicException */ protected function getContainerBuilder() { if ($this->containerBuilder) { return $this->containerBuilder; } $kernel = $this->getApplication()->getKernel(); if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) { $buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, get_class($kernel)); $container = $buildContainer(); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); } else { (new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump')); } return $this->containerBuilder = $container; } private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, $name) { if ($builder->has($name) || !$input->isInteractive()) { return $name; } $matchingServices = $this->findServiceIdsContaining($builder, $name); if (empty($matchingServices)) { throw new \InvalidArgumentException(sprintf('No services found that match "%s".', $name)); } $default = 1 === count($matchingServices) ? $matchingServices[0] : null; return $io->choice('Select one of the following services to display its information', $matchingServices, $default); } private function findServiceIdsContaining(ContainerBuilder $builder, $name) { $serviceIds = $builder->getServiceIds(); $foundServiceIds = array(); foreach ($serviceIds as $serviceId) { if (false === stripos($serviceId, $name)) { continue; } $foundServiceIds[] = $serviceId; } return $foundServiceIds; } /** * @internal */ public function filterToServiceTypes($serviceId) { // filter out things that could not be valid class names if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $serviceId)) { return false; } // if the id has a \, assume it is a class if (false !== strpos($serviceId, '\\')) { return true; } try { new \ReflectionClass($serviceId); return true; } catch (\ReflectionException $e) { // the service id is not a valid class/interface return false; } } } ���������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php�����������������0000664�0000000�0000000�00000005553�13247321071�0030460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; /** * A console command for autowiring information. * * @author Ryan Weaver <ryan@knpuniversity.com> * * @internal */ class DebugAutowiringCommand extends ContainerDebugCommand { protected static $defaultName = 'debug:autowiring'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'), )) ->setDescription('Lists classes/interfaces you can use for autowiring') ->setHelp(<<<'EOF' The <info>%command.name%</info> command displays all classes and interfaces that you can use as type-hints for autowiring: <info>php %command.full_name%</info> You can also pass a search term to filter the list: <info>php %command.full_name% log</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); $builder = $this->getContainerBuilder(); $serviceIds = $builder->getServiceIds(); $serviceIds = array_filter($serviceIds, array($this, 'filterToServiceTypes')); if ($search = $input->getArgument('search')) { $serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) { return false !== stripos($serviceId, $search); }); if (empty($serviceIds)) { $errorIo->error(sprintf('No autowirable classes or interfaces found matching "%s"', $search)); return 1; } } asort($serviceIds); $io->title('Autowirable Services'); $io->text('The following classes & interfaces can be used as type-hints when autowiring:'); if ($search) { $io->text(sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search)); } $io->newLine(); $tableRows = array(); foreach ($serviceIds as $serviceId) { $tableRows[] = array(sprintf('<fg=cyan>%s</fg=cyan>', $serviceId)); if ($builder->hasAlias($serviceId)) { $tableRows[] = array(sprintf(' alias to %s', $builder->getAlias($serviceId))); } } $io->table(array(), $tableRows); } } �����������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php������������0000664�0000000�0000000�00000007130�13247321071�0031411�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * A console command for retrieving information about event dispatcher. * * @author Matthieu Auger <mail@matthieuauger.com> * * @final since version 3.4 */ class EventDispatcherDebugCommand extends ContainerAwareCommand { protected static $defaultName = 'debug:event-dispatcher'; private $dispatcher; /** * @param EventDispatcherInterface $dispatcher */ public function __construct($dispatcher = null) { if (!$dispatcher instanceof EventDispatcherInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, EventDispatcherInterface::class), E_USER_DEPRECATED); parent::__construct($dispatcher); return; } parent::__construct(); $this->dispatcher = $dispatcher; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('event', InputArgument::OPTIONAL, 'An event name'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'), )) ->setDescription('Displays configured listeners for an application') ->setHelp(<<<'EOF' The <info>%command.name%</info> command displays all configured listeners: <info>php %command.full_name%</info> To get specific listeners for an event, specify its name: <info>php %command.full_name% kernel.request</info> EOF ) ; } /** * {@inheritdoc} * * @throws \LogicException */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->dispatcher) { $this->dispatcher = $this->getEventDispatcher(); } $io = new SymfonyStyle($input, $output); $options = array(); if ($event = $input->getArgument('event')) { if (!$this->dispatcher->hasListeners($event)) { $io->getErrorStyle()->warning(sprintf('The event "%s" does not have any registered listeners.', $event)); return; } $options = array('event' => $event); } $helper = new DescriptorHelper(); $options['format'] = $input->getOption('format'); $options['raw_text'] = $input->getOption('raw'); $options['output'] = $io; $helper->describe($io, $this->dispatcher, $options); } /** * Loads the Event Dispatcher from the container. * * BC to removed in 4.0 * * @return EventDispatcherInterface */ protected function getEventDispatcher() { return $this->getContainer()->get('event_dispatcher'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php���������������������0000664�0000000�0000000�00000013224�13247321071�0027602�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\Route; /** * A console command for retrieving information about routes. * * @author Fabien Potencier <fabien@symfony.com> * @author Tobias Schultze <http://tobion.de> * * @final since version 3.4 */ class RouterDebugCommand extends ContainerAwareCommand { protected static $defaultName = 'debug:router'; private $router; /** * @param RouterInterface $router */ public function __construct($router = null) { if (!$router instanceof RouterInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, RouterInterface::class), E_USER_DEPRECATED); parent::__construct($router); return; } parent::__construct(); $this->router = $router; } /** * {@inheritdoc} * * BC to be removed in 4.0 */ public function isEnabled() { if (null !== $this->router) { return parent::isEnabled(); } if (!$this->getContainer()->has('router')) { return false; } $router = $this->getContainer()->get('router'); if (!$router instanceof RouterInterface) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'A route name'), new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw route(s)'), )) ->setDescription('Displays current routes for an application') ->setHelp(<<<'EOF' The <info>%command.name%</info> displays the configured routes: <info>php %command.full_name%</info> EOF ) ; } /** * {@inheritdoc} * * @throws \InvalidArgumentException When route does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->router) { $this->router = $this->getContainer()->get('router'); } $io = new SymfonyStyle($input, $output); $name = $input->getArgument('name'); $helper = new DescriptorHelper(); $routes = $this->router->getRouteCollection(); if ($name) { if (!$route = $routes->get($name)) { throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } $callable = $this->extractCallable($route); $helper->describe($io, $route, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'name' => $name, 'output' => $io, 'callable' => $callable, )); } else { foreach ($routes as $route) { $this->convertController($route); } $helper->describe($io, $routes, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'show_controllers' => $input->getOption('show-controllers'), 'output' => $io, )); } } private function convertController(Route $route) { if ($route->hasDefault('_controller')) { $nameParser = new ControllerNameParser($this->getApplication()->getKernel()); try { $route->setDefault('_controller', $nameParser->build($route->getDefault('_controller'))); } catch (\InvalidArgumentException $e) { } } } private function extractCallable(Route $route) { if (!$route->hasDefault('_controller')) { return; } $controller = $route->getDefault('_controller'); if (1 === substr_count($controller, ':')) { list($service, $method) = explode(':', $controller); try { return sprintf('%s::%s', get_class($this->getApplication()->getKernel()->getContainer()->get($service)), $method); } catch (ServiceNotFoundException $e) { } } $nameParser = new ControllerNameParser($this->getApplication()->getKernel()); try { $shortNotation = $nameParser->build($controller); $route->setDefault('_controller', $shortNotation); return $controller; } catch (\InvalidArgumentException $e) { } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php���������������������0000664�0000000�0000000�00000011345�13247321071�0027612�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; /** * A console command to test route matching. * * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class RouterMatchCommand extends ContainerAwareCommand { protected static $defaultName = 'router:match'; private $router; /** * @param RouterInterface $router */ public function __construct($router = null) { if (!$router instanceof RouterInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, RouterInterface::class), E_USER_DEPRECATED); parent::__construct($router); return; } parent::__construct(); $this->router = $router; } /** * {@inheritdoc} * * BC to be removed in 4.0 */ public function isEnabled() { if (null !== $this->router) { return parent::isEnabled(); } if (!$this->getContainer()->has('router')) { return false; } $router = $this->getContainer()->get('router'); if (!$router instanceof RouterInterface) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'), new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method'), new InputOption('scheme', null, InputOption::VALUE_REQUIRED, 'Sets the URI scheme (usually http or https)'), new InputOption('host', null, InputOption::VALUE_REQUIRED, 'Sets the URI host'), )) ->setDescription('Helps debug routes by simulating a path info match') ->setHelp(<<<'EOF' The <info>%command.name%</info> shows which routes match a given request and which don't and for what reason: <info>php %command.full_name% /foo</info> or <info>php %command.full_name% /foo --method POST --scheme https --host symfony.com --verbose</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->router) { $this->router = $this->getContainer()->get('router'); } $io = new SymfonyStyle($input, $output); $context = $this->router->getContext(); if (null !== $method = $input->getOption('method')) { $context->setMethod($method); } if (null !== $scheme = $input->getOption('scheme')) { $context->setScheme($scheme); } if (null !== $host = $input->getOption('host')) { $context->setHost($host); } $matcher = new TraceableUrlMatcher($this->router->getRouteCollection(), $context); $traces = $matcher->getTraces($input->getArgument('path_info')); $io->newLine(); $matches = false; foreach ($traces as $trace) { if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) { $io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log']))); } elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) { $io->success(sprintf('Route "%s" matches', $trace['name'])); $routerDebugCommand = $this->getApplication()->find('debug:router'); $routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output); $matches = true; } elseif ($input->getOption('verbose')) { $io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log'])); } } if (!$matches) { $io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info'))); return 1; } } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php����������������0000664�0000000�0000000�00000033744�13247321071�0030631�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\Catalogue\MergeOperation; use Symfony\Component\Translation\Extractor\ExtractorInterface; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Reader\TranslationReaderInterface; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\DataCollectorTranslator; use Symfony\Component\Translation\LoggingTranslator; use Symfony\Component\Translation\TranslatorInterface; /** * Helps finding unused or missing translation messages in a given locale * and comparing them with the fallback ones. * * @author Florian Voutzinos <florian@voutzinos.com> * * @final since version 3.4 */ class TranslationDebugCommand extends ContainerAwareCommand { const MESSAGE_MISSING = 0; const MESSAGE_UNUSED = 1; const MESSAGE_EQUALS_FALLBACK = 2; protected static $defaultName = 'debug:translation'; private $translator; private $reader; private $extractor; private $defaultTransPath; private $defaultViewsPath; public function __construct($translator = null, TranslationReaderInterface $reader = null, ExtractorInterface $extractor = null, $defaultTransPath = null, $defaultViewsPath = null) { if (!$translator instanceof TranslatorInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, TranslatorInterface::class), E_USER_DEPRECATED); parent::__construct($translator); return; } parent::__construct(); $this->translator = $translator; $this->reader = $reader; $this->extractor = $extractor; $this->defaultTransPath = $defaultTransPath; $this->defaultViewsPath = $defaultViewsPath; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'), new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Displays only missing messages'), new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Displays only unused messages'), new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'), )) ->setDescription('Displays translation messages information') ->setHelp(<<<'EOF' The <info>%command.name%</info> command helps finding unused or missing translation messages and comparing them with the fallback ones by inspecting the templates and translation files of a given bundle or the app folder. You can display information about bundle translations in a specific locale: <info>php %command.full_name% en AcmeDemoBundle</info> You can also specify a translation domain for the search: <info>php %command.full_name% --domain=messages en AcmeDemoBundle</info> You can only display missing messages: <info>php %command.full_name% --only-missing en AcmeDemoBundle</info> You can only display unused messages: <info>php %command.full_name% --only-unused en AcmeDemoBundle</info> You can display information about app translations in a specific locale: <info>php %command.full_name% en</info> You can display information about translations in all registered bundles in a specific locale: <info>php %command.full_name% --all en</info> EOF ) ; } /** * {@inheritdoc} * * BC to be removed in 4.0 */ public function isEnabled() { if (null !== $this->translator) { return parent::isEnabled(); } if (!class_exists('Symfony\Component\Translation\Translator')) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->translator) { $this->translator = $this->getContainer()->get('translator'); $this->reader = $this->getContainer()->get('translation.reader'); $this->extractor = $this->getContainer()->get('translation.extractor'); } $io = new SymfonyStyle($input, $output); $locale = $input->getArgument('locale'); $domain = $input->getOption('domain'); /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); // Define Root Paths $transPaths = array($kernel->getRootDir().'/Resources/translations'); if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = array($kernel->getRootDir().'/Resources/views'); if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } // Override with provided Bundle info if (null !== $input->getArgument('bundle')) { try { $bundle = $kernel->getBundle($input->getArgument('bundle')); $transPaths = array($bundle->getPath().'/Resources/translations'); if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath.'/'.$bundle->getName(); } $transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName()); $viewsPaths = array($bundle->getPath().'/Resources/views'); if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName(); } $viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName()); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $transPaths = array($input->getArgument('bundle').'/Resources/translations'); $viewsPaths = array($input->getArgument('bundle').'/Resources/views'); if (!is_dir($transPaths[0])) { throw new \InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); } } } elseif ($input->getOption('all')) { foreach ($kernel->getBundles() as $bundle) { $transPaths[] = $bundle->getPath().'/Resources/translations'; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath.'/'.$bundle->getName(); } $transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName()); $viewsPaths[] = $bundle->getPath().'/Resources/views'; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName(); } $viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName()); } } // Extract used messages $extractedCatalogue = $this->extractMessages($locale, $viewsPaths); // Load defined messages $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths); // Merge defined and extracted messages to get all message ids $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue); $allMessages = $mergeOperation->getResult()->all($domain); if (null !== $domain) { $allMessages = array($domain => $allMessages); } // No defined or extracted messages if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) { $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale); if (null !== $domain) { $outputMessage .= sprintf(' and domain "%s"', $domain); } $io->getErrorStyle()->warning($outputMessage); return; } // Load the fallback catalogues $fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths); // Display header line $headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)); foreach ($fallbackCatalogues as $fallbackCatalogue) { $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale()); } $rows = array(); // Iterate all message ids and determine their state foreach ($allMessages as $domain => $messages) { foreach (array_keys($messages) as $messageId) { $value = $currentCatalogue->get($messageId, $domain); $states = array(); if ($extractedCatalogue->defines($messageId, $domain)) { if (!$currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_MISSING; } } elseif ($currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_UNUSED; } if (!in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused') || !in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) { continue; } foreach ($fallbackCatalogues as $fallbackCatalogue) { if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) { $states[] = self::MESSAGE_EQUALS_FALLBACK; break; } } $row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)); foreach ($fallbackCatalogues as $fallbackCatalogue) { $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain)); } $rows[] = $row; } } $io->table($headers, $rows); } private function formatState($state) { if (self::MESSAGE_MISSING === $state) { return '<error> missing </error>'; } if (self::MESSAGE_UNUSED === $state) { return '<comment> unused </comment>'; } if (self::MESSAGE_EQUALS_FALLBACK === $state) { return '<info> fallback </info>'; } return $state; } private function formatStates(array $states) { $result = array(); foreach ($states as $state) { $result[] = $this->formatState($state); } return implode(' ', $result); } private function formatId($id) { return sprintf('<fg=cyan;options=bold>%s</>', $id); } private function sanitizeString($string, $length = 40) { $string = trim(preg_replace('/\s+/', ' ', $string)); if (false !== $encoding = mb_detect_encoding($string, null, true)) { if (mb_strlen($string, $encoding) > $length) { return mb_substr($string, 0, $length - 3, $encoding).'...'; } } elseif (strlen($string) > $length) { return substr($string, 0, $length - 3).'...'; } return $string; } /** * @param string $locale * @param array $transPaths * * @return MessageCatalogue */ private function extractMessages($locale, $transPaths) { $extractedCatalogue = new MessageCatalogue($locale); foreach ($transPaths as $path) { if (is_dir($path)) { $this->extractor->extract($path, $extractedCatalogue); } } return $extractedCatalogue; } /** * @param string $locale * @param array $transPaths * * @return MessageCatalogue */ private function loadCurrentMessages($locale, $transPaths) { $currentCatalogue = new MessageCatalogue($locale); foreach ($transPaths as $path) { if (is_dir($path)) { $this->reader->read($path, $currentCatalogue); } } return $currentCatalogue; } /** * @param string $locale * @param array $transPaths * * @return MessageCatalogue[] */ private function loadFallbackCatalogues($locale, $transPaths) { $fallbackCatalogues = array(); if ($this->translator instanceof Translator || $this->translator instanceof DataCollectorTranslator || $this->translator instanceof LoggingTranslator) { foreach ($this->translator->getFallbackLocales() as $fallbackLocale) { if ($fallbackLocale === $locale) { continue; } $fallbackCatalogue = new MessageCatalogue($fallbackLocale); foreach ($transPaths as $path) { if (is_dir($path)) { $this->reader->read($path, $fallbackCatalogue); } } $fallbackCatalogues[] = $fallbackCatalogue; } } return $fallbackCatalogues; } } ����������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php���������������0000664�0000000�0000000�00000032560�13247321071�0031020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\Catalogue\TargetOperation; use Symfony\Component\Translation\Catalogue\MergeOperation; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Translation\Extractor\ExtractorInterface; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Reader\TranslationReaderInterface; use Symfony\Component\Translation\Writer\TranslationWriterInterface; /** * A command that parses templates to extract translation messages and adds them * into the translation files. * * @author Michel Salib <michelsalib@hotmail.com> * * @final since version 3.4 */ class TranslationUpdateCommand extends ContainerAwareCommand { protected static $defaultName = 'translation:update'; private $writer; private $reader; private $extractor; private $defaultLocale; private $defaultTransPath; private $defaultViewsPath; /** * @param TranslationWriterInterface $writer * @param TranslationReaderInterface $reader * @param ExtractorInterface $extractor * @param string $defaultLocale * @param string $defaultTransPath * @param string $defaultViewsPath */ public function __construct($writer = null, TranslationReaderInterface $reader = null, ExtractorInterface $extractor = null, $defaultLocale = null, $defaultTransPath = null, $defaultViewsPath = null) { if (!$writer instanceof TranslationWriterInterface) { @trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, TranslationWriterInterface::class), E_USER_DEPRECATED); parent::__construct($writer); return; } parent::__construct(); $this->writer = $writer; $this->reader = $reader; $this->extractor = $extractor; $this->defaultLocale = $defaultLocale; $this->defaultTransPath = $defaultTransPath; $this->defaultViewsPath = $defaultViewsPath; } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'), new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'), new InputOption('no-prefix', null, InputOption::VALUE_NONE, '[DEPRECATED] If set, no prefix is added to the translations'), new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'yml'), new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'), new InputOption('force', null, InputOption::VALUE_NONE, 'Should the update be done'), new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Should backup be disabled'), new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'), )) ->setDescription('Updates the translation file') ->setHelp(<<<'EOF' The <info>%command.name%</info> command extracts translation strings from templates of a given bundle or the app folder. It can display them or merge the new ones into the translation files. When new translation strings are found it can automatically add a prefix to the translation message. Example running against a Bundle (AcmeBundle) <info>php %command.full_name% --dump-messages en AcmeBundle</info> <info>php %command.full_name% --force --prefix="new_" fr AcmeBundle</info> Example running against app messages (app/Resources folder) <info>php %command.full_name% --dump-messages en</info> <info>php %command.full_name% --force --prefix="new_" fr</info> EOF ) ; } /** * {@inheritdoc} * * BC to be removed in 4.0 */ public function isEnabled() { if (null !== $this->writer) { return parent::isEnabled(); } if (!class_exists('Symfony\Component\Translation\Translator')) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // BC to be removed in 4.0 if (null === $this->writer) { $this->writer = $this->getContainer()->get('translation.writer'); $this->reader = $this->getContainer()->get('translation.reader'); $this->extractor = $this->getContainer()->get('translation.extractor'); $this->defaultLocale = $this->getContainer()->getParameter('kernel.default_locale'); } $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); // check presence of force or dump-message if (true !== $input->getOption('force') && true !== $input->getOption('dump-messages')) { $errorIo->error('You must choose one of --force or --dump-messages'); return 1; } // check format $supportedFormats = $this->writer->getFormats(); if (!in_array($input->getOption('output-format'), $supportedFormats)) { $errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.')); return 1; } /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); // Define Root Paths $transPaths = array($kernel->getRootDir().'/Resources/translations'); if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = array($kernel->getRootDir().'/Resources/views'); if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } $currentName = 'app folder'; // Override with provided Bundle info if (null !== $input->getArgument('bundle')) { try { $foundBundle = $kernel->getBundle($input->getArgument('bundle')); $transPaths = array($foundBundle->getPath().'/Resources/translations'); if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName(); } $transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $foundBundle->getName()); $viewsPaths = array($foundBundle->getPath().'/Resources/views'); if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName(); } $viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $foundBundle->getName()); $currentName = $foundBundle->getName(); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $transPaths = array($input->getArgument('bundle').'/Resources/translations'); $viewsPaths = array($input->getArgument('bundle').'/Resources/views'); $currentName = $transPaths[0]; if (!is_dir($transPaths[0])) { throw new \InvalidArgumentException(sprintf('<error>"%s" is neither an enabled bundle nor a directory.</error>', $transPaths[0])); } } } $errorIo->title('Translation Messages Extractor and Dumper'); $errorIo->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName)); // load any messages from templates $extractedCatalogue = new MessageCatalogue($input->getArgument('locale')); $errorIo->comment('Parsing templates...'); $prefix = $input->getOption('prefix'); // @deprecated since version 3.4, to be removed in 4.0 along with the --no-prefix option if ($input->getOption('no-prefix')) { @trigger_error('The "--no-prefix" option is deprecated since Symfony 3.4 and will be removed in 4.0. Use the "--prefix" option with an empty string as value instead.', E_USER_DEPRECATED); $prefix = ''; } $this->extractor->setPrefix($prefix); foreach ($viewsPaths as $path) { if (is_dir($path)) { $this->extractor->extract($path, $extractedCatalogue); } } // load any existing messages from the translation files $currentCatalogue = new MessageCatalogue($input->getArgument('locale')); $errorIo->comment('Loading translation files...'); foreach ($transPaths as $path) { if (is_dir($path)) { $this->reader->read($path, $currentCatalogue); } } if (null !== $domain = $input->getOption('domain')) { $currentCatalogue = $this->filterCatalogue($currentCatalogue, $domain); $extractedCatalogue = $this->filterCatalogue($extractedCatalogue, $domain); } // process catalogues $operation = $input->getOption('clean') ? new TargetOperation($currentCatalogue, $extractedCatalogue) : new MergeOperation($currentCatalogue, $extractedCatalogue); // Exit if no messages found. if (!count($operation->getDomains())) { $errorIo->warning('No translation messages were found.'); return; } $resultMessage = 'Translation files were successfully updated'; // show compiled list of messages if (true === $input->getOption('dump-messages')) { $extractedMessagesCount = 0; $io->newLine(); foreach ($operation->getDomains() as $domain) { $newKeys = array_keys($operation->getNewMessages($domain)); $allKeys = array_keys($operation->getMessages($domain)); $list = array_merge( array_diff($allKeys, $newKeys), array_map(function ($id) { return sprintf('<fg=green>%s</>', $id); }, $newKeys), array_map(function ($id) { return sprintf('<fg=red>%s</>', $id); }, array_keys($operation->getObsoleteMessages($domain))) ); $domainMessagesCount = count($list); $io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : '')); $io->listing($list); $extractedMessagesCount += $domainMessagesCount; } if ('xlf' == $input->getOption('output-format')) { $errorIo->comment('Xliff output version is <info>1.2</info>'); } $resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was'); } if (true === $input->getOption('no-backup')) { $this->writer->disableBackup(); } // save the files if (true === $input->getOption('force')) { $errorIo->comment('Writing files...'); $bundleTransPath = false; foreach ($transPaths as $path) { if (is_dir($path)) { $bundleTransPath = $path; } } if (!$bundleTransPath) { $bundleTransPath = end($transPaths); } $this->writer->write($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale)); if (true === $input->getOption('dump-messages')) { $resultMessage .= ' and translation files were updated'; } } $errorIo->success($resultMessage.'.'); } private function filterCatalogue(MessageCatalogue $catalogue, $domain) { $filteredCatalogue = new MessageCatalogue($catalogue->getLocale()); if ($messages = $catalogue->all($domain)) { $filteredCatalogue->add($messages, $domain); } foreach ($catalogue->getResources() as $resource) { $filteredCatalogue->addResource($resource); } if ($metadata = $catalogue->getMetadata('', $domain)) { foreach ($metadata as $k => $v) { $filteredCatalogue->setMetadata($k, $v, $domain); } } return $filteredCatalogue; } } ������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php��������������������0000664�0000000�0000000�00000004566�13247321071�0030024�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Workflow\Dumper\GraphvizDumper; use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper; use Symfony\Component\Workflow\Marking; /** * @author Grégoire Pineau <lyrixx@lyrixx.info> * * @final since version 3.4 */ class WorkflowDumpCommand extends ContainerAwareCommand { protected static $defaultName = 'workflow:dump'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'), new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'), )) ->setDescription('Dump a workflow') ->setHelp(<<<'EOF' The <info>%command.name%</info> command dumps the graphical representation of a workflow in DOT format %command.full_name% <workflow name> | dot -Tpng > workflow.png EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getApplication()->getKernel()->getContainer(); $serviceId = $input->getArgument('name'); if ($container->has('workflow.'.$serviceId)) { $workflow = $container->get('workflow.'.$serviceId); $dumper = new GraphvizDumper(); } elseif ($container->has('state_machine.'.$serviceId)) { $workflow = $container->get('state_machine.'.$serviceId); $dumper = new StateMachineGraphvizDumper(); } else { throw new \InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $serviceId)); } $marking = new Marking(); foreach ($input->getArgument('marking') as $place) { $marking->mark($place); } $output->writeln($dumper->dump($workflow->getDefinition(), $marking)); } } ������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php�����������������������0000664�0000000�0000000�00000004042�13247321071�0027250�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand; /** * Validates XLIFF files syntax and outputs encountered errors. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * @author Robin Chalas <robin.chalas@gmail.com> * @author Javier Eguiluz <javier.eguiluz@gmail.com> * * @final since version 3.4 */ class XliffLintCommand extends BaseLintCommand { protected static $defaultName = 'lint:xliff'; public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) { if (func_num_args()) { @trigger_error(sprintf('Passing a constructor argument in "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); } if (null === $directoryIteratorProvider) { $directoryIteratorProvider = function ($directory, $default) { if (!is_dir($directory)) { $directory = $this->getApplication()->getKernel()->locateResource($directory); } return $default($directory); }; } if (null === $isReadableProvider) { $isReadableProvider = function ($fileOrDirectory, $default) { return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); }; } parent::__construct($name, $directoryIteratorProvider, $isReadableProvider); } /** * {@inheritdoc} */ protected function configure() { parent::configure(); $this->setHelp($this->getHelp().<<<'EOF' Or find all files in a bundle: <info>php %command.full_name% @AcmeDemoBundle</info> EOF ); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php������������������������0000664�0000000�0000000�00000003732�13247321071�0027107�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand; /** * Validates YAML files syntax and outputs encountered errors. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * @author Robin Chalas <robin.chalas@gmail.com> * * @final since version 3.4 */ class YamlLintCommand extends BaseLintCommand { protected static $defaultName = 'lint:yaml'; public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) { if (func_num_args()) { @trigger_error(sprintf('Passing a constructor argument in "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); } if (null === $directoryIteratorProvider) { $directoryIteratorProvider = function ($directory, $default) { if (!is_dir($directory)) { $directory = $this->getApplication()->getKernel()->locateResource($directory); } return $default($directory); }; } if (null === $isReadableProvider) { $isReadableProvider = function ($fileOrDirectory, $default) { return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); }; } parent::__construct($name, $directoryIteratorProvider, $isReadableProvider); } /** * {@inheritdoc} */ protected function configure() { parent::configure(); $this->setHelp($this->getHelp().<<<'EOF' Or find all files in a bundle: <info>php %command.full_name% @AcmeDemoBundle</info> EOF ); } } ��������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/�������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023365�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Application.php����������������������������0000664�0000000�0000000�00000013310�13247321071�0026337�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * @author Fabien Potencier <fabien@symfony.com> */ class Application extends BaseApplication { private $kernel; private $commandsRegistered = false; private $registrationErrors = array(); public function __construct(KernelInterface $kernel) { $this->kernel = $kernel; parent::__construct('Symfony', Kernel::VERSION); $inputDefinition = $this->getDefinition(); $inputDefinition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment())); $inputDefinition->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.')); } /** * Gets the Kernel associated with this Console. * * @return KernelInterface A KernelInterface instance */ public function getKernel() { return $this->kernel; } /** * Runs the current application. * * @return int 0 if everything went fine, or an error code */ public function doRun(InputInterface $input, OutputInterface $output) { $this->kernel->boot(); $this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher')); $this->registerCommands(); if ($this->registrationErrors) { $this->renderRegistrationErrors($input, $output); } return parent::doRun($input, $output); } /** * {@inheritdoc} */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($this->registrationErrors) { $this->renderRegistrationErrors($input, $output); } return parent::doRunCommand($command, $input, $output); } /** * {@inheritdoc} */ public function find($name) { $this->registerCommands(); return parent::find($name); } /** * {@inheritdoc} */ public function get($name) { $this->registerCommands(); $command = parent::get($name); if ($command instanceof ContainerAwareInterface) { $command->setContainer($this->kernel->getContainer()); } return $command; } /** * {@inheritdoc} */ public function all($namespace = null) { $this->registerCommands(); return parent::all($namespace); } /** * {@inheritdoc} */ public function getLongVersion() { return parent::getLongVersion().sprintf(' (kernel: <comment>%s</>, env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getName(), $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false'); } public function add(Command $command) { $this->registerCommands(); return parent::add($command); } protected function registerCommands() { if ($this->commandsRegistered) { return; } $this->commandsRegistered = true; $this->kernel->boot(); $container = $this->kernel->getContainer(); foreach ($this->kernel->getBundles() as $bundle) { if ($bundle instanceof Bundle) { try { $bundle->registerCommands($this); } catch (\Exception $e) { $this->registrationErrors[] = $e; } catch (\Throwable $e) { $this->registrationErrors[] = new FatalThrowableError($e); } } } if ($container->has('console.command_loader')) { $this->setCommandLoader($container->get('console.command_loader')); } if ($container->hasParameter('console.command.ids')) { $lazyCommandIds = $container->hasParameter('console.lazy_command.ids') ? $container->getParameter('console.lazy_command.ids') : array(); foreach ($container->getParameter('console.command.ids') as $id) { if (!isset($lazyCommandIds[$id])) { try { $this->add($container->get($id)); } catch (\Exception $e) { $this->registrationErrors[] = $e; } catch (\Throwable $e) { $this->registrationErrors[] = new FatalThrowableError($e); } } } } } private function renderRegistrationErrors(InputInterface $input, OutputInterface $output) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } (new SymfonyStyle($input, $output))->warning('Some commands could not be registered:'); foreach ($this->registrationErrors as $error) { $this->doRenderException($error, $output); } $this->registrationErrors = array(); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/��������������������������������0000775�0000000�0000000�00000000000�13247321071�0025503�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php������������������0000664�0000000�0000000�00000021022�13247321071�0030327�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\Console\Descriptor\DescriptorInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ abstract class Descriptor implements DescriptorInterface { /** * @var OutputInterface */ protected $output; /** * {@inheritdoc} */ public function describe(OutputInterface $output, $object, array $options = array()) { $this->output = $output; switch (true) { case $object instanceof RouteCollection: $this->describeRouteCollection($object, $options); break; case $object instanceof Route: $this->describeRoute($object, $options); break; case $object instanceof ParameterBag: $this->describeContainerParameters($object, $options); break; case $object instanceof ContainerBuilder && isset($options['group_by']) && 'tags' === $options['group_by']: $this->describeContainerTags($object, $options); break; case $object instanceof ContainerBuilder && isset($options['id']): $this->describeContainerService($this->resolveServiceDefinition($object, $options['id']), $options, $object); break; case $object instanceof ContainerBuilder && isset($options['parameter']): $this->describeContainerParameter($object->resolveEnvPlaceholders($object->getParameter($options['parameter'])), $options); break; case $object instanceof ContainerBuilder: $this->describeContainerServices($object, $options); break; case $object instanceof Definition: $this->describeContainerDefinition($object, $options); break; case $object instanceof Alias: $this->describeContainerAlias($object, $options); break; case $object instanceof EventDispatcherInterface: $this->describeEventDispatcherListeners($object, $options); break; case is_callable($object): $this->describeCallable($object, $options); break; default: throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); } } /** * Returns the output. * * @return OutputInterface The output */ protected function getOutput() { return $this->output; } /** * Writes content to output. * * @param string $content * @param bool $decorated */ protected function write($content, $decorated = false) { $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); } /** * Describes an InputArgument instance. */ abstract protected function describeRouteCollection(RouteCollection $routes, array $options = array()); /** * Describes an InputOption instance. */ abstract protected function describeRoute(Route $route, array $options = array()); /** * Describes container parameters. */ abstract protected function describeContainerParameters(ParameterBag $parameters, array $options = array()); /** * Describes container tags. */ abstract protected function describeContainerTags(ContainerBuilder $builder, array $options = array()); /** * Describes a container service by its name. * * Common options are: * * name: name of described service * * @param Definition|Alias|object $service * @param array $options * @param ContainerBuilder|null $builder */ abstract protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null); /** * Describes container services. * * Common options are: * * tag: filters described services by given tag */ abstract protected function describeContainerServices(ContainerBuilder $builder, array $options = array()); /** * Describes a service definition. */ abstract protected function describeContainerDefinition(Definition $definition, array $options = array()); /** * Describes a service alias. */ abstract protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null); /** * Describes a container parameter. */ abstract protected function describeContainerParameter($parameter, array $options = array()); /** * Describes event dispatcher listeners. * * Common options are: * * name: name of listened event */ abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()); /** * Describes a callable. * * @param callable $callable * @param array $options */ abstract protected function describeCallable($callable, array $options = array()); /** * Formats a value as string. * * @param mixed $value * * @return string */ protected function formatValue($value) { if (is_object($value)) { return sprintf('object(%s)', get_class($value)); } if (is_string($value)) { return $value; } return preg_replace("/\n\s*/s", '', var_export($value, true)); } /** * Formats a parameter. * * @param mixed $value * * @return string */ protected function formatParameter($value) { if (is_bool($value) || is_array($value) || (null === $value)) { $jsonString = json_encode($value); if (preg_match('/^(.{60})./us', $jsonString, $matches)) { return $matches[1].'...'; } return $jsonString; } return (string) $value; } /** * @param ContainerBuilder $builder * @param string $serviceId * * @return mixed */ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceId) { if ($builder->hasDefinition($serviceId)) { return $builder->getDefinition($serviceId); } // Some service IDs don't have a Definition, they're simply an Alias if ($builder->hasAlias($serviceId)) { return $builder->getAlias($serviceId); } // the service has been injected in some special way, just return the service return $builder->get($serviceId); } /** * @param ContainerBuilder $builder * @param bool $showPrivate * * @return array */ protected function findDefinitionsByTag(ContainerBuilder $builder, $showPrivate) { $definitions = array(); $tags = $builder->findTags(); asort($tags); foreach ($tags as $tag) { foreach ($builder->findTaggedServiceIds($tag) as $serviceId => $attributes) { $definition = $this->resolveServiceDefinition($builder, $serviceId); if (!$definition instanceof Definition || !$showPrivate && !$definition->isPublic()) { continue; } if (!isset($definitions[$tag])) { $definitions[$tag] = array(); } $definitions[$tag][$serviceId] = $definition; } } return $definitions; } protected function sortParameters(ParameterBag $parameters) { $parameters = $parameters->all(); ksort($parameters); return $parameters; } protected function sortServiceIds(array $serviceIds) { asort($serviceIds); return $serviceIds; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php��������������0000664�0000000�0000000�00000033620�13247321071�0031170�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ class JsonDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeRouteCollection(RouteCollection $routes, array $options = array()) { $data = array(); foreach ($routes->all() as $name => $route) { $data[$name] = $this->getRouteData($route); } $this->writeData($data, $options); } /** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $this->writeData($this->getRouteData($route), $options); } /** * {@inheritdoc} */ protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) { $this->writeData($this->sortParameters($parameters), $options); } /** * {@inheritdoc} */ protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) { $showPrivate = isset($options['show_private']) && $options['show_private']; $data = array(); foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) { $data[$tag] = array(); foreach ($definitions as $definition) { $data[$tag][] = $this->getContainerDefinitionData($definition, true); } } $this->writeData($data, $options); } /** * {@inheritdoc} */ protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } if ($service instanceof Alias) { $this->describeContainerAlias($service, $options, $builder); } elseif ($service instanceof Definition) { $this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options); } else { $this->writeData(get_class($service), $options); } } /** * {@inheritdoc} */ protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) { $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); $showPrivate = isset($options['show_private']) && $options['show_private']; $omitTags = isset($options['omit_tags']) && $options['omit_tags']; $showArguments = isset($options['show_arguments']) && $options['show_arguments']; $data = array('definitions' => array(), 'aliases' => array(), 'services' => array()); if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); } foreach ($this->sortServiceIds($serviceIds) as $serviceId) { $service = $this->resolveServiceDefinition($builder, $serviceId); if ($service instanceof Alias) { if ($showPrivate || ($service->isPublic() && !$service->isPrivate())) { $data['aliases'][$serviceId] = $this->getContainerAliasData($service); } } elseif ($service instanceof Definition) { if (($showPrivate || ($service->isPublic() && !$service->isPrivate()))) { $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments); } } else { $data['services'][$serviceId] = get_class($service); } } $this->writeData($data, $options); } /** * {@inheritdoc} */ protected function describeContainerDefinition(Definition $definition, array $options = array()) { $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options); } /** * {@inheritdoc} */ protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) { if (!$builder) { return $this->writeData($this->getContainerAliasData($alias), $options); } $this->writeData( array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])), array_merge($options, array('id' => (string) $alias)) ); } /** * {@inheritdoc} */ protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) { $this->writeData($this->getEventDispatcherListenersData($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null), $options); } /** * {@inheritdoc} */ protected function describeCallable($callable, array $options = array()) { $this->writeData($this->getCallableData($callable, $options), $options); } /** * {@inheritdoc} */ protected function describeContainerParameter($parameter, array $options = array()) { $key = isset($options['parameter']) ? $options['parameter'] : ''; $this->writeData(array($key => $parameter), $options); } /** * Writes data as json. * * @return array|string */ private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } /** * @return array */ protected function getRouteData(Route $route) { return array( 'path' => $route->getPath(), 'pathRegex' => $route->compile()->getRegex(), 'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY', 'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '', 'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', 'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', 'class' => get_class($route), 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions(), ); } /** * @param Definition $definition * @param bool $omitTags * * @return array */ private function getContainerDefinitionData(Definition $definition, $omitTags = false, $showArguments = false) { $data = array( 'class' => (string) $definition->getClass(), 'public' => $definition->isPublic() && !$definition->isPrivate(), 'synthetic' => $definition->isSynthetic(), 'lazy' => $definition->isLazy(), 'shared' => $definition->isShared(), 'abstract' => $definition->isAbstract(), 'autowire' => $definition->isAutowired(), 'autoconfigure' => $definition->isAutoconfigured(), ); // forward compatibility with DependencyInjection component in version 4.0 if (method_exists($definition, 'getAutowiringTypes')) { foreach ($definition->getAutowiringTypes(false) as $autowiringType) { $data['autowiring_types'][] = $autowiringType; } } if ($showArguments) { $data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $showArguments); } $data['file'] = $definition->getFile(); if ($factory = $definition->getFactory()) { if (is_array($factory)) { if ($factory[0] instanceof Reference) { $data['factory_service'] = (string) $factory[0]; } elseif ($factory[0] instanceof Definition) { throw new \InvalidArgumentException('Factory is not describable.'); } else { $data['factory_class'] = $factory[0]; } $data['factory_method'] = $factory[1]; } else { $data['factory_function'] = $factory; } } $calls = $definition->getMethodCalls(); if (count($calls) > 0) { $data['calls'] = array(); foreach ($calls as $callData) { $data['calls'][] = $callData[0]; } } if (!$omitTags) { $data['tags'] = array(); foreach ($definition->getTags() as $tagName => $tagData) { foreach ($tagData as $parameters) { $data['tags'][] = array('name' => $tagName, 'parameters' => $parameters); } } } return $data; } /** * @return array */ private function getContainerAliasData(Alias $alias) { return array( 'service' => (string) $alias, 'public' => $alias->isPublic() && !$alias->isPrivate(), ); } /** * @param EventDispatcherInterface $eventDispatcher * @param string|null $event * * @return array */ private function getEventDispatcherListenersData(EventDispatcherInterface $eventDispatcher, $event = null) { $data = array(); $registeredListeners = $eventDispatcher->getListeners($event); if (null !== $event) { foreach ($registeredListeners as $listener) { $l = $this->getCallableData($listener); $l['priority'] = $eventDispatcher->getListenerPriority($event, $listener); $data[] = $l; } } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { foreach ($eventListeners as $eventListener) { $l = $this->getCallableData($eventListener); $l['priority'] = $eventDispatcher->getListenerPriority($eventListened, $eventListener); $data[$eventListened][] = $l; } } } return $data; } /** * @param callable $callable * @param array $options * * @return array */ private function getCallableData($callable, array $options = array()) { $data = array(); if (is_array($callable)) { $data['type'] = 'function'; if (is_object($callable[0])) { $data['name'] = $callable[1]; $data['class'] = get_class($callable[0]); } else { if (0 !== strpos($callable[1], 'parent::')) { $data['name'] = $callable[1]; $data['class'] = $callable[0]; $data['static'] = true; } else { $data['name'] = substr($callable[1], 8); $data['class'] = $callable[0]; $data['static'] = true; $data['parent'] = true; } } return $data; } if (is_string($callable)) { $data['type'] = 'function'; if (false === strpos($callable, '::')) { $data['name'] = $callable; } else { $callableParts = explode('::', $callable); $data['name'] = $callableParts[1]; $data['class'] = $callableParts[0]; $data['static'] = true; } return $data; } if ($callable instanceof \Closure) { $data['type'] = 'closure'; return $data; } if (method_exists($callable, '__invoke')) { $data['type'] = 'object'; $data['name'] = get_class($callable); return $data; } throw new \InvalidArgumentException('Callable is not describable.'); } private function describeValue($value, $omitTags, $showArguments) { if (is_array($value)) { $data = array(); foreach ($value as $k => $v) { $data[$k] = $this->describeValue($v, $omitTags, $showArguments); } return $data; } if ($value instanceof ServiceClosureArgument) { $value = $value->getValues()[0]; } if ($value instanceof Reference) { return array( 'type' => 'service', 'id' => (string) $value, ); } if ($value instanceof ArgumentInterface) { return $this->describeValue($value->getValues(), $omitTags, $showArguments); } if ($value instanceof Definition) { return $this->getContainerDefinitionData($value, $omitTags, $showArguments); } return $value; } } ����������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php����������0000664�0000000�0000000�00000034762�13247321071�0032051�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ class MarkdownDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeRouteCollection(RouteCollection $routes, array $options = array()) { $first = true; foreach ($routes->all() as $name => $route) { if ($first) { $first = false; } else { $this->write("\n\n"); } $this->describeRoute($route, array('name' => $name)); } $this->write("\n"); } /** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $output = '- Path: '.$route->getPath() ."\n".'- Path Regex: '.$route->compile()->getRegex() ."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY') ."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '') ."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY') ."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY') ."\n".'- Class: '.get_class($route) ."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults()) ."\n".'- Requirements: '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM') ."\n".'- Options: '.$this->formatRouterConfig($route->getOptions()); $this->write(isset($options['name']) ? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output : $output); $this->write("\n"); } /** * {@inheritdoc} */ protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) { $this->write("Container parameters\n====================\n"); foreach ($this->sortParameters($parameters) as $key => $value) { $this->write(sprintf("\n- `%s`: `%s`", $key, $this->formatParameter($value))); } } /** * {@inheritdoc} */ protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) { $showPrivate = isset($options['show_private']) && $options['show_private']; $this->write("Container tags\n=============="); foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) { $this->write("\n\n".$tag."\n".str_repeat('-', strlen($tag))); foreach ($definitions as $serviceId => $definition) { $this->write("\n\n"); $this->describeContainerDefinition($definition, array('omit_tags' => true, 'id' => $serviceId)); } } } /** * {@inheritdoc} */ protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } $childOptions = array_merge($options, array('id' => $options['id'], 'as_array' => true)); if ($service instanceof Alias) { $this->describeContainerAlias($service, $childOptions, $builder); } elseif ($service instanceof Definition) { $this->describeContainerDefinition($service, $childOptions); } else { $this->write(sprintf('**`%s`:** `%s`', $options['id'], get_class($service))); } } /** * {@inheritdoc} */ protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) { $showPrivate = isset($options['show_private']) && $options['show_private']; $title = $showPrivate ? 'Public and private services' : 'Public services'; if (isset($options['tag'])) { $title .= ' with tag `'.$options['tag'].'`'; } $this->write($title."\n".str_repeat('=', strlen($title))); $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); $showArguments = isset($options['show_arguments']) && $options['show_arguments']; $services = array('definitions' => array(), 'aliases' => array(), 'services' => array()); if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); } foreach ($this->sortServiceIds($serviceIds) as $serviceId) { $service = $this->resolveServiceDefinition($builder, $serviceId); if ($service instanceof Alias) { if ($showPrivate || ($service->isPublic() && !$service->isPrivate())) { $services['aliases'][$serviceId] = $service; } } elseif ($service instanceof Definition) { if (($showPrivate || ($service->isPublic() && !$service->isPrivate()))) { $services['definitions'][$serviceId] = $service; } } else { $services['services'][$serviceId] = $service; } } if (!empty($services['definitions'])) { $this->write("\n\nDefinitions\n-----------\n"); foreach ($services['definitions'] as $id => $service) { $this->write("\n"); $this->describeContainerDefinition($service, array('id' => $id, 'show_arguments' => $showArguments)); } } if (!empty($services['aliases'])) { $this->write("\n\nAliases\n-------\n"); foreach ($services['aliases'] as $id => $service) { $this->write("\n"); $this->describeContainerAlias($service, array('id' => $id)); } } if (!empty($services['services'])) { $this->write("\n\nServices\n--------\n"); foreach ($services['services'] as $id => $service) { $this->write("\n"); $this->write(sprintf('- `%s`: `%s`', $id, get_class($service))); } } } /** * {@inheritdoc} */ protected function describeContainerDefinition(Definition $definition, array $options = array()) { $output = '- Class: `'.$definition->getClass().'`' ."\n".'- Public: '.($definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no') ."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no') ."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no') ."\n".'- Shared: '.($definition->isShared() ? 'yes' : 'no') ."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no') ."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no') ."\n".'- Autoconfigured: '.($definition->isAutoconfigured() ? 'yes' : 'no') ; // forward compatibility with DependencyInjection component in version 4.0 if (method_exists($definition, 'getAutowiringTypes')) { foreach ($definition->getAutowiringTypes(false) as $autowiringType) { $output .= "\n".'- Autowiring Type: `'.$autowiringType.'`'; } } if (isset($options['show_arguments']) && $options['show_arguments']) { $output .= "\n".'- Arguments: '.($definition->getArguments() ? 'yes' : 'no'); } if ($definition->getFile()) { $output .= "\n".'- File: `'.$definition->getFile().'`'; } if ($factory = $definition->getFactory()) { if (is_array($factory)) { if ($factory[0] instanceof Reference) { $output .= "\n".'- Factory Service: `'.$factory[0].'`'; } elseif ($factory[0] instanceof Definition) { throw new \InvalidArgumentException('Factory is not describable.'); } else { $output .= "\n".'- Factory Class: `'.$factory[0].'`'; } $output .= "\n".'- Factory Method: `'.$factory[1].'`'; } else { $output .= "\n".'- Factory Function: `'.$factory.'`'; } } $calls = $definition->getMethodCalls(); foreach ($calls as $callData) { $output .= "\n".'- Call: `'.$callData[0].'`'; } if (!(isset($options['omit_tags']) && $options['omit_tags'])) { foreach ($definition->getTags() as $tagName => $tagData) { foreach ($tagData as $parameters) { $output .= "\n".'- Tag: `'.$tagName.'`'; foreach ($parameters as $name => $value) { $output .= "\n".' - '.ucfirst($name).': '.$value; } } } } $this->write(isset($options['id']) ? sprintf("### %s\n\n%s\n", $options['id'], $output) : $output); } /** * {@inheritdoc} */ protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) { $output = '- Service: `'.$alias.'`' ."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no'); if (!isset($options['id'])) { return $this->write($output); } $this->write(sprintf("### %s\n\n%s\n", $options['id'], $output)); if (!$builder) { return; } $this->write("\n"); $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, array('id' => (string) $alias))); } /** * {@inheritdoc} */ protected function describeContainerParameter($parameter, array $options = array()) { $this->write(isset($options['parameter']) ? sprintf("%s\n%s\n\n%s", $options['parameter'], str_repeat('=', strlen($options['parameter'])), $this->formatParameter($parameter)) : $parameter); } /** * {@inheritdoc} */ protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) { $event = array_key_exists('event', $options) ? $options['event'] : null; $title = 'Registered listeners'; if (null !== $event) { $title .= sprintf(' for event `%s` ordered by descending priority', $event); } $this->write(sprintf('# %s', $title)."\n"); $registeredListeners = $eventDispatcher->getListeners($event); if (null !== $event) { foreach ($registeredListeners as $order => $listener) { $this->write("\n".sprintf('## Listener %d', $order + 1)."\n"); $this->describeCallable($listener); $this->write(sprintf('- Priority: `%d`', $eventDispatcher->getListenerPriority($event, $listener))."\n"); } } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { $this->write("\n".sprintf('## %s', $eventListened)."\n"); foreach ($eventListeners as $order => $eventListener) { $this->write("\n".sprintf('### Listener %d', $order + 1)."\n"); $this->describeCallable($eventListener); $this->write(sprintf('- Priority: `%d`', $eventDispatcher->getListenerPriority($eventListened, $eventListener))."\n"); } } } } /** * {@inheritdoc} */ protected function describeCallable($callable, array $options = array()) { $string = ''; if (is_array($callable)) { $string .= "\n- Type: `function`"; if (is_object($callable[0])) { $string .= "\n".sprintf('- Name: `%s`', $callable[1]); $string .= "\n".sprintf('- Class: `%s`', get_class($callable[0])); } else { if (0 !== strpos($callable[1], 'parent::')) { $string .= "\n".sprintf('- Name: `%s`', $callable[1]); $string .= "\n".sprintf('- Class: `%s`', $callable[0]); $string .= "\n- Static: yes"; } else { $string .= "\n".sprintf('- Name: `%s`', substr($callable[1], 8)); $string .= "\n".sprintf('- Class: `%s`', $callable[0]); $string .= "\n- Static: yes"; $string .= "\n- Parent: yes"; } } return $this->write($string."\n"); } if (is_string($callable)) { $string .= "\n- Type: `function`"; if (false === strpos($callable, '::')) { $string .= "\n".sprintf('- Name: `%s`', $callable); } else { $callableParts = explode('::', $callable); $string .= "\n".sprintf('- Name: `%s`', $callableParts[1]); $string .= "\n".sprintf('- Class: `%s`', $callableParts[0]); $string .= "\n- Static: yes"; } return $this->write($string."\n"); } if ($callable instanceof \Closure) { $string .= "\n- Type: `closure`"; return $this->write($string."\n"); } if (method_exists($callable, '__invoke')) { $string .= "\n- Type: `object`"; $string .= "\n".sprintf('- Name: `%s`', get_class($callable)); return $this->write($string."\n"); } throw new \InvalidArgumentException('Callable is not describable.'); } /** * @return string */ private function formatRouterConfig(array $array) { if (!$array) { return 'NONE'; } $string = ''; ksort($array); foreach ($array as $name => $value) { $string .= "\n".' - `'.$name.'`: '.$this->formatValue($value); } return $string; } } ��������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php��������������0000664�0000000�0000000�00000045747�13247321071�0031220�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ class TextDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeRouteCollection(RouteCollection $routes, array $options = array()) { $showControllers = isset($options['show_controllers']) && $options['show_controllers']; $tableHeaders = array('Name', 'Method', 'Scheme', 'Host', 'Path'); if ($showControllers) { $tableHeaders[] = 'Controller'; } $tableRows = array(); foreach ($routes->all() as $name => $route) { $row = array( $name, $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', '' !== $route->getHost() ? $route->getHost() : 'ANY', $route->getPath(), ); if ($showControllers) { $controller = $route->getDefault('_controller'); if ($controller instanceof \Closure) { $controller = 'Closure'; } elseif (is_object($controller)) { $controller = get_class($controller); } $row[] = $controller; } $tableRows[] = $row; } if (isset($options['output'])) { $options['output']->table($tableHeaders, $tableRows); } else { $table = new Table($this->getOutput()); $table->setHeaders($tableHeaders)->setRows($tableRows); $table->render(); } } /** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $tableHeaders = array('Property', 'Value'); $tableRows = array( array('Route Name', isset($options['name']) ? $options['name'] : ''), array('Path', $route->getPath()), array('Path Regex', $route->compile()->getRegex()), array('Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')), array('Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')), array('Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')), array('Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')), array('Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')), array('Class', get_class($route)), array('Defaults', $this->formatRouterConfig($route->getDefaults())), array('Options', $this->formatRouterConfig($route->getOptions())), ); if (isset($options['callable'])) { $tableRows[] = array('Callable', $options['callable']); } $table = new Table($this->getOutput()); $table->setHeaders($tableHeaders)->setRows($tableRows); $table->render(); } /** * {@inheritdoc} */ protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) { $tableHeaders = array('Parameter', 'Value'); $tableRows = array(); foreach ($this->sortParameters($parameters) as $parameter => $value) { $tableRows[] = array($parameter, $this->formatParameter($value)); } $options['output']->title('Symfony Container Parameters'); $options['output']->table($tableHeaders, $tableRows); } /** * {@inheritdoc} */ protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) { $showPrivate = isset($options['show_private']) && $options['show_private']; if ($showPrivate) { $options['output']->title('Symfony Container Public and Private Tags'); } else { $options['output']->title('Symfony Container Public Tags'); } foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) { $options['output']->section(sprintf('"%s" tag', $tag)); $options['output']->listing(array_keys($definitions)); } } /** * {@inheritdoc} */ protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } if ($service instanceof Alias) { $this->describeContainerAlias($service, $options, $builder); } elseif ($service instanceof Definition) { $this->describeContainerDefinition($service, $options); } else { $options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id'])); $options['output']->table( array('Service ID', 'Class'), array( array(isset($options['id']) ? $options['id'] : '-', get_class($service)), ) ); } } /** * {@inheritdoc} */ protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) { $showPrivate = isset($options['show_private']) && $options['show_private']; $showTag = isset($options['tag']) ? $options['tag'] : null; if ($showPrivate) { $title = 'Symfony Container Public and Private Services'; } else { $title = 'Symfony Container Public Services'; } if ($showTag) { $title .= sprintf(' Tagged with "%s" Tag', $options['tag']); } $options['output']->title($title); $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); $maxTags = array(); if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); } foreach ($serviceIds as $key => $serviceId) { $definition = $this->resolveServiceDefinition($builder, $serviceId); if ($definition instanceof Definition) { // filter out private services unless shown explicitly if (!$showPrivate && (!$definition->isPublic() || $definition->isPrivate())) { unset($serviceIds[$key]); continue; } if ($showTag) { $tags = $definition->getTag($showTag); foreach ($tags as $tag) { foreach ($tag as $key => $value) { if (!isset($maxTags[$key])) { $maxTags[$key] = strlen($key); } if (strlen($value) > $maxTags[$key]) { $maxTags[$key] = strlen($value); } } } } } elseif ($definition instanceof Alias) { if (!$showPrivate && (!$definition->isPublic() || $definition->isPrivate())) { unset($serviceIds[$key]); continue; } } } $tagsCount = count($maxTags); $tagsNames = array_keys($maxTags); $tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name')); $tableRows = array(); $rawOutput = isset($options['raw_text']) && $options['raw_text']; foreach ($this->sortServiceIds($serviceIds) as $serviceId) { $definition = $this->resolveServiceDefinition($builder, $serviceId); $styledServiceId = $rawOutput ? $serviceId : sprintf('<fg=cyan>%s</fg=cyan>', OutputFormatter::escape($serviceId)); if ($definition instanceof Definition) { if ($showTag) { foreach ($definition->getTag($showTag) as $key => $tag) { $tagValues = array(); foreach ($tagsNames as $tagName) { $tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : ''; } if (0 === $key) { $tableRows[] = array_merge(array($serviceId), $tagValues, array($definition->getClass())); } else { $tableRows[] = array_merge(array(' "'), $tagValues, array('')); } } } else { $tableRows[] = array($styledServiceId, $definition->getClass()); } } elseif ($definition instanceof Alias) { $alias = $definition; $tableRows[] = array_merge(array($styledServiceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array()); } else { $tableRows[] = array_merge(array($styledServiceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array()); } } $options['output']->table($tableHeaders, $tableRows); } /** * {@inheritdoc} */ protected function describeContainerDefinition(Definition $definition, array $options = array()) { if (isset($options['id'])) { $options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id'])); } $tableHeaders = array('Option', 'Value'); $tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-'); $tableRows[] = array('Class', $definition->getClass() ?: '-'); $omitTags = isset($options['omit_tags']) && $options['omit_tags']; if (!$omitTags && ($tags = $definition->getTags())) { $tagInformation = array(); foreach ($tags as $tagName => $tagData) { foreach ($tagData as $tagParameters) { $parameters = array_map(function ($key, $value) { return sprintf('<info>%s</info>: %s', $key, $value); }, array_keys($tagParameters), array_values($tagParameters)); $parameters = implode(', ', $parameters); if ('' === $parameters) { $tagInformation[] = sprintf('%s', $tagName); } else { $tagInformation[] = sprintf('%s (%s)', $tagName, $parameters); } } } $tagInformation = implode("\n", $tagInformation); } else { $tagInformation = '-'; } $tableRows[] = array('Tags', $tagInformation); $calls = $definition->getMethodCalls(); if (count($calls) > 0) { $callInformation = array(); foreach ($calls as $call) { $callInformation[] = $call[0]; } $tableRows[] = array('Calls', implode(', ', $callInformation)); } $tableRows[] = array('Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no'); $tableRows[] = array('Synthetic', $definition->isSynthetic() ? 'yes' : 'no'); $tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no'); $tableRows[] = array('Shared', $definition->isShared() ? 'yes' : 'no'); $tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no'); $tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no'); $tableRows[] = array('Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'); // forward compatibility with DependencyInjection component in version 4.0 if (method_exists($definition, 'getAutowiringTypes') && $autowiringTypes = $definition->getAutowiringTypes(false)) { $tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes)); } if ($definition->getFile()) { $tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-'); } if ($factory = $definition->getFactory()) { if (is_array($factory)) { if ($factory[0] instanceof Reference) { $tableRows[] = array('Factory Service', $factory[0]); } elseif ($factory[0] instanceof Definition) { throw new \InvalidArgumentException('Factory is not describable.'); } else { $tableRows[] = array('Factory Class', $factory[0]); } $tableRows[] = array('Factory Method', $factory[1]); } else { $tableRows[] = array('Factory Function', $factory); } } $showArguments = isset($options['show_arguments']) && $options['show_arguments']; $argumentsInformation = array(); if ($showArguments && ($arguments = $definition->getArguments())) { foreach ($arguments as $argument) { if ($argument instanceof ServiceClosureArgument) { $argument = $argument->getValues()[0]; } if ($argument instanceof Reference) { $argumentsInformation[] = sprintf('Service(%s)', (string) $argument); } elseif ($argument instanceof IteratorArgument) { $argumentsInformation[] = sprintf('Iterator (%d element(s))', count($argument->getValues())); } elseif ($argument instanceof Definition) { $argumentsInformation[] = 'Inlined Service'; } else { $argumentsInformation[] = is_array($argument) ? sprintf('Array (%d element(s))', count($argument)) : $argument; } } $tableRows[] = array('Arguments', implode("\n", $argumentsInformation)); } $options['output']->table($tableHeaders, $tableRows); } /** * {@inheritdoc} */ protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) { $options['output']->comment(sprintf('This service is an alias for the service <info>%s</info>', (string) $alias)); if (!$builder) { return; } return $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, array('id' => (string) $alias))); } /** * {@inheritdoc} */ protected function describeContainerParameter($parameter, array $options = array()) { $options['output']->table( array('Parameter', 'Value'), array( array($options['parameter'], $this->formatParameter($parameter), ), )); } /** * {@inheritdoc} */ protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) { $event = array_key_exists('event', $options) ? $options['event'] : null; if (null !== $event) { $title = sprintf('Registered Listeners for "%s" Event', $event); } else { $title = 'Registered Listeners Grouped by Event'; } $options['output']->title($title); $registeredListeners = $eventDispatcher->getListeners($event); if (null !== $event) { $this->renderEventListenerTable($eventDispatcher, $event, $registeredListeners, $options['output']); } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { $options['output']->section(sprintf('"%s" event', $eventListened)); $this->renderEventListenerTable($eventDispatcher, $eventListened, $eventListeners, $options['output']); } } } /** * {@inheritdoc} */ protected function describeCallable($callable, array $options = array()) { $this->writeText($this->formatCallable($callable), $options); } private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io) { $tableHeaders = array('Order', 'Callable', 'Priority'); $tableRows = array(); $order = 1; foreach ($eventListeners as $order => $listener) { $tableRows[] = array(sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)); } $io->table($tableHeaders, $tableRows); } /** * @param array $config * * @return string */ private function formatRouterConfig(array $config) { if (empty($config)) { return 'NONE'; } ksort($config); $configAsString = ''; foreach ($config as $key => $value) { $configAsString .= sprintf("\n%s: %s", $key, $this->formatValue($value)); } return trim($configAsString); } /** * @param callable $callable * * @return string */ private function formatCallable($callable) { if (is_array($callable)) { if (is_object($callable[0])) { return sprintf('%s::%s()', get_class($callable[0]), $callable[1]); } return sprintf('%s::%s()', $callable[0], $callable[1]); } if (is_string($callable)) { return sprintf('%s()', $callable); } if ($callable instanceof \Closure) { return '\Closure()'; } if (method_exists($callable, '__invoke')) { return sprintf('%s::__invoke()', get_class($callable)); } throw new \InvalidArgumentException('Callable is not describable.'); } /** * @param string $content * @param array $options */ private function writeText($content, array $options = array()) { $this->write( isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true ); } } �������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php���������������0000664�0000000�0000000�00000054140�13247321071�0031017�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ class XmlDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeRouteCollection(RouteCollection $routes, array $options = array()) { $this->writeDocument($this->getRouteCollectionDocument($routes)); } /** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $this->writeDocument($this->getRouteDocument($route, isset($options['name']) ? $options['name'] : null)); } /** * {@inheritdoc} */ protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) { $this->writeDocument($this->getContainerParametersDocument($parameters)); } /** * {@inheritdoc} */ protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) { $this->writeDocument($this->getContainerTagsDocument($builder, isset($options['show_private']) && $options['show_private'])); } /** * {@inheritdoc} */ protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } $this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder, isset($options['show_arguments']) && $options['show_arguments'])); } /** * {@inheritdoc} */ protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) { $this->writeDocument($this->getContainerServicesDocument($builder, isset($options['tag']) ? $options['tag'] : null, isset($options['show_private']) && $options['show_private'], isset($options['show_arguments']) && $options['show_arguments'], isset($options['filter']) ? $options['filter'] : null)); } /** * {@inheritdoc} */ protected function describeContainerDefinition(Definition $definition, array $options = array()) { $this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])); } /** * {@inheritdoc} */ protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, isset($options['id']) ? $options['id'] : null)->childNodes->item(0), true)); if (!$builder) { return $this->writeDocument($dom); } $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $alias), (string) $alias)->childNodes->item(0), true)); $this->writeDocument($dom); } /** * {@inheritdoc} */ protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) { $this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null)); } /** * {@inheritdoc} */ protected function describeCallable($callable, array $options = array()) { $this->writeDocument($this->getCallableDocument($callable)); } /** * {@inheritdoc} */ protected function describeContainerParameter($parameter, array $options = array()) { $this->writeDocument($this->getContainerParameterDocument($parameter, $options)); } /** * Writes DOM document. * * @return \DOMDocument|string */ private function writeDocument(\DOMDocument $dom) { $dom->formatOutput = true; $this->write($dom->saveXML()); } /** * @return \DOMDocument */ private function getRouteCollectionDocument(RouteCollection $routes) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($routesXML = $dom->createElement('routes')); foreach ($routes->all() as $name => $route) { $routeXML = $this->getRouteDocument($route, $name); $routesXML->appendChild($routesXML->ownerDocument->importNode($routeXML->childNodes->item(0), true)); } return $dom; } /** * @param Route $route * @param string|null $name * * @return \DOMDocument */ private function getRouteDocument(Route $route, $name = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($routeXML = $dom->createElement('route')); if ($name) { $routeXML->setAttribute('name', $name); } $routeXML->setAttribute('class', get_class($route)); $routeXML->appendChild($pathXML = $dom->createElement('path')); $pathXML->setAttribute('regex', $route->compile()->getRegex()); $pathXML->appendChild(new \DOMText($route->getPath())); if ('' !== $route->getHost()) { $routeXML->appendChild($hostXML = $dom->createElement('host')); $hostXML->setAttribute('regex', $route->compile()->getHostRegex()); $hostXML->appendChild(new \DOMText($route->getHost())); } foreach ($route->getSchemes() as $scheme) { $routeXML->appendChild($schemeXML = $dom->createElement('scheme')); $schemeXML->appendChild(new \DOMText($scheme)); } foreach ($route->getMethods() as $method) { $routeXML->appendChild($methodXML = $dom->createElement('method')); $methodXML->appendChild(new \DOMText($method)); } if ($route->getDefaults()) { $routeXML->appendChild($defaultsXML = $dom->createElement('defaults')); foreach ($route->getDefaults() as $attribute => $value) { $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); $defaultXML->setAttribute('key', $attribute); $defaultXML->appendChild(new \DOMText($this->formatValue($value))); } } $originRequirements = $requirements = $route->getRequirements(); unset($requirements['_scheme'], $requirements['_method']); if ($requirements) { $routeXML->appendChild($requirementsXML = $dom->createElement('requirements')); foreach ($originRequirements as $attribute => $pattern) { $requirementsXML->appendChild($requirementXML = $dom->createElement('requirement')); $requirementXML->setAttribute('key', $attribute); $requirementXML->appendChild(new \DOMText($pattern)); } } if ($route->getOptions()) { $routeXML->appendChild($optionsXML = $dom->createElement('options')); foreach ($route->getOptions() as $name => $value) { $optionsXML->appendChild($optionXML = $dom->createElement('option')); $optionXML->setAttribute('key', $name); $optionXML->appendChild(new \DOMText($this->formatValue($value))); } } return $dom; } /** * @return \DOMDocument */ private function getContainerParametersDocument(ParameterBag $parameters) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($parametersXML = $dom->createElement('parameters')); foreach ($this->sortParameters($parameters) as $key => $value) { $parametersXML->appendChild($parameterXML = $dom->createElement('parameter')); $parameterXML->setAttribute('key', $key); $parameterXML->appendChild(new \DOMText($this->formatParameter($value))); } return $dom; } /** * @param ContainerBuilder $builder * @param bool $showPrivate * * @return \DOMDocument */ private function getContainerTagsDocument(ContainerBuilder $builder, $showPrivate = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) { $containerXML->appendChild($tagXML = $dom->createElement('tag')); $tagXML->setAttribute('name', $tag); foreach ($definitions as $serviceId => $definition) { $definitionXML = $this->getContainerDefinitionDocument($definition, $serviceId, true); $tagXML->appendChild($dom->importNode($definitionXML->childNodes->item(0), true)); } } return $dom; } /** * @param mixed $service * @param string $id * @param ContainerBuilder|null $builder * @param bool $showArguments * * @return \DOMDocument */ private function getContainerServiceDocument($service, $id, ContainerBuilder $builder = null, $showArguments = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); if ($service instanceof Alias) { $dom->appendChild($dom->importNode($this->getContainerAliasDocument($service, $id)->childNodes->item(0), true)); if ($builder) { $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service, false, $showArguments)->childNodes->item(0), true)); } } elseif ($service instanceof Definition) { $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments)->childNodes->item(0), true)); } else { $dom->appendChild($serviceXML = $dom->createElement('service')); $serviceXML->setAttribute('id', $id); $serviceXML->setAttribute('class', get_class($service)); } return $dom; } /** * @param ContainerBuilder $builder * @param string|null $tag * @param bool $showPrivate * @param bool $showArguments * @param callable $filter * * @return \DOMDocument */ private function getContainerServicesDocument(ContainerBuilder $builder, $tag = null, $showPrivate = false, $showArguments = false, $filter = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); $serviceIds = $tag ? array_keys($builder->findTaggedServiceIds($tag)) : $builder->getServiceIds(); if ($filter) { $serviceIds = array_filter($serviceIds, $filter); } foreach ($this->sortServiceIds($serviceIds) as $serviceId) { $service = $this->resolveServiceDefinition($builder, $serviceId); if (($service instanceof Definition || $service instanceof Alias) && !($showPrivate || ($service->isPublic() && !$service->isPrivate()))) { continue; } $serviceXML = $this->getContainerServiceDocument($service, $serviceId, null, $showArguments); $containerXML->appendChild($containerXML->ownerDocument->importNode($serviceXML->childNodes->item(0), true)); } return $dom; } /** * @param Definition $definition * @param string|null $id * @param bool $omitTags * * @return \DOMDocument */ private function getContainerDefinitionDocument(Definition $definition, $id = null, $omitTags = false, $showArguments = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($serviceXML = $dom->createElement('definition')); if ($id) { $serviceXML->setAttribute('id', $id); } $serviceXML->setAttribute('class', $definition->getClass()); if ($factory = $definition->getFactory()) { $serviceXML->appendChild($factoryXML = $dom->createElement('factory')); if (is_array($factory)) { if ($factory[0] instanceof Reference) { $factoryXML->setAttribute('service', (string) $factory[0]); } elseif ($factory[0] instanceof Definition) { throw new \InvalidArgumentException('Factory is not describable.'); } else { $factoryXML->setAttribute('class', $factory[0]); } $factoryXML->setAttribute('method', $factory[1]); } else { $factoryXML->setAttribute('function', $factory); } } $serviceXML->setAttribute('public', $definition->isPublic() && !$definition->isPrivate() ? 'true' : 'false'); $serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false'); $serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false'); $serviceXML->setAttribute('shared', $definition->isShared() ? 'true' : 'false'); $serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false'); $serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false'); $serviceXML->setAttribute('autoconfigured', $definition->isAutoconfigured() ? 'true' : 'false'); $serviceXML->setAttribute('file', $definition->getFile()); $calls = $definition->getMethodCalls(); if (count($calls) > 0) { $serviceXML->appendChild($callsXML = $dom->createElement('calls')); foreach ($calls as $callData) { $callsXML->appendChild($callXML = $dom->createElement('call')); $callXML->setAttribute('method', $callData[0]); } } if ($showArguments) { foreach ($this->getArgumentNodes($definition->getArguments(), $dom) as $node) { $serviceXML->appendChild($node); } } if (!$omitTags) { if ($tags = $definition->getTags()) { $serviceXML->appendChild($tagsXML = $dom->createElement('tags')); foreach ($tags as $tagName => $tagData) { foreach ($tagData as $parameters) { $tagsXML->appendChild($tagXML = $dom->createElement('tag')); $tagXML->setAttribute('name', $tagName); foreach ($parameters as $name => $value) { $tagXML->appendChild($parameterXML = $dom->createElement('parameter')); $parameterXML->setAttribute('name', $name); $parameterXML->appendChild(new \DOMText($this->formatParameter($value))); } } } } } return $dom; } /** * @return \DOMNode[] */ private function getArgumentNodes(array $arguments, \DOMDocument $dom) { $nodes = array(); foreach ($arguments as $argumentKey => $argument) { $argumentXML = $dom->createElement('argument'); if (is_string($argumentKey)) { $argumentXML->setAttribute('key', $argumentKey); } if ($argument instanceof ServiceClosureArgument) { $argument = $argument->getValues()[0]; } if ($argument instanceof Reference) { $argumentXML->setAttribute('type', 'service'); $argumentXML->setAttribute('id', (string) $argument); } elseif ($argument instanceof IteratorArgument) { $argumentXML->setAttribute('type', 'iterator'); foreach ($this->getArgumentNodes($argument->getValues(), $dom) as $childArgumentXML) { $argumentXML->appendChild($childArgumentXML); } } elseif ($argument instanceof Definition) { $argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true)->childNodes->item(0), true)); } elseif (is_array($argument)) { $argumentXML->setAttribute('type', 'collection'); foreach ($this->getArgumentNodes($argument, $dom) as $childArgumenXML) { $argumentXML->appendChild($childArgumenXML); } } else { $argumentXML->appendChild(new \DOMText($argument)); } $nodes[] = $argumentXML; } return $nodes; } /** * @param Alias $alias * @param string|null $id * * @return \DOMDocument */ private function getContainerAliasDocument(Alias $alias, $id = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($aliasXML = $dom->createElement('alias')); if ($id) { $aliasXML->setAttribute('id', $id); } $aliasXML->setAttribute('service', (string) $alias); $aliasXML->setAttribute('public', $alias->isPublic() && !$alias->isPrivate() ? 'true' : 'false'); return $dom; } /** * @return \DOMDocument */ private function getContainerParameterDocument($parameter, $options = array()) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($parameterXML = $dom->createElement('parameter')); if (isset($options['parameter'])) { $parameterXML->setAttribute('key', $options['parameter']); } $parameterXML->appendChild(new \DOMText($this->formatParameter($parameter))); return $dom; } /** * @param EventDispatcherInterface $eventDispatcher * @param string|null $event * * @return \DOMDocument */ private function getEventDispatcherListenersDocument(EventDispatcherInterface $eventDispatcher, $event = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($eventDispatcherXML = $dom->createElement('event-dispatcher')); $registeredListeners = $eventDispatcher->getListeners($event); if (null !== $event) { $this->appendEventListenerDocument($eventDispatcher, $event, $eventDispatcherXML, $registeredListeners); } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { $eventDispatcherXML->appendChild($eventXML = $dom->createElement('event')); $eventXML->setAttribute('name', $eventListened); $this->appendEventListenerDocument($eventDispatcher, $eventListened, $eventXML, $eventListeners); } } return $dom; } private function appendEventListenerDocument(EventDispatcherInterface $eventDispatcher, $event, \DOMElement $element, array $eventListeners) { foreach ($eventListeners as $listener) { $callableXML = $this->getCallableDocument($listener); $callableXML->childNodes->item(0)->setAttribute('priority', $eventDispatcher->getListenerPriority($event, $listener)); $element->appendChild($element->ownerDocument->importNode($callableXML->childNodes->item(0), true)); } } /** * @param callable $callable * * @return \DOMDocument */ private function getCallableDocument($callable) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($callableXML = $dom->createElement('callable')); if (is_array($callable)) { $callableXML->setAttribute('type', 'function'); if (is_object($callable[0])) { $callableXML->setAttribute('name', $callable[1]); $callableXML->setAttribute('class', get_class($callable[0])); } else { if (0 !== strpos($callable[1], 'parent::')) { $callableXML->setAttribute('name', $callable[1]); $callableXML->setAttribute('class', $callable[0]); $callableXML->setAttribute('static', 'true'); } else { $callableXML->setAttribute('name', substr($callable[1], 8)); $callableXML->setAttribute('class', $callable[0]); $callableXML->setAttribute('static', 'true'); $callableXML->setAttribute('parent', 'true'); } } return $dom; } if (is_string($callable)) { $callableXML->setAttribute('type', 'function'); if (false === strpos($callable, '::')) { $callableXML->setAttribute('name', $callable); } else { $callableParts = explode('::', $callable); $callableXML->setAttribute('name', $callableParts[1]); $callableXML->setAttribute('class', $callableParts[0]); $callableXML->setAttribute('static', 'true'); } return $dom; } if ($callable instanceof \Closure) { $callableXML->setAttribute('type', 'closure'); return $dom; } if (method_exists($callable, '__invoke')) { $callableXML->setAttribute('type', 'object'); $callableXML->setAttribute('name', get_class($callable)); return $dom; } throw new \InvalidArgumentException('Callable is not describable.'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Helper/������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024604�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Console/Helper/DescriptorHelper.php����������������0000664�0000000�0000000�00000002100�13247321071�0030564�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Console\Helper; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\MarkdownDescriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\TextDescriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\XmlDescriptor; use Symfony\Component\Console\Helper\DescriptorHelper as BaseDescriptorHelper; /** * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> * * @internal */ class DescriptorHelper extends BaseDescriptorHelper { public function __construct() { $this ->register('txt', new TextDescriptor()) ->register('xml', new XmlDescriptor()) ->register('json', new JsonDescriptor()) ->register('md', new MarkdownDescriptor()) ; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024106�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php������������������0000664�0000000�0000000�00000004603�13247321071�0030431�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Psr\Container\ContainerInterface; use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Templating\EngineInterface; use Twig\Environment; /** * Provides common features needed in controllers. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class AbstractController implements ServiceSubscriberInterface { use ControllerTrait; /** * @var ContainerInterface */ protected $container; /** * @internal * @required */ public function setContainer(ContainerInterface $container) { $previous = $this->container; $this->container = $container; return $previous; } public static function getSubscribedServices() { return array( 'router' => '?'.RouterInterface::class, 'request_stack' => '?'.RequestStack::class, 'http_kernel' => '?'.HttpKernelInterface::class, 'serializer' => '?'.SerializerInterface::class, 'session' => '?'.SessionInterface::class, 'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class, 'templating' => '?'.EngineInterface::class, 'twig' => '?'.Environment::class, 'doctrine' => '?'.ManagerRegistry::class, 'form.factory' => '?'.FormFactoryInterface::class, 'security.token_storage' => '?'.TokenStorageInterface::class, 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, ); } } �����������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php��������������������������0000664�0000000�0000000�00000002013�13247321071�0026736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Controller is a simple implementation of a Controller. * * It provides methods to common features needed in controllers. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class Controller implements ContainerAwareInterface { use ContainerAwareTrait; use ControllerTrait; /** * Gets a container configuration parameter by its name. * * @param string $name The parameter name * * @return mixed * * @final since version 3.4 */ protected function getParameter($name) { return $this->container->getParameter($name); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php����������������0000664�0000000�0000000�00000012274�13247321071�0030726�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\HttpKernel\KernelInterface; /** * ControllerNameParser converts controller from the short notation a:b:c * (BlogBundle:Post:index) to a fully-qualified class::method string * (Bundle\BlogBundle\Controller\PostController::indexAction). * * @author Fabien Potencier <fabien@symfony.com> */ class ControllerNameParser { protected $kernel; public function __construct(KernelInterface $kernel) { $this->kernel = $kernel; } /** * Converts a short notation a:b:c to a class::method. * * @param string $controller A short notation controller (a:b:c) * * @return string A string in the class::method notation * * @throws \InvalidArgumentException when the specified bundle is not enabled * or the controller cannot be found */ public function parse($controller) { $parts = explode(':', $controller); if (3 !== count($parts) || in_array('', $parts, true)) { throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid "a:b:c" controller string.', $controller)); } $originalController = $controller; list($bundle, $controller, $action) = $parts; $controller = str_replace('/', '\\', $controller); $bundles = array(); try { // this throws an exception if there is no such bundle $allBundles = $this->kernel->getBundle($bundle, false, true); } catch (\InvalidArgumentException $e) { $message = sprintf( 'The "%s" (from the _controller value "%s") does not exist or is not enabled in your kernel!', $bundle, $originalController ); if ($alternative = $this->findAlternative($bundle)) { $message .= sprintf(' Did you mean "%s:%s:%s"?', $alternative, $controller, $action); } throw new \InvalidArgumentException($message, 0, $e); } if (!is_array($allBundles)) { // happens when HttpKernel is version 4+ $allBundles = array($allBundles); } foreach ($allBundles as $b) { $try = $b->getNamespace().'\\Controller\\'.$controller.'Controller'; if (class_exists($try)) { return $try.'::'.$action.'Action'; } $bundles[] = $b->getName(); $msg = sprintf('The _controller value "%s:%s:%s" maps to a "%s" class, but this class was not found. Create this class or check the spelling of the class and its namespace.', $bundle, $controller, $action, $try); } if (count($bundles) > 1) { $msg = sprintf('Unable to find controller "%s:%s" in bundles %s.', $bundle, $controller, implode(', ', $bundles)); } throw new \InvalidArgumentException($msg); } /** * Converts a class::method notation to a short one (a:b:c). * * @param string $controller A string in the class::method notation * * @return string A short notation controller (a:b:c) * * @throws \InvalidArgumentException when the controller is not valid or cannot be found in any bundle */ public function build($controller) { if (0 === preg_match('#^(.*?\\\\Controller\\\\(.+)Controller)::(.+)Action$#', $controller, $match)) { throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid "class::method" string.', $controller)); } $className = $match[1]; $controllerName = $match[2]; $actionName = $match[3]; foreach ($this->kernel->getBundles() as $name => $bundle) { if (0 !== strpos($className, $bundle->getNamespace())) { continue; } return sprintf('%s:%s:%s', $name, $controllerName, $actionName); } throw new \InvalidArgumentException(sprintf('Unable to find a bundle that defines controller "%s".', $controller)); } /** * Attempts to find a bundle that is *similar* to the given bundle name. * * @param string $nonExistentBundleName * * @return string */ private function findAlternative($nonExistentBundleName) { $bundleNames = array_map(function ($b) { return $b->getName(); }, $this->kernel->getBundles()); $alternative = null; $shortest = null; foreach ($bundleNames as $bundleName) { // if there's a partial match, return it immediately if (false !== strpos($bundleName, $nonExistentBundleName)) { return $bundleName; } $lev = levenshtein($nonExistentBundleName, $bundleName); if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) { $alternative = $bundleName; $shortest = $lev; } } return $alternative; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php������������������0000664�0000000�0000000�00000004622�13247321071�0030470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; /** * @author Fabien Potencier <fabien@symfony.com> */ class ControllerResolver extends ContainerControllerResolver { protected $parser; public function __construct(ContainerInterface $container, ControllerNameParser $parser, LoggerInterface $logger = null) { $this->parser = $parser; parent::__construct($container, $logger); } /** * {@inheritdoc} */ protected function createController($controller) { if (false === strpos($controller, '::') && 2 === substr_count($controller, ':')) { // controller in the a:b:c notation then $controller = $this->parser->parse($controller); } $resolvedController = parent::createController($controller); if (1 === substr_count($controller, ':') && is_array($resolvedController)) { $resolvedController[0] = $this->configureController($resolvedController[0]); } return $resolvedController; } /** * {@inheritdoc} */ protected function instantiateController($class) { return $this->configureController(parent::instantiateController($class)); } private function configureController($controller) { if ($controller instanceof ContainerAwareInterface) { // @deprecated switch, to be removed in 4.0 where these classes // won't implement ContainerAwareInterface anymore switch (\get_class($controller)) { case RedirectController::class: case TemplateController::class: return $controller; } $controller->setContainer($this->container); } if ($controller instanceof AbstractController && null !== $previousContainer = $controller->setContainer($this->container)) { $controller->setContainer($previousContainer); } return $controller; } } ��������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php���������������������0000664�0000000�0000000�00000037477�13247321071�0027770�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Doctrine\Common\Persistence\ManagerRegistry; use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Csrf\CsrfToken; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Common features needed in controllers. * * @author Fabien Potencier <fabien@symfony.com> * * @internal * * @property ContainerInterface $container */ trait ControllerTrait { /** * Returns true if the service id is defined. * * @param string $id The service id * * @return bool true if the service id is defined, false otherwise * * @final since version 3.4 */ protected function has($id) { return $this->container->has($id); } /** * Gets a container service by its id. * * @param string $id The service id * * @return object The service * * @final since version 3.4 */ protected function get($id) { return $this->container->get($id); } /** * Generates a URL from the given parameters. * * @param string $route The name of the route * @param array $parameters An array of parameters * @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface) * * @return string The generated URL * * @see UrlGeneratorInterface * * @final since version 3.4 */ protected function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { return $this->container->get('router')->generate($route, $parameters, $referenceType); } /** * Forwards the request to another controller. * * @param string $controller The controller name (a string like BlogBundle:Post:index) * @param array $path An array of path parameters * @param array $query An array of query parameters * * @return Response A Response instance * * @final since version 3.4 */ protected function forward($controller, array $path = array(), array $query = array()) { $request = $this->container->get('request_stack')->getCurrentRequest(); $path['_forwarded'] = $request->attributes; $path['_controller'] = $controller; $subRequest = $request->duplicate($query, null, $path); return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } /** * Returns a RedirectResponse to the given URL. * * @param string $url The URL to redirect to * @param int $status The status code to use for the Response * * @return RedirectResponse * * @final since version 3.4 */ protected function redirect($url, $status = 302) { return new RedirectResponse($url, $status); } /** * Returns a RedirectResponse to the given route with the given parameters. * * @param string $route The name of the route * @param array $parameters An array of parameters * @param int $status The status code to use for the Response * * @return RedirectResponse * * @final since version 3.4 */ protected function redirectToRoute($route, array $parameters = array(), $status = 302) { return $this->redirect($this->generateUrl($route, $parameters), $status); } /** * Returns a JsonResponse that uses the serializer component if enabled, or json_encode. * * @param mixed $data The response data * @param int $status The status code to use for the Response * @param array $headers Array of extra headers to add * @param array $context Context to pass to serializer when using serializer component * * @return JsonResponse * * @final since version 3.4 */ protected function json($data, $status = 200, $headers = array(), $context = array()) { if ($this->container->has('serializer')) { $json = $this->container->get('serializer')->serialize($data, 'json', array_merge(array( 'json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS, ), $context)); return new JsonResponse($json, $status, $headers, true); } return new JsonResponse($data, $status, $headers); } /** * Returns a BinaryFileResponse object with original or customized file name and disposition header. * * @param \SplFileInfo|string $file File object or path to file to be sent as response * @param string|null $fileName File name to be sent to response or null (will use original file name) * @param string $disposition Disposition of response ("attachment" is default, other type is "inline") * * @return BinaryFileResponse * * @final since version 3.4 */ protected function file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT) { $response = new BinaryFileResponse($file); $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName); return $response; } /** * Adds a flash message to the current session for type. * * @param string $type The type * @param string $message The message * * @throws \LogicException * * @final since version 3.4 */ protected function addFlash($type, $message) { if (!$this->container->has('session')) { throw new \LogicException('You can not use the addFlash method if sessions are disabled. Enable them in "config/packages/framework.yaml".'); } $this->container->get('session')->getFlashBag()->add($type, $message); } /** * Checks if the attributes are granted against the current authentication token and optionally supplied subject. * * @param mixed $attributes The attributes * @param mixed $subject The subject * * @return bool * * @throws \LogicException * * @final since version 3.4 */ protected function isGranted($attributes, $subject = null) { if (!$this->container->has('security.authorization_checker')) { throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".'); } return $this->container->get('security.authorization_checker')->isGranted($attributes, $subject); } /** * Throws an exception unless the attributes are granted against the current authentication token and optionally * supplied subject. * * @param mixed $attributes The attributes * @param mixed $subject The subject * @param string $message The message passed to the exception * * @throws AccessDeniedException * * @final since version 3.4 */ protected function denyAccessUnlessGranted($attributes, $subject = null, $message = 'Access Denied.') { if (!$this->isGranted($attributes, $subject)) { $exception = $this->createAccessDeniedException($message); $exception->setAttributes($attributes); $exception->setSubject($subject); throw $exception; } } /** * Returns a rendered view. * * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * * @return string The rendered view * * @final since version 3.4 */ protected function renderView($view, array $parameters = array()) { if ($this->container->has('templating')) { return $this->container->get('templating')->render($view, $parameters); } if (!$this->container->has('twig')) { throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); } return $this->container->get('twig')->render($view, $parameters); } /** * Renders a view. * * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * @param Response $response A response instance * * @return Response A Response instance * * @final since version 3.4 */ protected function render($view, array $parameters = array(), Response $response = null) { if ($this->container->has('templating')) { $content = $this->container->get('templating')->render($view, $parameters); } elseif ($this->container->has('twig')) { $content = $this->container->get('twig')->render($view, $parameters); } else { throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); } if (null === $response) { $response = new Response(); } $response->setContent($content); return $response; } /** * Streams a view. * * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * @param StreamedResponse $response A response instance * * @return StreamedResponse A StreamedResponse instance * * @final since version 3.4 */ protected function stream($view, array $parameters = array(), StreamedResponse $response = null) { if ($this->container->has('templating')) { $templating = $this->container->get('templating'); $callback = function () use ($templating, $view, $parameters) { $templating->stream($view, $parameters); }; } elseif ($this->container->has('twig')) { $twig = $this->container->get('twig'); $callback = function () use ($twig, $view, $parameters) { $twig->display($view, $parameters); }; } else { throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); } if (null === $response) { return new StreamedResponse($callback); } $response->setCallback($callback); return $response; } /** * Returns a NotFoundHttpException. * * This will result in a 404 response code. Usage example: * * throw $this->createNotFoundException('Page not found!'); * * @param string $message A message * @param \Exception|null $previous The previous exception * * @return NotFoundHttpException * * @final since version 3.4 */ protected function createNotFoundException($message = 'Not Found', \Exception $previous = null) { return new NotFoundHttpException($message, $previous); } /** * Returns an AccessDeniedException. * * This will result in a 403 response code. Usage example: * * throw $this->createAccessDeniedException('Unable to access this page!'); * * @param string $message A message * @param \Exception|null $previous The previous exception * * @return AccessDeniedException * * @throws \LogicException If the Security component is not available * * @final since version 3.4 */ protected function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null) { if (!class_exists(AccessDeniedException::class)) { throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".'); } return new AccessDeniedException($message, $previous); } /** * Creates and returns a Form instance from the type of the form. * * @param string $type The fully qualified class name of the form type * @param mixed $data The initial data for the form * @param array $options Options for the form * * @return FormInterface * * @final since version 3.4 */ protected function createForm($type, $data = null, array $options = array()) { return $this->container->get('form.factory')->create($type, $data, $options); } /** * Creates and returns a form builder instance. * * @param mixed $data The initial data for the form * @param array $options Options for the form * * @return FormBuilderInterface * * @final since version 3.4 */ protected function createFormBuilder($data = null, array $options = array()) { return $this->container->get('form.factory')->createBuilder(FormType::class, $data, $options); } /** * Shortcut to return the Doctrine Registry service. * * @return ManagerRegistry * * @throws \LogicException If DoctrineBundle is not available * * @final since version 3.4 */ protected function getDoctrine() { if (!$this->container->has('doctrine')) { throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require symfony/orm-pack".'); } return $this->container->get('doctrine'); } /** * Get a user from the Security Token Storage. * * @return mixed * * @throws \LogicException If SecurityBundle is not available * * @see TokenInterface::getUser() * * @final since version 3.4 */ protected function getUser() { if (!$this->container->has('security.token_storage')) { throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".'); } if (null === $token = $this->container->get('security.token_storage')->getToken()) { return; } if (!is_object($user = $token->getUser())) { // e.g. anonymous authentication return; } return $user; } /** * Checks the validity of a CSRF token. * * @param string $id The id used when generating the token * @param string $token The actual token sent with the request that should be validated * * @return bool * * @final since version 3.4 */ protected function isCsrfTokenValid($id, $token) { if (!$this->container->has('security.csrf.token_manager')) { throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml".'); } return $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($id, $token)); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php������������������0000664�0000000�0000000�00000015560�13247321071�0030433�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Redirects a request to another URL. * * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class RedirectController implements ContainerAwareInterface { /** * @deprecated since version 3.4, to be removed in 4.0 */ protected $container; private $router; private $httpPort; private $httpsPort; public function __construct(UrlGeneratorInterface $router = null, $httpPort = null, $httpsPort = null) { $this->router = $router; $this->httpPort = $httpPort; $this->httpsPort = $httpsPort; } /** * @deprecated since version 3.4, to be removed in 4.0 alongside with the ContainerAwareInterface type. */ public function setContainer(ContainerInterface $container = null) { @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject an UrlGeneratorInterface using the constructor instead.', __METHOD__), E_USER_DEPRECATED); $this->container = $container; $this->router = $container->get('router'); } /** * Redirects to another route with the given name. * * The response status code is 302 if the permanent parameter is false (default), * and 301 if the redirection is permanent. * * In case the route name is empty, the status code will be 404 when permanent is false * and 410 otherwise. * * @param Request $request The request instance * @param string $route The route name to redirect to * @param bool $permanent Whether the redirection is permanent * @param bool|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore * * @return Response A Response instance * * @throws HttpException In case the route name is empty */ public function redirectAction(Request $request, $route, $permanent = false, $ignoreAttributes = false) { if ('' == $route) { throw new HttpException($permanent ? 410 : 404); } $attributes = array(); if (false === $ignoreAttributes || is_array($ignoreAttributes)) { $attributes = $request->attributes->get('_route_params'); unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes']); if ($ignoreAttributes) { $attributes = array_diff_key($attributes, array_flip($ignoreAttributes)); } } return new RedirectResponse($this->router->generate($route, $attributes, UrlGeneratorInterface::ABSOLUTE_URL), $permanent ? 301 : 302); } /** * Redirects to a URL. * * The response status code is 302 if the permanent parameter is false (default), * and 301 if the redirection is permanent. * * In case the path is empty, the status code will be 404 when permanent is false * and 410 otherwise. * * @param Request $request The request instance * @param string $path The absolute path or URL to redirect to * @param bool $permanent Whether the redirect is permanent or not * @param string|null $scheme The URL scheme (null to keep the current one) * @param int|null $httpPort The HTTP port (null to keep the current one for the same scheme or the configured port in the container) * @param int|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the configured port in the container) * * @return Response A Response instance * * @throws HttpException In case the path is empty */ public function urlRedirectAction(Request $request, $path, $permanent = false, $scheme = null, $httpPort = null, $httpsPort = null) { if ('' == $path) { throw new HttpException($permanent ? 410 : 404); } $statusCode = $permanent ? 301 : 302; // redirect if the path is a full URL if (parse_url($path, PHP_URL_SCHEME)) { return new RedirectResponse($path, $statusCode); } if (null === $scheme) { $scheme = $request->getScheme(); } $qs = $request->getQueryString(); if ($qs) { if (false === strpos($path, '?')) { $qs = '?'.$qs; } else { $qs = '&'.$qs; } } $port = ''; if ('http' === $scheme) { if (null === $httpPort) { if ('http' === $request->getScheme()) { $httpPort = $request->getPort(); } elseif ($this->container && $this->container->hasParameter('request_listener.http_port')) { @trigger_error(sprintf('Passing the http port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), E_USER_DEPRECATED); $httpPort = $this->container->getParameter('request_listener.http_port'); } else { $httpPort = $this->httpPort; } } if (null !== $httpPort && 80 != $httpPort) { $port = ":$httpPort"; } } elseif ('https' === $scheme) { if (null === $httpsPort) { if ('https' === $request->getScheme()) { $httpsPort = $request->getPort(); } elseif ($this->container && $this->container->hasParameter('request_listener.https_port')) { @trigger_error(sprintf('Passing the https port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), E_USER_DEPRECATED); $httpsPort = $this->container->getParameter('request_listener.https_port'); } else { $httpsPort = $this->httpsPort; } } if (null !== $httpsPort && 443 != $httpsPort) { $port = ":$httpsPort"; } } $url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs; return new RedirectResponse($url, $statusCode); } } ������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php������������������0000664�0000000�0000000�00000005664�13247321071�0030451�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\EngineInterface; use Twig\Environment; /** * TemplateController. * * @author Fabien Potencier <fabien@symfony.com> * * @final since version 3.4 */ class TemplateController implements ContainerAwareInterface { /** * @deprecated since version 3.4, to be removed in 4.0 */ protected $container; private $twig; private $templating; public function __construct(Environment $twig = null, EngineInterface $templating = null) { $this->twig = $twig; $this->templating = $templating; } /** * @deprecated since version 3.4, to be removed in 4.0 alongside with the ContainerAwareInterface type. */ public function setContainer(ContainerInterface $container = null) { @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a Twig Environment or an EngineInterface using the constructor instead.', __METHOD__), E_USER_DEPRECATED); if ($container->has('templating')) { $this->templating = $container->get('templating'); } elseif ($container->has('twig')) { $this->twig = $container->get('twig'); } $this->container = $container; } /** * Renders a template. * * @param string $template The template name * @param int|null $maxAge Max age for client caching * @param int|null $sharedAge Max age for shared (proxy) caching * @param bool|null $private Whether or not caching should apply for client caches only * * @return Response A Response instance */ public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null) { if ($this->templating) { $response = new Response($this->templating->render($template)); } elseif ($this->twig) { $response = new Response($this->twig->render($template)); } else { throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.'); } if ($maxAge) { $response->setMaxAge($maxAge); } if ($sharedAge) { $response->setSharedMaxAge($sharedAge); } if ($private) { $response->setPrivate(); } elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) { $response->setPublic(); } return $response; } } ����������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DataCollector/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024503�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DataCollector/RequestDataCollector.php�������������0000664�0000000�0000000�00000004754�13247321071�0031317�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DataCollector; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector as BaseRequestCollector; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * RequestDataCollector. * * @author Jules Pietri <jusles@heahprod.com> */ class RequestDataCollector extends BaseRequestCollector implements EventSubscriberInterface { /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { parent::collect($request, $response, $exception); if ($parentRequestAttributes = $request->attributes->get('_forwarded')) { if ($parentRequestAttributes instanceof ParameterBag) { $parentRequestAttributes->set('_forward_token', $response->headers->get('x-debug-token')); } } if ($request->attributes->has('_forward_controller')) { $this->data['forward'] = array( 'token' => $request->attributes->get('_forward_token'), 'controller' => $this->parseController($request->attributes->get('_forward_controller')), ); } } /** * Gets the parsed forward controller. * * @return array|bool An array with keys 'token' the forward profile token, and * 'controller' the parsed forward controller, false otherwise */ public function getForward() { return isset($this->data['forward']) ? $this->data['forward'] : false; } public function onKernelController(FilterControllerEvent $event) { $this->controllers[$event->getRequest()] = $event->getController(); if ($parentRequestAttributes = $event->getRequest()->attributes->get('_forwarded')) { if ($parentRequestAttributes instanceof ParameterBag) { $parentRequestAttributes->set('_forward_controller', $event->getController()); } } } /** * {@inheritdoc} */ public function getName() { return 'request'; } } ��������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php��������������0000664�0000000�0000000�00000001743�13247321071�0031142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DataCollector; use Symfony\Component\HttpKernel\DataCollector\RouterDataCollector as BaseRouterDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\RedirectController; /** * RouterDataCollector. * * @author Fabien Potencier <fabien@symfony.com> */ class RouterDataCollector extends BaseRouterDataCollector { public function guessRoute(Request $request, $controller) { if (is_array($controller)) { $controller = $controller[0]; } if ($controller instanceof RedirectController) { return $request->attributes->get('_route'); } return parent::guessRoute($request, $controller); } } �����������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025704�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/����������������������0000775�0000000�0000000�00000000000�13247321071�0027456�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddAnnotationsCachedReaderPass.php������������������������������������������������������������������0000664�0000000�0000000�00000002573�13247321071�0036067�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * @internal */ class AddAnnotationsCachedReaderPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { // "annotations.cached_reader" is wired late so that any passes using // "annotation_reader" at build time don't get any cache foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) { $reader = $container->getDefinition($id); $properties = $reader->getProperties(); if (isset($properties['cacheProviderBackup'])) { $provider = $properties['cacheProviderBackup']->getValues()[0]; unset($properties['cacheProviderBackup']); $reader->setProperties($properties); $container->set($id, null); $container->setDefinition($id, $reader->replaceArgument(1, $provider)); } } } } �������������������������������������������������������������������������������������������������������������������������������������AddCacheClearerPass.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000002574�13247321071�0033661�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use tagged iterator arguments instead.', AddCacheClearerPass::class), E_USER_DEPRECATED); use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; /** * Registers the cache clearers. * * @deprecated since version 3.4, to be removed in 4.0. Use tagged iterator arguments. * * @author Dustin Dobervich <ddobervich@gmail.com> */ class AddCacheClearerPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('cache_clearer')) { return; } $clearers = array(); foreach ($container->findTaggedServiceIds('kernel.cache_clearer', true) as $id => $attributes) { $clearers[] = new Reference($id); } $container->getDefinition('cache_clearer')->replaceArgument(0, $clearers); } } ������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php0000664�0000000�0000000�00000002623�13247321071�0033613�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use tagged iterator arguments instead.', AddCacheWarmerPass::class), E_USER_DEPRECATED); use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Registers the cache warmers. * * @deprecated since version 3.4, to be removed in 4.0. Use tagged iterator arguments instead. * * @author Fabien Potencier <fabien@symfony.com> */ class AddCacheWarmerPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('cache_warmer')) { return; } $warmers = $this->findAndSortTaggedServices('kernel.cache_warmer', $container); if (empty($warmers)) { return; } $container->getDefinition('cache_warmer')->replaceArgument(0, $warmers); } } �������������������������������������������������������������������������������������������������������������AddConsoleCommandPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000001644�13247321071�0034256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('%s is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass instead.', AddConsoleCommandPass::class), E_USER_DEPRECATED); use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass as BaseAddConsoleCommandPass; /** * Registers console commands. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * * @deprecated since version 3.3, to be removed in 4.0. Use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass instead. */ class AddConsoleCommandPass extends BaseAddConsoleCommandPass { } ��������������������������������������������������������������������������������������������AddConstraintValidatorsPass.php���������������������������������������������������������������������0000664�0000000�0000000�00000001502�13247321071�0035523�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass as BaseAddConstraintValidatorsPass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', AddConstraintValidatorsPass::class, BaseAddConstraintValidatorsPass::class), E_USER_DEPRECATED); /** * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseAddConstraintValidatorsPass} instead */ class AddConstraintValidatorsPass extends BaseAddConstraintValidatorsPass { } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddDebugLogProcessorPass.php������������������������������������������������������������������������0000664�0000000�0000000�00000002102�13247321071�0034733�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; class AddDebugLogProcessorPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->hasDefinition('profiler')) { return; } if (!$container->hasDefinition('monolog.logger_prototype')) { return; } if (!$container->hasDefinition('debug.log_processor')) { return; } $definition = $container->getDefinition('monolog.logger_prototype'); $definition->addMethodCall('pushProcessor', array(new Reference('debug.log_processor'))); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddExpressionLanguageProvidersPass.php��������������������������������������������������������������0000664�0000000�0000000�00000003077�13247321071�0037060�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; /** * Registers the expression language providers. * * @author Fabien Potencier <fabien@symfony.com> */ class AddExpressionLanguageProvidersPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { // routing if ($container->has('router')) { $definition = $container->findDefinition('router'); foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) { $definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id))); } } // security if ($container->has('security.access.expression_voter')) { $definition = $container->findDefinition('security.access.expression_voter'); foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) { $definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id))); } } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddValidatorInitializersPass.php��������������������������������������������������������������������0000664�0000000�0000000�00000001511�13247321071�0035662�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass as BaseAddValidatorsInitializerPass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', AddValidatorInitializersPass::class, BaseAddValidatorsInitializerPass::class), E_USER_DEPRECATED); /** * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseAddValidatorInitializersPass} instead */ class AddValidatorInitializersPass extends BaseAddValidatorsInitializerPass { } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CacheCollectorPass.php0000664�0000000�0000000�00000004723�13247321071�0033676�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** * Inject a data collector to all the cache services to be able to get detailed statistics. * * @author Tobias Nyholm <tobias.nyholm@gmail.com> */ class CacheCollectorPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('data_collector.cache')) { return; } $collectorDefinition = $container->getDefinition('data_collector.cache'); foreach ($container->findTaggedServiceIds('cache.pool') as $id => $attributes) { $definition = $container->getDefinition($id); if ($definition->isAbstract()) { continue; } $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class); $recorder->setTags($definition->getTags()); $recorder->setPublic($definition->isPublic()); $recorder->setArguments(array(new Reference($innerId = $id.'.recorder_inner'))); $definition->setTags(array()); $definition->setPublic(false); if (method_exists($definition, 'getAutowiringTypes') && $types = $definition->getAutowiringTypes(false)) { $recorder->setAutowiringTypes($types); $definition->setAutowiringTypes(array()); } $container->setDefinition($innerId, $definition); $container->setDefinition($id, $recorder); // Tell the collector to add the new instance $collectorDefinition->addMethodCall('addInstance', array($id, new Reference($id))); $collectorDefinition->setPublic(false); } } } ���������������������������������������������CachePoolClearerPass.php����������������������������������������������������������������������������0000664�0000000�0000000�00000004105�13247321071�0034072�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * @author Nicolas Grekas <p@tchwork.com> */ final class CachePoolClearerPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { $container->getParameterBag()->remove('cache.prefix.seed'); foreach ($container->findTaggedServiceIds('cache.pool.clearer') as $id => $attr) { $clearer = $container->getDefinition($id); $pools = array(); foreach ($clearer->getArgument(0) as $id => $ref) { if ($container->hasDefinition($id)) { $pools[$id] = new Reference($id); } } $clearer->replaceArgument(0, $pools); } if (!$container->has('cache.annotations')) { return; } $factory = array(AbstractAdapter::class, 'createSystemCache'); $annotationsPool = $container->findDefinition('cache.annotations'); if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) { return; } if ($container->has('monolog.logger.cache')) { $annotationsPool->addArgument(new Reference('monolog.logger.cache')); } elseif ($container->has('cache.system')) { $systemPool = $container->findDefinition('cache.system'); if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) { $annotationsPool->addArgument($systemArgs[4]); } } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php�����0000664�0000000�0000000�00000012753�13247321071�0032663�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; /** * @author Nicolas Grekas <p@tchwork.com> */ class CachePoolPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if ($container->hasParameter('cache.prefix.seed')) { $seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed')); } else { $seed = '_'.$container->getParameter('kernel.root_dir'); } $seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment'); $pools = array(); $clearers = array(); $attributes = array( 'provider', 'namespace', 'default_lifetime', 'reset', ); foreach ($container->findTaggedServiceIds('cache.pool') as $id => $tags) { $adapter = $pool = $container->getDefinition($id); if ($pool->isAbstract()) { continue; } while ($adapter instanceof ChildDefinition) { $adapter = $container->findDefinition($adapter->getParent()); if ($t = $adapter->getTag('cache.pool')) { $tags[0] += $t[0]; } } if (!isset($tags[0]['namespace'])) { $tags[0]['namespace'] = $this->getNamespace($seed, $id); } if (isset($tags[0]['clearer'])) { $clearer = $tags[0]['clearer']; while ($container->hasAlias($clearer)) { $clearer = (string) $container->getAlias($clearer); } } else { $clearer = null; } unset($tags[0]['clearer']); if (isset($tags[0]['provider'])) { $tags[0]['provider'] = new Reference(static::getServiceProvider($container, $tags[0]['provider'])); } $i = 0; foreach ($attributes as $attr) { if (!isset($tags[0][$attr])) { // no-op } elseif ('reset' === $attr) { if ($tags[0][$attr]) { $pool->addTag('kernel.reset', array('method' => $tags[0][$attr])); } } elseif ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass()) { $pool->replaceArgument($i++, $tags[0][$attr]); } unset($tags[0][$attr]); } if (!empty($tags[0])) { throw new InvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "namespace", "default_lifetime" and "reset", found "%s".', $id, implode('", "', array_keys($tags[0])))); } if (null !== $clearer) { $clearers[$clearer][$id] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE); } $pools[$id] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE); } $clearer = 'cache.global_clearer'; while ($container->hasAlias($clearer)) { $clearer = (string) $container->getAlias($clearer); } if ($container->hasDefinition($clearer)) { $clearers['cache.global_clearer'] = $pools; } foreach ($clearers as $id => $pools) { $clearer = $container->getDefinition($id); if ($clearer instanceof ChildDefinition) { $clearer->replaceArgument(0, $pools); } else { $clearer->setArgument(0, $pools); } $clearer->addTag('cache.pool.clearer'); if ('cache.system_clearer' === $id) { $clearer->addTag('kernel.cache_clearer'); } } } private function getNamespace($seed, $id) { return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$seed, true))), 0, 10); } /** * @internal */ public static function getServiceProvider(ContainerBuilder $container, $name) { $container->resolveEnvPlaceholders($name, null, $usedEnvs); if ($usedEnvs || preg_match('#^[a-z]++://#', $name)) { $dsn = $name; if (!$container->hasDefinition($name = 'cache_connection.'.ContainerBuilder::hash($dsn))) { $definition = new Definition(AbstractAdapter::class); $definition->setPublic(false); $definition->setFactory(array(AbstractAdapter::class, 'createConnection')); $definition->setArguments(array($dsn, array('lazy' => true))); $container->setDefinition($name, $definition); } } return $name; } } ���������������������CachePoolPrunerPass.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000004067�13247321071�0033777�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; /** * @author Rob Frawley 2nd <rmf@src.run> */ class CachePoolPrunerPass implements CompilerPassInterface { private $cacheCommandServiceId; private $cachePoolTag; public function __construct($cacheCommandServiceId = CachePoolPruneCommand::class, $cachePoolTag = 'cache.pool') { $this->cacheCommandServiceId = $cacheCommandServiceId; $this->cachePoolTag = $cachePoolTag; } /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition($this->cacheCommandServiceId)) { return; } $services = array(); foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $tags) { $class = $container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass()); if (!$reflection = $container->getReflectionClass($class)) { throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } if ($reflection->implementsInterface(PruneableInterface::class)) { $services[$id] = new Reference($id); } } $container->getDefinition($this->cacheCommandServiceId)->replaceArgument(0, new IteratorArgument($services)); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CompilerDebugDumpPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000003102�13247321071�0034302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0.', CompilerDebugDumpPass::class), E_USER_DEPRECATED); use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** * @deprecated since version 3.3, to be removed in 4.0. */ class CompilerDebugDumpPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $filename = self::getCompilerLogFilename($container); $filesystem = new Filesystem(); $filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null); try { $filesystem->chmod($filename, 0666, umask()); } catch (IOException $e) { // discard chmod failure (some filesystem may not support it) } } public static function getCompilerLogFilename(ContainerInterface $container) { $class = $container->getParameter('kernel.container_class'); return $container->getParameter('kernel.cache_dir').'/'.$class.'Compiler.log'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ConfigCachePass.php���0000664�0000000�0000000�00000001675�13247321071�0033160�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Config\DependencyInjection\ConfigCachePass as BaseConfigCachePass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use tagged iterator arguments instead.', ConfigCachePass::class), E_USER_DEPRECATED); /** * Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority. * * @deprecated since version 3.3, to be removed in 4.0. Use tagged iterator arguments instead. * * @author Matthias Pigulla <mp@webfactory.de> * @author Benjamin Klotz <bk@webfactory.de> */ class ConfigCachePass extends BaseConfigCachePass { } �������������������������������������������������������������������ContainerBuilderDebugDumpPass.php�������������������������������������������������������������������0000664�0000000�0000000�00000002206�13247321071�0035765�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Config\ConfigCache; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\XmlDumper; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Dumps the ContainerBuilder to a cache file so that it can be used by * debugging tools such as the debug:container console command. * * @author Ryan Weaver <ryan@thatsquality.com> * @author Fabien Potencier <fabien@symfony.com> */ class ContainerBuilderDebugDumpPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $cache = new ConfigCache($container->getParameter('debug.container.dump'), true); if (!$cache->isFresh()) { $cache->write((new XmlDumper($container))->dump(), $container->getResources()); } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ControllerArgumentValueResolverPass.php�������������������������������������������������������������0000664�0000000�0000000�00000001742�13247321071�0037310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass as BaseControllerArgumentValueResolverPass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', ControllerArgumentValueResolverPass::class, BaseControllerArgumentValueResolverPass::class), E_USER_DEPRECATED); /** * Gathers and configures the argument value resolvers. * * @author Iltar van der Berg <kjarli@gmail.com> * * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseControllerArgumentValueResolverPass} */ class ControllerArgumentValueResolverPass extends BaseControllerArgumentValueResolverPass { } ������������������������������DataCollectorTranslatorPass.php���������������������������������������������������������������������0000664�0000000�0000000�00000002142�13247321071�0035530�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * @author Christian Flothmann <christian.flothmann@sensiolabs.de> */ class DataCollectorTranslatorPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->has('translator')) { return; } $translatorClass = $container->getParameterBag()->resolveValue($container->findDefinition('translator')->getClass()); if (!is_subclass_of($translatorClass, 'Symfony\Component\Translation\TranslatorBagInterface')) { $container->removeDefinition('translator.data_collector'); $container->removeDefinition('data_collector.translation'); } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FormPass.php����������0000664�0000000�0000000�00000006465�13247321071�0031734�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\Form\DependencyInjection\FormPass instead.', FormPass::class), E_USER_DEPRECATED); use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; /** * Adds all services with the tags "form.type" and "form.type_guesser" as * arguments of the "form.extension" service. * * @author Bernhard Schussek <bschussek@gmail.com> * * @deprecated since version 3.3, to be removed in 4.0. Use FormPass in the Form component instead. */ class FormPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; public function process(ContainerBuilder $container) { if (!$container->hasDefinition('form.extension')) { return; } $definition = $container->getDefinition('form.extension'); // Builds an array with fully-qualified type class names as keys and service IDs as values $types = array(); foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) { $serviceDefinition = $container->getDefinition($serviceId); if (!$serviceDefinition->isPublic()) { $serviceDefinition->setPublic(true); } // Support type access by FQCN $types[$serviceDefinition->getClass()] = $serviceId; } $definition->replaceArgument(1, $types); $typeExtensions = array(); foreach ($this->findAndSortTaggedServices('form.type_extension', $container) as $reference) { $serviceId = (string) $reference; $serviceDefinition = $container->getDefinition($serviceId); if (!$serviceDefinition->isPublic()) { $serviceDefinition->setPublic(true); } $tag = $serviceDefinition->getTag('form.type_extension'); if (isset($tag[0]['extended_type'])) { $extendedType = $tag[0]['extended_type']; } else { throw new InvalidArgumentException(sprintf('Tagged form type extension must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "%s" service.', $serviceId)); } $typeExtensions[$extendedType][] = $serviceId; } $definition->replaceArgument(2, $typeExtensions); // Find all services annotated with "form.type_guesser" $guessers = array_keys($container->findTaggedServiceIds('form.type_guesser')); foreach ($guessers as $serviceId) { $serviceDefinition = $container->getDefinition($serviceId); if (!$serviceDefinition->isPublic()) { $serviceDefinition->setPublic(true); } } $definition->replaceArgument(3, $guessers); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������LoggingTranslatorPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000004576�13247321071�0034413�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorBagInterface; /** * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> */ class LoggingTranslatorPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->hasAlias('logger') || !$container->hasAlias('translator')) { return; } if ($container->hasParameter('translator.logging') && $container->getParameter('translator.logging')) { $translatorAlias = $container->getAlias('translator'); $definition = $container->getDefinition((string) $translatorAlias); $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!$r = $container->getReflectionClass($class)) { throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $translatorAlias)); } if ($r->isSubclassOf(TranslatorInterface::class) && $r->isSubclassOf(TranslatorBagInterface::class)) { $container->getDefinition('translator.logging')->setDecoratedService('translator'); $warmer = $container->getDefinition('translation.warmer'); $subscriberAttributes = $warmer->getTag('container.service_subscriber'); $warmer->clearTag('container.service_subscriber'); foreach ($subscriberAttributes as $k => $v) { if ((!isset($v['id']) || 'translator' !== $v['id']) && (!isset($v['key']) || 'translator' !== $v['key'])) { $warmer->addTag('container.service_subscriber', $v); } } $warmer->addTag('container.service_subscriber', array('key' => 'translator', 'id' => 'translator.logging.inner')); } } } } ����������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php������0000664�0000000�0000000�00000004004�13247321071�0032576�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; /** * Adds tagged data_collector services to profiler service. * * @author Fabien Potencier <fabien@symfony.com> */ class ProfilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (false === $container->hasDefinition('profiler')) { return; } $definition = $container->getDefinition('profiler'); $collectors = new \SplPriorityQueue(); $order = PHP_INT_MAX; foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $template = null; if (isset($attributes[0]['template'])) { if (!isset($attributes[0]['id'])) { throw new InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id)); } $template = array($attributes[0]['id'], $attributes[0]['template']); } $collectors->insert(array($id, $template), array($priority, --$order)); } $templates = array(); foreach ($collectors as $collector) { $definition->addMethodCall('add', array(new Reference($collector[0]))); $templates[$collector[0]] = $collector[1]; } $container->setParameter('data_collector.templates', $templates); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php��0000664�0000000�0000000�00000001602�13247321071�0033455�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass instead.', PropertyInfoPass::class), E_USER_DEPRECATED); use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass as BasePropertyInfoPass; /** * Adds extractors to the property_info service. * * @author Kévin Dunglas <dunglas@gmail.com> * * @deprecated since version 3.3, to be removed in 4.0. Use {@link BasePropertyInfoPass instead}. */ class PropertyInfoPass extends BasePropertyInfoPass { } ������������������������������������������������������������������������������������������������������������������������������RoutingResolverPass.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000001573�13247321071�0034116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass as BaseRoutingResolverPass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', RoutingResolverPass::class, BaseRoutingResolverPass::class), E_USER_DEPRECATED); /** * Adds tagged routing.loader services to routing.resolver service. * * @author Fabien Potencier <fabien@symfony.com> * * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseRoutingResolverPass} */ class RoutingResolverPass extends BaseRoutingResolverPass { } �������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php����0000664�0000000�0000000�00000001714�13247321071�0033132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\Serializer\DependencyInjection\SerializerPass instead.', SerializerPass::class), E_USER_DEPRECATED); use Symfony\Component\Serializer\DependencyInjection\SerializerPass as BaseSerializerPass; /** * Adds all services with the tags "serializer.encoder" and "serializer.normalizer" as * encoders and normalizers to the Serializer service. * * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseSerializerPass} instead. * * @author Javier Lopez <f12loalf@gmail.com> */ class SerializerPass extends BaseSerializerPass { } ����������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php����0000664�0000000�0000000�00000004036�13247321071�0033125�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; class TemplatingPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if ($container->hasDefinition('templating')) { return; } if ($container->hasAlias('templating')) { $container->setAlias(ComponentEngineInterface::class, new Alias('templating', false)); $container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating', false)); } if ($container->hasDefinition('templating.engine.php')) { $refs = array(); $helpers = array(); foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) { if (isset($attributes[0]['alias'])) { $helpers[$attributes[0]['alias']] = $id; $refs[$id] = new Reference($id); } } if (count($helpers) > 0) { $definition = $container->getDefinition('templating.engine.php'); $definition->addMethodCall('setHelpers', array($helpers)); if ($container->hasDefinition('templating.engine.php.helpers_locator')) { $container->getDefinition('templating.engine.php.helpers_locator')->replaceArgument(0, $refs); } } } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������TranslationDumperPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000001606�13247321071�0034415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass instead.', TranslationDumperPass::class), E_USER_DEPRECATED); use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass as BaseTranslationDumperPass; /** * Adds tagged translation.formatter services to translation writer. * * @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslationDumperPass instead}. */ class TranslationDumperPass extends BaseTranslationDumperPass { } ��������������������������������������������������������������������������������������������������������������������������TranslationExtractorPass.php������������������������������������������������������������������������0000664�0000000�0000000�00000001630�13247321071�0035131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass instead.', TranslationExtractorPass::class), E_USER_DEPRECATED); use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass as BaseTranslationExtractorPass; /** * Adds tagged translation.formatter services to translation writer. * * @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslationDumperPass instead}. */ class TranslationExtractorPass extends BaseTranslationExtractorPass { } ��������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslatorPass.php����0000664�0000000�0000000�00000001525�13247321071�0033152�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslatorPass instead.', TranslatorPass::class), E_USER_DEPRECATED); use Symfony\Component\Translation\DependencyInjection\TranslatorPass as BaseTranslatorPass; /** * Adds tagged translation.formatter services to translation writer. * * @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslatorPass instead}. */ class TranslatorPass extends BaseTranslatorPass { } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php����0000664�0000000�0000000�00000005545�13247321071�0033111�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Find all service tags which are defined, but not used and yield a warning log message. * * @author Florian Pfitzer <pfitzer@wurzel3.de> */ class UnusedTagsPass implements CompilerPassInterface { private $whitelist = array( 'annotations.cached_reader', 'cache.pool.clearer', 'console.command', 'container.hot_path', 'container.service_locator', 'container.service_subscriber', 'controller.service_arguments', 'config_cache.resource_checker', 'data_collector', 'form.type', 'form.type_extension', 'form.type_guesser', 'kernel.cache_clearer', 'kernel.cache_warmer', 'kernel.event_listener', 'kernel.event_subscriber', 'kernel.fragment_renderer', 'monolog.logger', 'routing.expression_language_provider', 'routing.loader', 'security.expression_language_provider', 'security.remember_me_aware', 'security.voter', 'serializer.encoder', 'serializer.normalizer', 'templating.helper', 'translation.dumper', 'translation.extractor', 'translation.loader', 'twig.extension', 'twig.loader', 'validator.constraint_validator', 'validator.initializer', ); public function process(ContainerBuilder $container) { $tags = array_unique(array_merge($container->findTags(), $this->whitelist)); foreach ($container->findUnusedTags() as $tag) { // skip whitelisted tags if (in_array($tag, $this->whitelist)) { continue; } // check for typos $candidates = array(); foreach ($tags as $definedTag) { if ($definedTag === $tag) { continue; } if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= strlen($tag) / 3) { $candidates[] = $definedTag; } } $services = array_keys($container->findTaggedServiceIds($tag)); $message = sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services)); if (!empty($candidates)) { $message .= sprintf(' Did you mean "%s"?', implode('", "', $candidates)); } $container->log($this, $message); } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������ValidateWorkflowsPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000001515�13247321071�0034410�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass as BaseValidateWorkflowsPass; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', ValidateWorkflowsPass::class, BaseValidateWorkflowsPass::class), E_USER_DEPRECATED); /** * @author Tobias Nyholm <tobias.nyholm@gmail.com> * * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseValidateWorkflowsPass} instead */ class ValidateWorkflowsPass extends BaseValidateWorkflowsPass { } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������WorkflowGuardListenerPass.php�����������������������������������������������������������������������0000664�0000000�0000000�00000002702�13247321071�0035243�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; /** * @author Christian Flothmann <christian.flothmann@sensiolabs.de> * @author Grégoire Pineau <lyrixx@lyrixx.info> */ class WorkflowGuardListenerPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasParameter('workflow.has_guard_listeners')) { return; } $container->getParameterBag()->remove('workflow.has_guard_listeners'); $servicesNeeded = array( 'security.token_storage', 'security.authorization_checker', 'security.authentication.trust_resolver', 'security.role_hierarchy', ); foreach ($servicesNeeded as $service) { if (!$container->has($service)) { throw new LogicException(sprintf('The "%s" service is needed to be able to use the workflow guard listener.', $service)); } } } } ��������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php��������������0000664�0000000�0000000�00000133164�13247321071�0031234�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection; use Doctrine\Common\Annotations\Annotation; use Doctrine\Common\Cache\Cache; use Symfony\Bundle\FullStack; use Symfony\Component\Asset\Package; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Form\Form; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Store\SemaphoreStore; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Translation\Translator; use Symfony\Component\Validator\Validation; use Symfony\Component\WebLink\HttpHeaderSerializer; /** * FrameworkExtension configuration structure. * * @author Jeremy Mikola <jmikola@gmail.com> */ class Configuration implements ConfigurationInterface { private $debug; /** * @param bool $debug Whether debugging is enabled or not */ public function __construct($debug) { $this->debug = (bool) $debug; } /** * Generates the configuration tree builder. * * @return TreeBuilder The tree builder */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('framework'); $rootNode ->beforeNormalization() ->ifTrue(function ($v) { return !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class); }) ->then(function ($v) { $v['assets'] = array(); return $v; }) ->end() ->children() ->scalarNode('secret')->end() ->scalarNode('http_method_override') ->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead") ->defaultTrue() ->end() ->arrayNode('trusted_proxies') ->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.') ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v) && null !== $v; }) ->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); }) ->end() ->prototype('scalar') ->validate() ->ifTrue(function ($v) { if (empty($v)) { return false; } if (false !== strpos($v, '/')) { if ('0.0.0.0/0' === $v) { return false; } list($v, $mask) = explode('/', $v, 2); if (strcmp($mask, (int) $mask) || $mask < 1 || $mask > (false !== strpos($v, ':') ? 128 : 32)) { return true; } } return !filter_var($v, FILTER_VALIDATE_IP); }) ->thenInvalid('Invalid proxy IP "%s"') ->end() ->end() ->end() ->scalarNode('ide')->defaultNull()->end() ->booleanNode('test')->end() ->scalarNode('default_locale')->defaultValue('en')->end() ->arrayNode('trusted_hosts') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->end() ->end() ; $this->addCsrfSection($rootNode); $this->addFormSection($rootNode); $this->addEsiSection($rootNode); $this->addSsiSection($rootNode); $this->addFragmentsSection($rootNode); $this->addProfilerSection($rootNode); $this->addWorkflowSection($rootNode); $this->addRouterSection($rootNode); $this->addSessionSection($rootNode); $this->addRequestSection($rootNode); $this->addTemplatingSection($rootNode); $this->addAssetsSection($rootNode); $this->addTranslatorSection($rootNode); $this->addValidationSection($rootNode); $this->addAnnotationsSection($rootNode); $this->addSerializerSection($rootNode); $this->addPropertyAccessSection($rootNode); $this->addPropertyInfoSection($rootNode); $this->addCacheSection($rootNode); $this->addPhpErrorsSection($rootNode); $this->addWebLinkSection($rootNode); $this->addLockSection($rootNode); return $treeBuilder; } private function addCsrfSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('csrf_protection') ->treatFalseLike(array('enabled' => false)) ->treatTrueLike(array('enabled' => true)) ->treatNullLike(array('enabled' => true)) ->addDefaultsIfNotSet() ->children() // defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class) ->booleanNode('enabled')->defaultNull()->end() ->end() ->end() ->end() ; } private function addFormSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('form') ->info('form configuration') ->{!class_exists(FullStack::class) && class_exists(Form::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() ->arrayNode('csrf_protection') ->treatFalseLike(array('enabled' => false)) ->treatTrueLike(array('enabled' => true)) ->treatNullLike(array('enabled' => true)) ->addDefaultsIfNotSet() ->children() ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled ->scalarNode('field_name')->defaultValue('_token')->end() ->end() ->end() ->end() ->end() ->end() ; } private function addEsiSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('esi') ->info('esi configuration') ->canBeEnabled() ->end() ->end() ; } private function addSsiSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('ssi') ->info('ssi configuration') ->canBeEnabled() ->end() ->end(); } private function addFragmentsSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('fragments') ->info('fragments configuration') ->canBeEnabled() ->children() ->scalarNode('path')->defaultValue('/_fragment')->end() ->end() ->end() ->end() ; } private function addProfilerSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('profiler') ->info('profiler configuration') ->canBeEnabled() ->children() ->booleanNode('collect')->defaultTrue()->end() ->booleanNode('only_exceptions')->defaultFalse()->end() ->booleanNode('only_master_requests')->defaultFalse()->end() ->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end() ->arrayNode('matcher') ->setDeprecated('The "profiler.matcher" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0.') ->canBeEnabled() ->performNoDeepMerging() ->fixXmlConfig('ip') ->children() ->scalarNode('path') ->info('use the urldecoded format') ->example('^/path to resource/') ->end() ->scalarNode('service')->end() ->arrayNode('ips') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ->end() ; } private function addWorkflowSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('workflow') ->children() ->arrayNode('workflows') ->canBeEnabled() ->beforeNormalization() ->always(function ($v) { if (true === $v['enabled']) { $workflows = $v; unset($workflows['enabled']); if (1 === count($workflows) && isset($workflows[0]['enabled'])) { $workflows = array(); } $v = array( 'enabled' => true, 'workflows' => $workflows, ); } return $v; }) ->end() ->children() ->arrayNode('workflows') ->useAttributeAsKey('name') ->prototype('array') ->fixXmlConfig('support') ->fixXmlConfig('place') ->fixXmlConfig('transition') ->children() ->arrayNode('audit_trail') ->canBeEnabled() ->end() ->enumNode('type') ->values(array('workflow', 'state_machine')) ->end() ->arrayNode('marking_store') ->fixXmlConfig('argument') ->children() ->enumNode('type') ->values(array('multiple_state', 'single_state')) ->end() ->arrayNode('arguments') ->beforeNormalization() ->ifString() ->then(function ($v) { return array($v); }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') ->end() ->end() ->scalarNode('service') ->cannotBeEmpty() ->end() ->end() ->validate() ->ifTrue(function ($v) { return isset($v['type']) && isset($v['service']); }) ->thenInvalid('"type" and "service" cannot be used together.') ->end() ->validate() ->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); }) ->thenInvalid('"arguments" and "service" cannot be used together.') ->end() ->end() ->arrayNode('supports') ->beforeNormalization() ->ifString() ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar') ->cannotBeEmpty() ->validate() ->ifTrue(function ($v) { return !class_exists($v); }) ->thenInvalid('The supported class %s does not exist.') ->end() ->end() ->end() ->scalarNode('support_strategy') ->cannotBeEmpty() ->end() ->scalarNode('initial_place') ->defaultNull() ->end() ->arrayNode('places') ->isRequired() ->requiresAtLeastOneElement() ->prototype('scalar') ->cannotBeEmpty() ->end() ->end() ->arrayNode('transitions') ->beforeNormalization() ->always() ->then(function ($transitions) { // It's an indexed array, we let the validation occurs if (isset($transitions[0])) { return $transitions; } foreach ($transitions as $name => $transition) { if (array_key_exists('name', $transition)) { continue; } $transition['name'] = $name; $transitions[$name] = $transition; } return $transitions; }) ->end() ->isRequired() ->requiresAtLeastOneElement() ->prototype('array') ->children() ->scalarNode('name') ->isRequired() ->cannotBeEmpty() ->end() ->scalarNode('guard') ->cannotBeEmpty() ->info('An expression to block the transition') ->example('is_fully_authenticated() and has_role(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'') ->end() ->arrayNode('from') ->beforeNormalization() ->ifString() ->then(function ($v) { return array($v); }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') ->cannotBeEmpty() ->end() ->end() ->arrayNode('to') ->beforeNormalization() ->ifString() ->then(function ($v) { return array($v); }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') ->cannotBeEmpty() ->end() ->end() ->end() ->end() ->end() ->end() ->validate() ->ifTrue(function ($v) { return $v['supports'] && isset($v['support_strategy']); }) ->thenInvalid('"supports" and "support_strategy" cannot be used together.') ->end() ->validate() ->ifTrue(function ($v) { return !$v['supports'] && !isset($v['support_strategy']); }) ->thenInvalid('"supports" or "support_strategy" should be configured.') ->end() ->end() ->end() ->end() ->end() ->end() ; } private function addRouterSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('router') ->info('router configuration') ->canBeEnabled() ->children() ->scalarNode('resource')->isRequired()->end() ->scalarNode('type')->end() ->scalarNode('http_port')->defaultValue(80)->end() ->scalarNode('https_port')->defaultValue(443)->end() ->scalarNode('strict_requirements') ->info( "set to true to throw an exception when a parameter does not match the requirements\n". "set to false to disable exceptions when a parameter does not match the requirements (and return null instead)\n". "set to null to disable parameter checks against requirements\n". "'true' is the preferred configuration in development mode, while 'false' or 'null' might be preferred in production" ) ->defaultTrue() ->end() ->end() ->end() ->end() ; } private function addSessionSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('session') ->info('session configuration') ->canBeEnabled() ->children() ->scalarNode('storage_id')->defaultValue('session.storage.native')->end() ->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end() ->scalarNode('name')->end() ->scalarNode('cookie_lifetime')->end() ->scalarNode('cookie_path')->end() ->scalarNode('cookie_domain')->end() ->booleanNode('cookie_secure')->end() ->booleanNode('cookie_httponly')->defaultTrue()->end() ->booleanNode('use_cookies')->end() ->scalarNode('gc_divisor')->end() ->scalarNode('gc_probability')->defaultValue(1)->end() ->scalarNode('gc_maxlifetime')->end() ->booleanNode('use_strict_mode') ->defaultTrue() ->setDeprecated('The "%path%.%node%" option is enabled by default and deprecated since Symfony 3.4. It will be always enabled in 4.0.') ->end() ->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end() ->integerNode('metadata_update_threshold') ->defaultValue('0') ->info('seconds to wait between 2 session metadata updates') ->end() ->end() ->end() ->end() ; } private function addRequestSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('request') ->info('request configuration') ->canBeEnabled() ->fixXmlConfig('format') ->children() ->arrayNode('formats') ->useAttributeAsKey('name') ->prototype('array') ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && isset($v['mime_type']); }) ->then(function ($v) { return $v['mime_type']; }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v); }) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ; } private function addTemplatingSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('templating') ->info('templating configuration') ->canBeEnabled() ->beforeNormalization() ->ifTrue(function ($v) { return false === $v || is_array($v) && false === $v['enabled']; }) ->then(function () { return array('enabled' => false, 'engines' => false); }) ->end() ->children() ->scalarNode('hinclude_default_template')->defaultNull()->end() ->scalarNode('cache')->end() ->arrayNode('form') ->addDefaultsIfNotSet() ->fixXmlConfig('resource') ->children() ->arrayNode('resources') ->addDefaultChildrenIfNoneSet() ->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end() ->validate() ->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); }) ->then(function ($v) { return array_merge(array('FrameworkBundle:Form'), $v); }) ->end() ->end() ->end() ->end() ->end() ->fixXmlConfig('engine') ->children() ->arrayNode('engines') ->example(array('twig')) ->isRequired() ->requiresAtLeastOneElement() ->canBeUnset() ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v) && false !== $v; }) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->fixXmlConfig('loader') ->children() ->arrayNode('loaders') ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v); }) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ; } private function addAssetsSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('assets') ->info('assets configuration') ->{!class_exists(FullStack::class) && class_exists(Package::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->fixXmlConfig('base_url') ->children() ->scalarNode('version_strategy')->defaultNull()->end() ->scalarNode('version')->defaultNull()->end() ->scalarNode('version_format')->defaultValue('%%s?%%s')->end() ->scalarNode('json_manifest_path')->defaultNull()->end() ->scalarNode('base_path')->defaultValue('')->end() ->arrayNode('base_urls') ->requiresAtLeastOneElement() ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v); }) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version_strategy']) && isset($v['version']); }) ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets".') ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version_strategy']) && isset($v['json_manifest_path']); }) ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".') ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version']) && isset($v['json_manifest_path']); }) ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets".') ->end() ->fixXmlConfig('package') ->children() ->arrayNode('packages') ->useAttributeAsKey('name') ->prototype('array') ->fixXmlConfig('base_url') ->children() ->scalarNode('version_strategy')->defaultNull()->end() ->scalarNode('version') ->beforeNormalization() ->ifTrue(function ($v) { return '' === $v; }) ->then(function ($v) { return; }) ->end() ->end() ->scalarNode('version_format')->defaultNull()->end() ->scalarNode('json_manifest_path')->defaultNull()->end() ->scalarNode('base_path')->defaultValue('')->end() ->arrayNode('base_urls') ->requiresAtLeastOneElement() ->beforeNormalization() ->ifTrue(function ($v) { return !is_array($v); }) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version_strategy']) && isset($v['version']); }) ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets" packages.') ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version_strategy']) && isset($v['json_manifest_path']); }) ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.') ->end() ->validate() ->ifTrue(function ($v) { return isset($v['version']) && isset($v['json_manifest_path']); }) ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.') ->end() ->end() ->end() ->end() ->end() ->end() ; } private function addTranslatorSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('translator') ->info('translator configuration') ->{!class_exists(FullStack::class) && class_exists(Translator::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->fixXmlConfig('fallback') ->fixXmlConfig('path') ->children() ->arrayNode('fallbacks') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->defaultValue(array('en')) ->end() ->booleanNode('logging')->defaultValue($this->debug)->end() ->scalarNode('formatter')->defaultValue('translator.formatter.default')->end() ->scalarNode('default_path') ->info('The default path used to load translations') ->defaultValue('%kernel.project_dir%/translations') ->end() ->arrayNode('paths') ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ; } private function addValidationSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('validation') ->info('validation configuration') ->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() ->scalarNode('cache') // Can be removed in 4.0, when validator.mapping.cache.doctrine.apc is removed ->setDeprecated('The "%path%.%node%" option is deprecated since Symfony 3.2 and will be removed in 4.0. Configure the "cache.validator" service under "framework.cache.pools" instead.') ->beforeNormalization() ->ifString()->then(function ($v) { if ('validator.mapping.cache.doctrine.apc' === $v && !class_exists('Doctrine\Common\Cache\ApcCache')) { throw new LogicException('Doctrine APC cache for the validator cannot be enabled as the Doctrine Cache package is not installed.'); } return $v; }) ->end() ->end() ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() ->arrayNode('static_method') ->defaultValue(array('loadValidatorMetadata')) ->prototype('scalar')->end() ->treatFalseLike(array()) ->validate() ->ifTrue(function ($v) { return !is_array($v); }) ->then(function ($v) { return (array) $v; }) ->end() ->end() ->scalarNode('translation_domain')->defaultValue('validators')->end() ->booleanNode('strict_email')->defaultFalse()->end() ->arrayNode('mapping') ->addDefaultsIfNotSet() ->fixXmlConfig('path') ->children() ->arrayNode('paths') ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ->end() ; } private function addAnnotationsSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('annotations') ->info('annotation configuration') ->{class_exists(Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() ->scalarNode('cache')->defaultValue(interface_exists(Cache::class) ? 'php_array' : 'none')->end() ->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end() ->booleanNode('debug')->defaultValue($this->debug)->end() ->end() ->end() ->end() ; } private function addSerializerSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('serializer') ->info('serializer configuration') ->{!class_exists(FullStack::class) && class_exists(Serializer::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() ->scalarNode('cache') ->setDeprecated('The "%path%.%node%" option is deprecated since Symfony 3.1 and will be removed in 4.0. Configure the "cache.serializer" service under "framework.cache.pools" instead.') ->end() ->scalarNode('name_converter')->end() ->scalarNode('circular_reference_handler')->end() ->arrayNode('mapping') ->addDefaultsIfNotSet() ->fixXmlConfig('path') ->children() ->arrayNode('paths') ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ->end() ; } private function addPropertyAccessSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('property_access') ->addDefaultsIfNotSet() ->info('Property access configuration') ->children() ->booleanNode('magic_call')->defaultFalse()->end() ->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end() ->end() ->end() ->end() ; } private function addPropertyInfoSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('property_info') ->info('Property info configuration') ->canBeEnabled() ->end() ->end() ; } private function addCacheSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('cache') ->info('Cache configuration') ->addDefaultsIfNotSet() ->fixXmlConfig('pool') ->children() ->scalarNode('prefix_seed') ->info('Used to namespace cache keys when using several apps with the same shared backend') ->example('my-application-name') ->end() ->scalarNode('app') ->info('App related cache pools configuration') ->defaultValue('cache.adapter.filesystem') ->end() ->scalarNode('system') ->info('System related cache pools configuration') ->defaultValue('cache.adapter.system') ->end() ->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools')->end() ->scalarNode('default_doctrine_provider')->end() ->scalarNode('default_psr6_provider')->end() ->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end() ->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end() ->arrayNode('pools') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('adapter')->defaultValue('cache.app')->end() ->booleanNode('public')->defaultFalse()->end() ->integerNode('default_lifetime')->end() ->scalarNode('provider') ->info('The service name to use as provider when the specified adapter needs one.') ->end() ->scalarNode('clearer')->end() ->end() ->end() ->validate() ->ifTrue(function ($v) { return isset($v['cache.app']) || isset($v['cache.system']); }) ->thenInvalid('"cache.app" and "cache.system" are reserved names') ->end() ->end() ->end() ->end() ->end() ; } private function addPhpErrorsSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('php_errors') ->info('PHP errors handling configuration') ->addDefaultsIfNotSet() ->children() ->booleanNode('log') ->info('Use the app logger instead of the PHP logger for logging PHP errors.') ->defaultValue($this->debug) ->treatNullLike($this->debug) ->end() ->booleanNode('throw') ->info('Throw PHP errors as \ErrorException instances.') ->defaultValue($this->debug) ->treatNullLike($this->debug) ->end() ->end() ->end() ->end() ; } private function addLockSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('lock') ->info('Lock configuration') ->{!class_exists(FullStack::class) && class_exists(Lock::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->beforeNormalization() ->ifString()->then(function ($v) { return array('enabled' => true, 'resources' => $v); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && !isset($v['resources']); }) ->then(function ($v) { $e = $v['enabled']; unset($v['enabled']); return array('enabled' => $e, 'resources' => $v); }) ->end() ->addDefaultsIfNotSet() ->fixXmlConfig('resource') ->children() ->arrayNode('resources') ->requiresAtLeastOneElement() ->defaultValue(array('default' => array(class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock'))) ->beforeNormalization() ->ifString()->then(function ($v) { return array('default' => $v); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && array_keys($v) === range(0, count($v) - 1); }) ->then(function ($v) { return array('default' => $v); }) ->end() ->prototype('array') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ; } private function addWebLinkSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('web_link') ->info('web links configuration') ->{!class_exists(FullStack::class) && class_exists(HttpHeaderSerializer::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->end() ->end() ; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php���������0000664�0000000�0000000�00000242723�13247321071�0032261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\Monolog\Processor\DebugProcessor; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader; use Symfony\Bundle\FullStack; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\DirectoryResource; use Symfony\Component\Config\ResourceCheckerInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Finder\Finder; use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\Lock\Factory; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\Store\StoreFactory; use Symfony\Component\Lock\StoreInterface; use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader; use Symfony\Component\Routing\Loader\AnnotationFileLoader; use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Serializer\Encoder\DecoderInterface; use Symfony\Component\Serializer\Encoder\EncoderInterface; use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand; use Symfony\Component\Translation\Translator; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\ObjectInitializerInterface; use Symfony\Component\WebLink\HttpHeaderSerializer; use Symfony\Component\Workflow; use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand; use Symfony\Component\Yaml\Yaml; /** * FrameworkExtension. * * @author Fabien Potencier <fabien@symfony.com> * @author Jeremy Mikola <jmikola@gmail.com> * @author Kévin Dunglas <dunglas@gmail.com> * @author Grégoire Pineau <lyrixx@lyrixx.info> */ class FrameworkExtension extends Extension { private $formConfigEnabled = false; private $translationConfigEnabled = false; private $sessionConfigEnabled = false; private $annotationsConfigEnabled = false; private $validatorConfigEnabled = false; /** * @var string|null */ private $kernelRootHash; /** * Responds to the app.config configuration parameter. * * @throws LogicException */ public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config')); $loader->load('web.xml'); $loader->load('services.xml'); $container->getDefinition('kernel.class_cache.cache_warmer')->setPrivate(true); $container->getDefinition('uri_signer')->setPrivate(true); $container->getDefinition('config_cache_factory')->setPrivate(true); $container->getDefinition('response_listener')->setPrivate(true); $container->getDefinition('file_locator')->setPrivate(true); $container->getDefinition('streamed_response_listener')->setPrivate(true); $container->getDefinition('locale_listener')->setPrivate(true); $container->getDefinition('validate_request_listener')->setPrivate(true); // forward compatibility with Symfony 4.0 where the ContainerAwareEventDispatcher class is removed if (!class_exists(ContainerAwareEventDispatcher::class)) { $definition = $container->getDefinition('event_dispatcher'); $definition->setClass(EventDispatcher::class); $definition->setArguments(array()); } if (\PHP_VERSION_ID < 70000) { $definition = $container->getDefinition('kernel.class_cache.cache_warmer'); $definition->addTag('kernel.cache_warmer'); // Ignore deprecation for PHP versions below 7.0 $definition->setDeprecated(false); } $loader->load('fragment_renderer.xml'); $container->getDefinition('fragment.handler')->setPrivate(true); $container->getDefinition('fragment.renderer.inline')->setPrivate(true); $container->getDefinition('fragment.renderer.hinclude')->setPrivate(true); $container->getDefinition('fragment.renderer.esi')->setPrivate(true); $container->getDefinition('fragment.renderer.ssi')->setPrivate(true); if (class_exists(Application::class)) { $loader->load('console.xml'); if (!class_exists(BaseXliffLintCommand::class)) { $container->removeDefinition('console.command.xliff_lint'); } if (!class_exists(BaseYamlLintCommand::class)) { $container->removeDefinition('console.command.yaml_lint'); } } // Load Cache configuration first as it is used by other components $loader->load('cache.xml'); $container->getDefinition('cache.adapter.system')->setPrivate(true); $container->getDefinition('cache.adapter.apcu')->setPrivate(true); $container->getDefinition('cache.adapter.doctrine')->setPrivate(true); $container->getDefinition('cache.adapter.filesystem')->setPrivate(true); $container->getDefinition('cache.adapter.psr6')->setPrivate(true); $container->getDefinition('cache.adapter.redis')->setPrivate(true); $container->getDefinition('cache.adapter.memcached')->setPrivate(true); $container->getDefinition('cache.default_clearer')->setPrivate(true); $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']); $this->translationConfigEnabled = $this->isConfigEnabled($container, $config['translator']); // A translator must always be registered (as support is included by // default in the Form and Validator component). If disabled, an identity // translator will be used and everything will still work as expected. if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.'); } if (class_exists(Translator::class)) { $loader->load('identity_translator.xml'); } } if (isset($config['secret'])) { $container->setParameter('kernel.secret', $config['secret']); } $container->setParameter('kernel.http_method_override', $config['http_method_override']); $container->setParameter('kernel.trusted_hosts', $config['trusted_hosts']); if ($config['trusted_proxies']) { $container->setParameter('kernel.trusted_proxies', $config['trusted_proxies']); } $container->setParameter('kernel.default_locale', $config['default_locale']); if (!$container->hasParameter('debug.file_link_format')) { if (!$container->hasParameter('templating.helper.code.file_link_format')) { $links = array( 'textmate' => 'txmt://open?url=file://%%f&line=%%l', 'macvim' => 'mvim://open?url=file://%%f&line=%%l', 'emacs' => 'emacs://open?url=file://%%f&line=%%l', 'sublime' => 'subl://open?url=file://%%f&line=%%l', 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l', ); $ide = $config['ide']; $container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide)); } $container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%'); } if (!empty($config['test'])) { $loader->load('test.xml'); $container->getDefinition('test.client.history')->setPrivate(true); $container->getDefinition('test.client.cookiejar')->setPrivate(true); $container->getDefinition('test.session.listener')->setPrivate(true); } if ($this->isConfigEnabled($container, $config['session'])) { $this->sessionConfigEnabled = true; $this->registerSessionConfiguration($config['session'], $container, $loader); } if ($this->isConfigEnabled($container, $config['request'])) { $this->registerRequestConfiguration($config['request'], $container, $loader); } if (null === $config['csrf_protection']['enabled']) { $config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class); } $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader); if ($this->isConfigEnabled($container, $config['form'])) { if (!class_exists('Symfony\Component\Form\Form')) { throw new LogicException('Form support cannot be enabled as the Form component is not installed.'); } $this->formConfigEnabled = true; $this->registerFormConfiguration($config, $container, $loader); if (class_exists('Symfony\Component\Validator\Validation')) { $config['validation']['enabled'] = true; } else { $container->setParameter('validator.translation_domain', 'validators'); $container->removeDefinition('form.type_extension.form.validator'); $container->removeDefinition('form.type_guesser.validator'); } } else { $container->removeDefinition('console.command.form_debug'); } if ($this->isConfigEnabled($container, $config['assets'])) { if (!class_exists('Symfony\Component\Asset\Package')) { throw new LogicException('Asset support cannot be enabled as the Asset component is not installed.'); } $this->registerAssetsConfiguration($config['assets'], $container, $loader); } if ($this->isConfigEnabled($container, $config['templating'])) { if (!class_exists('Symfony\Component\Templating\PhpEngine')) { throw new LogicException('Templating support cannot be enabled as the Templating component is not installed.'); } $this->registerTemplatingConfiguration($config['templating'], $container, $loader); } $this->registerValidationConfiguration($config['validation'], $container, $loader); $this->registerEsiConfiguration($config['esi'], $container, $loader); $this->registerSsiConfiguration($config['ssi'], $container, $loader); $this->registerFragmentsConfiguration($config['fragments'], $container, $loader); $this->registerTranslatorConfiguration($config['translator'], $container, $loader); $this->registerProfilerConfiguration($config['profiler'], $container, $loader); $this->registerCacheConfiguration($config['cache'], $container); $this->registerWorkflowConfiguration($config['workflows'], $container, $loader); $this->registerDebugConfiguration($config['php_errors'], $container, $loader); $this->registerRouterConfiguration($config['router'], $container, $loader); $this->registerAnnotationsConfiguration($config['annotations'], $container, $loader); $this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader); if ($this->isConfigEnabled($container, $config['serializer'])) { if (!class_exists('Symfony\Component\Serializer\Serializer')) { throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed.'); } $this->registerSerializerConfiguration($config['serializer'], $container, $loader); } if ($this->isConfigEnabled($container, $config['property_info'])) { $this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader); } if ($this->isConfigEnabled($container, $config['lock'])) { $this->registerLockConfiguration($config['lock'], $container, $loader); } if ($this->isConfigEnabled($container, $config['web_link'])) { if (!class_exists(HttpHeaderSerializer::class)) { throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed.'); } $loader->load('web_link.xml'); } $this->addAnnotatedClassesToCompile(array( '**\\Controller\\', '**\\Entity\\', // Added explicitly so that we don't rely on the class map being dumped to make it work 'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller', )); $container->registerForAutoconfiguration(Command::class) ->addTag('console.command'); $container->registerForAutoconfiguration(ResourceCheckerInterface::class) ->addTag('config_cache.resource_checker'); $container->registerForAutoconfiguration(EnvVarProcessorInterface::class) ->addTag('container.env_var_processor'); $container->registerForAutoconfiguration(ServiceSubscriberInterface::class) ->addTag('container.service_subscriber'); $container->registerForAutoconfiguration(ArgumentValueResolverInterface::class) ->addTag('controller.argument_value_resolver'); $container->registerForAutoconfiguration(AbstractController::class) ->addTag('controller.service_arguments'); $container->registerForAutoconfiguration(Controller::class) ->addTag('controller.service_arguments'); $container->registerForAutoconfiguration(DataCollectorInterface::class) ->addTag('data_collector'); $container->registerForAutoconfiguration(FormTypeInterface::class) ->addTag('form.type'); $container->registerForAutoconfiguration(FormTypeGuesserInterface::class) ->addTag('form.type_guesser'); $container->registerForAutoconfiguration(CacheClearerInterface::class) ->addTag('kernel.cache_clearer'); $container->registerForAutoconfiguration(CacheWarmerInterface::class) ->addTag('kernel.cache_warmer'); $container->registerForAutoconfiguration(EventSubscriberInterface::class) ->addTag('kernel.event_subscriber'); $container->registerForAutoconfiguration(ResettableInterface::class) ->addTag('kernel.reset', array('method' => 'reset')); $container->registerForAutoconfiguration(PropertyListExtractorInterface::class) ->addTag('property_info.list_extractor'); $container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class) ->addTag('property_info.type_extractor'); $container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class) ->addTag('property_info.description_extractor'); $container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class) ->addTag('property_info.access_extractor'); $container->registerForAutoconfiguration(EncoderInterface::class) ->addTag('serializer.encoder'); $container->registerForAutoconfiguration(DecoderInterface::class) ->addTag('serializer.encoder'); $container->registerForAutoconfiguration(NormalizerInterface::class) ->addTag('serializer.normalizer'); $container->registerForAutoconfiguration(DenormalizerInterface::class) ->addTag('serializer.normalizer'); $container->registerForAutoconfiguration(ConstraintValidatorInterface::class) ->addTag('validator.constraint_validator'); $container->registerForAutoconfiguration(ObjectInitializerInterface::class) ->addTag('validator.initializer'); if (!$container->getParameter('kernel.debug')) { // remove tagged iterator argument for resource checkers $container->getDefinition('config_cache_factory')->setArguments(array()); } if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Component\\Config\\ConfigCache', 'Symfony\\Component\\Config\\FileLocator', 'Symfony\\Component\\Debug\\ErrorHandler', 'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'Symfony\\Component\\DependencyInjection\\Container', 'Symfony\\Component\\EventDispatcher\\Event', 'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher', 'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener', 'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener', 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', 'Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver', 'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata', 'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadataFactory', 'Symfony\\Component\\HttpKernel\\Event\\KernelEvent', 'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent', 'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent', 'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent', 'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent', 'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent', 'Symfony\\Component\\HttpKernel\\HttpKernel', 'Symfony\\Component\\HttpKernel\\KernelEvents', 'Symfony\\Component\\HttpKernel\\Config\\FileLocator', 'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerNameParser', 'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver', // Cannot be included because annotations will parse the big compiled class file // 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller', // cannot be included as commands are discovered based on the path to this class via Reflection // 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle', )); } } /** * {@inheritdoc} */ public function getConfiguration(array $config, ContainerBuilder $container) { return new Configuration($container->getParameter('kernel.debug')); } private function registerFormConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('form.xml'); $container->getDefinition('form.resolved_type_factory')->setPrivate(true); $container->getDefinition('form.registry')->setPrivate(true); $container->getDefinition('form.type_guesser.validator')->setPrivate(true); $container->getDefinition('form.type.form')->setPrivate(true); $container->getDefinition('form.type.choice')->setPrivate(true); $container->getDefinition('form.type_extension.form.http_foundation')->setPrivate(true); $container->getDefinition('form.type_extension.form.validator')->setPrivate(true); $container->getDefinition('form.type_extension.repeated.validator')->setPrivate(true); $container->getDefinition('form.type_extension.submit.validator')->setPrivate(true); $container->getDefinition('form.type_extension.upload.validator')->setPrivate(true); $container->getDefinition('deprecated.form.registry')->setPrivate(true); if (null === $config['form']['csrf_protection']['enabled']) { $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled']; } if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) { $loader->load('form_csrf.xml'); $container->getDefinition('form.type_extension.csrf')->setPrivate(true); $container->getDefinition('deprecated.form.registry.csrf')->setPrivate(true); $container->setParameter('form.type_extension.csrf.enabled', true); $container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']); } else { $container->setParameter('form.type_extension.csrf.enabled', false); } if (!class_exists(Translator::class)) { $container->removeDefinition('form.type_extension.upload.validator'); } } private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { $container->removeDefinition('fragment.renderer.esi'); return; } $loader->load('esi.xml'); $container->getDefinition('esi')->setPrivate(true); $container->getDefinition('esi_listener')->setPrivate(true); } private function registerSsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { $container->removeDefinition('fragment.renderer.ssi'); return; } $loader->load('ssi.xml'); $container->getDefinition('ssi')->setPrivate(true); $container->getDefinition('ssi_listener')->setPrivate(true); } private function registerFragmentsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { $container->removeDefinition('fragment.renderer.hinclude'); return; } $loader->load('fragment_listener.xml'); $container->setParameter('fragment.path', $config['path']); } private function registerProfilerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { // this is needed for the WebProfiler to work even if the profiler is disabled $container->setParameter('data_collector.templates', array()); return; } $loader->load('profiling.xml'); $loader->load('collectors.xml'); $loader->load('cache_debug.xml'); $container->getDefinition('data_collector.request')->setPrivate(true); $container->getDefinition('data_collector.router')->setPrivate(true); $container->getDefinition('profiler_listener')->setPrivate(true); if ($this->formConfigEnabled) { $loader->load('form_debug.xml'); $container->getDefinition('form.resolved_type_factory')->setPrivate(true); $container->getDefinition('data_collector.form.extractor')->setPrivate(true); $container->getDefinition('data_collector.form')->setPrivate(true); } if ($this->validatorConfigEnabled) { $loader->load('validator_debug.xml'); } if ($this->translationConfigEnabled) { $loader->load('translation_debug.xml'); $container->getDefinition('data_collector.translation')->setPrivate(true); $container->getDefinition('translator.data_collector')->setDecoratedService('translator'); } $container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']); $container->setParameter('profiler_listener.only_master_requests', $config['only_master_requests']); // Choose storage class based on the DSN list($class) = explode(':', $config['dsn'], 2); if ('file' !== $class) { throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.', $class)); } $container->setParameter('profiler.storage.dsn', $config['dsn']); if ($this->isConfigEnabled($container, $config['matcher'])) { if (isset($config['matcher']['service'])) { $container->setAlias('profiler.request_matcher', $config['matcher']['service'])->setPrivate(true); } elseif (isset($config['matcher']['ip']) || isset($config['matcher']['path']) || isset($config['matcher']['ips'])) { $definition = $container->register('profiler.request_matcher', 'Symfony\\Component\\HttpFoundation\\RequestMatcher'); $definition->setPublic(false); if (isset($config['matcher']['ip'])) { $definition->addMethodCall('matchIp', array($config['matcher']['ip'])); } if (isset($config['matcher']['ips'])) { $definition->addMethodCall('matchIps', array($config['matcher']['ips'])); } if (isset($config['matcher']['path'])) { $definition->addMethodCall('matchPath', array($config['matcher']['path'])); } } } $container->getDefinition('profiler') ->addArgument($config['collect']) ->addTag('kernel.reset', array('method' => 'reset')); } private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$config['enabled']) { $container->removeDefinition('console.command.workflow_dump'); return; } if (!class_exists(Workflow\Workflow::class)) { throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed.'); } $loader->load('workflow.xml'); $container->getDefinition('workflow.marking_store.multiple_state')->setPrivate(true); $container->getDefinition('workflow.marking_store.single_state')->setPrivate(true); $container->getDefinition('workflow.registry')->setPrivate(true); $registryDefinition = $container->getDefinition('workflow.registry'); foreach ($config['workflows'] as $name => $workflow) { if (!array_key_exists('type', $workflow)) { $workflow['type'] = 'workflow'; @trigger_error(sprintf('The "type" option of the "framework.workflows.%s" configuration entry must be defined since Symfony 3.3. The default value will be "state_machine" in Symfony 4.0.', $name), E_USER_DEPRECATED); } $type = $workflow['type']; $transitions = array(); foreach ($workflow['transitions'] as $transition) { if ('workflow' === $type) { $transitions[] = new Definition(Workflow\Transition::class, array($transition['name'], $transition['from'], $transition['to'])); } elseif ('state_machine' === $type) { foreach ($transition['from'] as $from) { foreach ($transition['to'] as $to) { $transitions[] = new Definition(Workflow\Transition::class, array($transition['name'], $from, $to)); } } } } // Create a Definition $definitionDefinition = new Definition(Workflow\Definition::class); $definitionDefinition->setPublic(false); $definitionDefinition->addArgument($workflow['places']); $definitionDefinition->addArgument($transitions); $definitionDefinition->addTag('workflow.definition', array( 'name' => $name, 'type' => $type, 'marking_store' => isset($workflow['marking_store']['type']) ? $workflow['marking_store']['type'] : null, )); if (isset($workflow['initial_place'])) { $definitionDefinition->addArgument($workflow['initial_place']); } // Create MarkingStore if (isset($workflow['marking_store']['type'])) { $markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']); foreach ($workflow['marking_store']['arguments'] as $argument) { $markingStoreDefinition->addArgument($argument); } } elseif (isset($workflow['marking_store']['service'])) { $markingStoreDefinition = new Reference($workflow['marking_store']['service']); } // Create Workflow $workflowId = sprintf('%s.%s', $type, $name); $workflowDefinition = new ChildDefinition(sprintf('%s.abstract', $type)); $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition', $workflowId))); if (isset($markingStoreDefinition)) { $workflowDefinition->replaceArgument(1, $markingStoreDefinition); } $workflowDefinition->replaceArgument(3, $name); // Store to container $container->setDefinition($workflowId, $workflowDefinition); $container->setDefinition(sprintf('%s.definition', $workflowId), $definitionDefinition); // Add workflow to Registry if ($workflow['supports']) { foreach ($workflow['supports'] as $supportedClassName) { $strategyDefinition = new Definition(Workflow\SupportStrategy\ClassInstanceSupportStrategy::class, array($supportedClassName)); $strategyDefinition->setPublic(false); $registryDefinition->addMethodCall('add', array(new Reference($workflowId), $strategyDefinition)); } } elseif (isset($workflow['support_strategy'])) { $registryDefinition->addMethodCall('add', array(new Reference($workflowId), new Reference($workflow['support_strategy']))); } // Enable the AuditTrail if ($workflow['audit_trail']['enabled']) { $listener = new Definition(Workflow\EventListener\AuditTrailListener::class); $listener->setPrivate(true); $listener->addTag('monolog.logger', array('channel' => 'workflow')); $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave')); $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition')); $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter')); $listener->addArgument(new Reference('logger')); $container->setDefinition(sprintf('%s.listener.audit_trail', $workflowId), $listener); } // Add Guard Listener $guard = new Definition(Workflow\EventListener\GuardListener::class); $guard->setPrivate(true); $configuration = array(); foreach ($workflow['transitions'] as $transitionName => $config) { if (!isset($config['guard'])) { continue; } if (!class_exists(ExpressionLanguage::class)) { throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed.'); } if (!class_exists(Security::class)) { throw new LogicException('Cannot guard workflows as the Security component is not installed.'); } $eventName = sprintf('workflow.%s.guard.%s', $name, $transitionName); $guard->addTag('kernel.event_listener', array('event' => $eventName, 'method' => 'onTransition')); $configuration[$eventName] = $config['guard']; } if ($configuration) { $guard->setArguments(array( $configuration, new Reference('workflow.security.expression_language'), new Reference('security.token_storage'), new Reference('security.authorization_checker'), new Reference('security.authentication.trust_resolver'), new Reference('security.role_hierarchy'), new Reference('validator', ContainerInterface::NULL_ON_INVALID_REFERENCE), )); $container->setDefinition(sprintf('%s.listener.guard', $workflowId), $guard); $container->setParameter('workflow.has_guard_listeners', true); } } } private function registerDebugConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('debug_prod.xml'); $container->getDefinition('debug.debug_handlers_listener')->setPrivate(true); if (class_exists(Stopwatch::class)) { $container->register('debug.stopwatch', Stopwatch::class) ->addArgument(true) ->setPrivate(true) ->addTag('kernel.reset', array('method' => 'reset')); $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch', false)); } $debug = $container->getParameter('kernel.debug'); if ($debug) { $container->setParameter('debug.container.dump', '%kernel.cache_dir%/%kernel.container_class%.xml'); } if ($debug && class_exists(Stopwatch::class)) { $loader->load('debug.xml'); $container->getDefinition('debug.event_dispatcher')->setPrivate(true); $container->getDefinition('debug.controller_resolver')->setPrivate(true); $container->getDefinition('debug.argument_resolver')->setPrivate(true); } $definition = $container->findDefinition('debug.debug_handlers_listener'); if (!$config['log']) { $definition->replaceArgument(1, null); } if (!$config['throw']) { $container->setParameter('debug.error_handler.throw_at', 0); } $definition->replaceArgument(4, $debug); $definition->replaceArgument(6, $debug); if ($debug && class_exists(DebugProcessor::class)) { $definition = new Definition(DebugProcessor::class); $definition->setPublic(false); $container->setDefinition('debug.log_processor', $definition); } } private function registerRouterConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { $container->removeDefinition('console.command.router_debug'); $container->removeDefinition('console.command.router_match'); return; } $loader->load('routing.xml'); $container->getDefinition('router_listener')->setPrivate(true); $container->setParameter('router.resource', $config['resource']); $container->setParameter('router.cache_class_prefix', $container->getParameter('kernel.container_class')); $router = $container->findDefinition('router.default'); $argument = $router->getArgument(2); $argument['strict_requirements'] = $config['strict_requirements']; if (isset($config['type'])) { $argument['resource_type'] = $config['type']; } $router->replaceArgument(2, $argument); $container->setParameter('request_listener.http_port', $config['http_port']); $container->setParameter('request_listener.https_port', $config['https_port']); if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 'Symfony\\Component\\Routing\\RequestContext', 'Symfony\\Component\\Routing\\Router', 'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher', $container->findDefinition('router.default')->getClass(), )); } if ($this->annotationsConfigEnabled) { $container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class) ->setPublic(false) ->addTag('routing.loader', array('priority' => -10)) ->addArgument(new Reference('annotation_reader')); $container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class) ->setPublic(false) ->addTag('routing.loader', array('priority' => -10)) ->setArguments(array( new Reference('file_locator'), new Reference('routing.loader.annotation'), )); $container->register('routing.loader.annotation.file', AnnotationFileLoader::class) ->setPublic(false) ->addTag('routing.loader', array('priority' => -10)) ->setArguments(array( new Reference('file_locator'), new Reference('routing.loader.annotation'), )); } } private function registerSessionConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('session.xml'); $container->getDefinition('session.storage.native')->setPrivate(true); $container->getDefinition('session.storage.php_bridge')->setPrivate(true); $container->getDefinition('session_listener')->setPrivate(true); $container->getDefinition('session.save_listener')->setPrivate(true); $container->getAlias('session.storage.filesystem')->setPrivate(true); // session storage $container->setAlias('session.storage', $config['storage_id'])->setPrivate(true); $options = array('cache_limiter' => '0'); foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode') as $key) { if (isset($config[$key])) { $options[$key] = $config[$key]; } } $container->setParameter('session.storage.options', $options); // session handler (the internal callback registered with PHP session management) if (null === $config['handler_id']) { // Set the handler class to be null $container->getDefinition('session.storage.native')->replaceArgument(1, null); $container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null); } else { $container->setAlias('session.handler', $config['handler_id'])->setPrivate(true); } $container->setParameter('session.save_path', $config['save_path']); if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Component\\HttpKernel\\EventListener\\SessionListener', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy', $container->getDefinition('session')->getClass(), )); if ($container->hasDefinition($config['storage_id'])) { $this->addClassesToCompile(array( $container->findDefinition('session.storage')->getClass(), )); } } $container->setParameter('session.metadata.update_threshold', $config['metadata_update_threshold']); } private function registerRequestConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if ($config['formats']) { $loader->load('request.xml'); $container->getDefinition('request.add_request_formats_listener')->setPrivate(true); $container ->getDefinition('request.add_request_formats_listener') ->replaceArgument(0, $config['formats']) ; } } private function registerTemplatingConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('templating.xml'); $container->getDefinition('templating.name_parser')->setPrivate(true); $container->getDefinition('templating.filename_parser')->setPrivate(true); $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']); if ($container->getParameter('kernel.debug')) { $logger = new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE); $container->getDefinition('templating.loader.cache') ->addTag('monolog.logger', array('channel' => 'templating')) ->addMethodCall('setLogger', array($logger)); $container->getDefinition('templating.loader.chain') ->addTag('monolog.logger', array('channel' => 'templating')) ->addMethodCall('setLogger', array($logger)); } if (!empty($config['loaders'])) { $loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']); // Use a delegation unless only a single loader was registered if (1 === count($loaders)) { $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true); } else { $container->getDefinition('templating.loader.chain')->addArgument($loaders); $container->setAlias('templating.loader', 'templating.loader.chain')->setPrivate(true); } } $container->setParameter('templating.loader.cache.path', null); if (isset($config['cache'])) { // Wrap the existing loader with cache (must happen after loaders are registered) $container->setDefinition('templating.loader.wrapped', $container->findDefinition('templating.loader')); $loaderCache = $container->getDefinition('templating.loader.cache'); $container->setParameter('templating.loader.cache.path', $config['cache']); $container->setDefinition('templating.loader', $loaderCache); } if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser', $container->findDefinition('templating.locator')->getClass(), )); } $container->setParameter('templating.engines', $config['engines']); $engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']); // Use a delegation unless only a single engine was registered if (1 === count($engines)) { $container->setAlias('templating', (string) reset($engines))->setPublic(true); } else { $templateEngineDefinition = $container->getDefinition('templating.engine.delegating'); foreach ($engines as $engine) { $templateEngineDefinition->addMethodCall('addEngine', array($engine)); } $container->setAlias('templating', 'templating.engine.delegating')->setPublic(true); } $container->getDefinition('fragment.renderer.hinclude') ->addTag('kernel.fragment_renderer', array('alias' => 'hinclude')) ->replaceArgument(0, new Reference('templating')) ; // configure the PHP engine if needed if (in_array('php', $config['engines'], true)) { $loader->load('templating_php.xml'); $container->getDefinition('templating.helper.slots')->setPrivate(true); $container->getDefinition('templating.helper.request')->setPrivate(true); $container->getDefinition('templating.helper.session')->setPrivate(true); $container->getDefinition('templating.helper.router')->setPrivate(true); $container->getDefinition('templating.helper.assets')->setPrivate(true); $container->getDefinition('templating.helper.actions')->setPrivate(true); $container->getDefinition('templating.helper.code')->setPrivate(true); $container->getDefinition('templating.helper.translator')->setPrivate(true); $container->getDefinition('templating.helper.form')->setPrivate(true); $container->getDefinition('templating.helper.stopwatch')->setPrivate(true); $container->getDefinition('templating.globals')->setPrivate(true); $container->setParameter('templating.helper.form.resources', $config['form']['resources']); if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { $loader->load('templating_debug.xml'); $container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php')); $container->setAlias('debug.templating.engine.php', 'templating.engine.php')->setPrivate(true); } if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Component\\Templating\\Storage\\FileStorage', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader', )); } if ($container->has('assets.packages')) { $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); } else { $container->removeDefinition('templating.helper.assets'); } if (!$this->translationConfigEnabled) { $container->removeDefinition('templating.helper.translator'); } } } private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('assets.xml'); $container->getDefinition('assets.packages')->setPrivate(true); $container->getDefinition('assets.context')->setPrivate(true); $container->getDefinition('assets.path_package')->setPrivate(true); $container->getDefinition('assets.url_package')->setPrivate(true); $container->getDefinition('assets.static_version_strategy')->setPrivate(true); $defaultVersion = null; if ($config['version_strategy']) { $defaultVersion = new Reference($config['version_strategy']); } else { $defaultVersion = $this->createVersion($container, $config['version'], $config['version_format'], $config['json_manifest_path'], '_default'); } $defaultPackage = $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion); $container->setDefinition('assets._default_package', $defaultPackage); $namedPackages = array(); foreach ($config['packages'] as $name => $package) { if (null !== $package['version_strategy']) { $version = new Reference($package['version_strategy']); } elseif (!array_key_exists('version', $package) && null === $package['json_manifest_path']) { // if neither version nor json_manifest_path are specified, use the default $version = $defaultVersion; } else { // let format fallback to main version_format $format = $package['version_format'] ?: $config['version_format']; $version = isset($package['version']) ? $package['version'] : null; $version = $this->createVersion($container, $version, $format, $package['json_manifest_path'], $name); } $container->setDefinition('assets._package_'.$name, $this->createPackageDefinition($package['base_path'], $package['base_urls'], $version)); $namedPackages[$name] = new Reference('assets._package_'.$name); } $container->getDefinition('assets.packages') ->replaceArgument(0, new Reference('assets._default_package')) ->replaceArgument(1, $namedPackages) ; } /** * Returns a definition for an asset package. */ private function createPackageDefinition($basePath, array $baseUrls, Reference $version) { if ($basePath && $baseUrls) { throw new \LogicException('An asset package cannot have base URLs and base paths.'); } $package = new ChildDefinition($baseUrls ? 'assets.url_package' : 'assets.path_package'); $package ->setPublic(false) ->replaceArgument(0, $baseUrls ?: $basePath) ->replaceArgument(1, $version) ; return $package; } private function createVersion(ContainerBuilder $container, $version, $format, $jsonManifestPath, $name) { // Configuration prevents $version and $jsonManifestPath from being set if (null !== $version) { $def = new ChildDefinition('assets.static_version_strategy'); $def ->replaceArgument(0, $version) ->replaceArgument(1, $format) ; $container->setDefinition('assets._version_'.$name, $def); return new Reference('assets._version_'.$name); } if (null !== $jsonManifestPath) { $def = new ChildDefinition('assets.json_manifest_version_strategy'); $def->replaceArgument(0, $jsonManifestPath); $container->setDefinition('assets._version_'.$name, $def); return new Reference('assets._version_'.$name); } return new Reference('assets.empty_version_strategy'); } private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader) { if (!$this->isConfigEnabled($container, $config)) { $container->removeDefinition('console.command.translation_debug'); $container->removeDefinition('console.command.translation_update'); return; } $loader->load('translation.xml'); $container->getDefinition('translator.default')->setPrivate(true); $container->getDefinition('translation.loader.php')->setPrivate(true); $container->getDefinition('translation.loader.yml')->setPrivate(true); $container->getDefinition('translation.loader.xliff')->setPrivate(true); $container->getDefinition('translation.loader.po')->setPrivate(true); $container->getDefinition('translation.loader.mo')->setPrivate(true); $container->getDefinition('translation.loader.qt')->setPrivate(true); $container->getDefinition('translation.loader.csv')->setPrivate(true); $container->getDefinition('translation.loader.res')->setPrivate(true); $container->getDefinition('translation.loader.dat')->setPrivate(true); $container->getDefinition('translation.loader.ini')->setPrivate(true); $container->getDefinition('translation.loader.json')->setPrivate(true); $container->getDefinition('translation.dumper.php')->setPrivate(true); $container->getDefinition('translation.dumper.xliff')->setPrivate(true); $container->getDefinition('translation.dumper.po')->setPrivate(true); $container->getDefinition('translation.dumper.mo')->setPrivate(true); $container->getDefinition('translation.dumper.yml')->setPrivate(true); $container->getDefinition('translation.dumper.qt')->setPrivate(true); $container->getDefinition('translation.dumper.csv')->setPrivate(true); $container->getDefinition('translation.dumper.ini')->setPrivate(true); $container->getDefinition('translation.dumper.json')->setPrivate(true); $container->getDefinition('translation.dumper.res')->setPrivate(true); $container->getDefinition('translation.extractor.php')->setPrivate(true); $container->getDefinition('translator_listener')->setPrivate(true); $container->getDefinition('translation.loader')->setPrivate(true); $container->getDefinition('translation.reader')->setPrivate(true); $container->getDefinition('translation.extractor')->setPrivate(true); $container->getDefinition('translation.writer')->setPrivate(true); // Use the "real" translator instead of the identity default $container->setAlias('translator', 'translator.default')->setPublic(true); $container->setAlias('translator.formatter', new Alias($config['formatter'], false)); $translator = $container->findDefinition('translator.default'); $translator->addMethodCall('setFallbackLocales', array($config['fallbacks'])); $container->setParameter('translator.logging', $config['logging']); $container->setParameter('translator.default_path', $config['default_path']); // Discover translation directories $dirs = array(); if (class_exists('Symfony\Component\Validator\Validation')) { $r = new \ReflectionClass('Symfony\Component\Validator\Validation'); $dirs[] = dirname($r->getFileName()).'/Resources/translations'; } if (class_exists('Symfony\Component\Form\Form')) { $r = new \ReflectionClass('Symfony\Component\Form\Form'); $dirs[] = dirname($r->getFileName()).'/Resources/translations'; } if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); $dirs[] = dirname(dirname($r->getFileName())).'/Resources/translations'; } $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); $rootDir = $container->getParameter('kernel.root_dir'); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { if ($container->fileExists($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { $dirs[] = $dir; } } foreach ($config['paths'] as $dir) { if ($container->fileExists($dir)) { $dirs[] = $dir; } else { throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir)); } } if ($container->fileExists($defaultDir)) { $dirs[] = $defaultDir; } if ($container->fileExists($dir = $rootDir.'/Resources/translations')) { $dirs[] = $dir; } // Register translation resources if ($dirs) { $files = array(); $finder = Finder::create() ->followLinks() ->files() ->filter(function (\SplFileInfo $file) { return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename()); }) ->in($dirs) ->sortByName() ; foreach ($finder as $file) { list(, $locale) = explode('.', $file->getBasename(), 3); if (!isset($files[$locale])) { $files[$locale] = array(); } $files[$locale][] = (string) $file; } $options = array_merge( $translator->getArgument(4), array('resource_files' => $files) ); $translator->replaceArgument(4, $options); } } private function registerValidationConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->validatorConfigEnabled = $this->isConfigEnabled($container, $config)) { return; } if (!class_exists('Symfony\Component\Validator\Validation')) { throw new LogicException('Validation support cannot be enabled as the Validator component is not installed.'); } $loader->load('validator.xml'); $container->getDefinition('validator.builder')->setPrivate(true); $container->getDefinition('validator.expression')->setPrivate(true); $container->getDefinition('validator.email')->setPrivate(true); $validatorBuilder = $container->getDefinition('validator.builder'); $container->setParameter('validator.translation_domain', $config['translation_domain']); $files = array('xml' => array(), 'yml' => array()); $this->registerValidatorMapping($container, $config, $files); if (!empty($files['xml'])) { $validatorBuilder->addMethodCall('addXmlMappings', array($files['xml'])); } if (!empty($files['yml'])) { $validatorBuilder->addMethodCall('addYamlMappings', array($files['yml'])); } $definition = $container->findDefinition('validator.email'); $definition->replaceArgument(0, $config['strict_email']); if (array_key_exists('enable_annotations', $config) && $config['enable_annotations']) { if (!$this->annotationsConfigEnabled) { throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.'); } $validatorBuilder->addMethodCall('enableAnnotationMapping', array(new Reference('annotation_reader'))); } if (array_key_exists('static_method', $config) && $config['static_method']) { foreach ($config['static_method'] as $methodName) { $validatorBuilder->addMethodCall('addMethodMapping', array($methodName)); } } if (isset($config['cache']) && $config['cache']) { $container->setParameter( 'validator.mapping.cache.prefix', 'validator_'.$this->getKernelRootHash($container) ); $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache']))); } elseif (!$container->getParameter('kernel.debug')) { $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference('validator.mapping.cache.symfony'))); } } private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files) { $fileRecorder = function ($extension, $path) use (&$files) { $files['yaml' === $extension ? 'yml' : $extension][] = $path; }; if (interface_exists('Symfony\Component\Form\FormInterface')) { $reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface'); $fileRecorder('xml', dirname($reflClass->getFileName()).'/Resources/config/validation.xml'); } foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) { $dirname = $bundle['path']; if ( $container->fileExists($file = $dirname.'/Resources/config/validation.yaml', false) || $container->fileExists($file = $dirname.'/Resources/config/validation.yml', false) ) { $fileRecorder('yml', $file); } if ($container->fileExists($file = $dirname.'/Resources/config/validation.xml', false)) { $fileRecorder('xml', $file); } if ($container->fileExists($dir = $dirname.'/Resources/config/validation', '/^$/')) { $this->registerMappingFilesFromDir($dir, $fileRecorder); } } $projectDir = $container->getParameter('kernel.project_dir'); if ($container->fileExists($dir = $projectDir.'/config/validator', '/^$/')) { $this->registerMappingFilesFromDir($dir, $fileRecorder); } $this->registerMappingFilesFromConfig($container, $config, $fileRecorder); } private function registerMappingFilesFromDir($dir, callable $fileRecorder) { foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) { $fileRecorder($file->getExtension(), $file->getRealPath()); } } private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder) { foreach ($config['mapping']['paths'] as $path) { if (is_dir($path)) { $this->registerMappingFilesFromDir($path, $fileRecorder); $container->addResource(new DirectoryResource($path, '/^$/')); } elseif ($container->fileExists($path, false)) { if (!preg_match('/\.(xml|ya?ml)$/', $path, $matches)) { throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.', $path)); } $fileRecorder($matches[1], $path); } else { throw new \RuntimeException(sprintf('Could not open file or directory "%s".', $path)); } } } private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, $loader) { if (!$this->annotationsConfigEnabled) { return; } if (!class_exists('Doctrine\Common\Annotations\Annotation')) { throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.'); } $loader->load('annotations.xml'); $container->getAlias('annotation_reader')->setPrivate(true); if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { $container->getDefinition('annotations.dummy_registry') ->setMethodCalls(array(array('registerLoader', array('class_exists')))); } if ('none' !== $config['cache']) { if (!class_exists('Doctrine\Common\Cache\CacheProvider')) { throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.'); } $cacheService = $config['cache']; if ('php_array' === $config['cache']) { $cacheService = 'annotations.cache'; // Enable warmer only if PHP array is used for cache $definition = $container->findDefinition('annotations.cache_warmer'); $definition->addTag('kernel.cache_warmer'); if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\Component\Cache\Adapter\PhpArrayAdapter', 'Symfony\Component\Cache\DoctrineProvider', )); } } elseif ('file' === $config['cache']) { $cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']); if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir)); } $container ->getDefinition('annotations.filesystem_cache') ->replaceArgument(0, $cacheDir) ; $cacheService = 'annotations.filesystem_cache'; } $container ->getDefinition('annotations.cached_reader') ->replaceArgument(2, $config['debug']) // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService))) ->addTag('annotations.cached_reader') ; $container->setAlias('annotation_reader', 'annotations.cached_reader')->setPrivate(true); $container->setAlias(Reader::class, new Alias('annotations.cached_reader', false)); } else { $container->removeDefinition('annotations.cached_reader'); } } private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { return; } $loader->load('property_access.xml'); $container->getDefinition('property_accessor')->setPrivate(true); $container ->getDefinition('property_accessor') ->replaceArgument(0, $config['magic_call']) ->replaceArgument(1, $config['throw_exception_on_invalid_index']) ; } private function registerSecurityCsrfConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { if (!$this->isConfigEnabled($container, $config)) { return; } if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) { throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".'); } if (!$this->sessionConfigEnabled) { throw new \LogicException('CSRF protection needs sessions to be enabled.'); } // Enable services for CSRF protection (even without forms) $loader->load('security_csrf.xml'); } private function registerSerializerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('serializer.xml'); if (!class_exists(DateIntervalNormalizer::class)) { $container->removeDefinition('serializer.normalizer.dateinterval'); } $container->getDefinition('serializer.mapping.cache.symfony')->setPrivate(true); $chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { $container->removeAlias('serializer.property_accessor'); $container->removeDefinition('serializer.normalizer.object'); } if (!class_exists(Yaml::class)) { $container->removeDefinition('serializer.encoder.yaml'); } $serializerLoaders = array(); if (isset($config['enable_annotations']) && $config['enable_annotations']) { if (!$this->annotationsConfigEnabled) { throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.'); } $annotationLoader = new Definition( 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', array(new Reference('annotation_reader')) ); $annotationLoader->setPublic(false); $serializerLoaders[] = $annotationLoader; } $fileRecorder = function ($extension, $path) use (&$serializerLoaders) { $definition = new Definition(in_array($extension, array('yaml', 'yml')) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($path)); $definition->setPublic(false); $serializerLoaders[] = $definition; }; foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) { $dirname = $bundle['path']; if ($container->fileExists($file = $dirname.'/Resources/config/serialization.xml', false)) { $fileRecorder('xml', $file); } if ( $container->fileExists($file = $dirname.'/Resources/config/serialization.yaml', false) || $container->fileExists($file = $dirname.'/Resources/config/serialization.yml', false) ) { $fileRecorder('yml', $file); } if ($container->fileExists($dir = $dirname.'/Resources/config/serialization', '/^$/')) { $this->registerMappingFilesFromDir($dir, $fileRecorder); } } $projectDir = $container->getParameter('kernel.project_dir'); if ($container->fileExists($dir = $projectDir.'/config/serializer', '/^$/')) { $this->registerMappingFilesFromDir($dir, $fileRecorder); } $this->registerMappingFilesFromConfig($container, $config, $fileRecorder); $chainLoader->replaceArgument(0, $serializerLoaders); $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0, $serializerLoaders); if (isset($config['cache']) && $config['cache']) { $container->setParameter( 'serializer.mapping.cache.prefix', 'serializer_'.$this->getKernelRootHash($container) ); $container->getDefinition('serializer.mapping.class_metadata_factory')->replaceArgument( 1, new Reference($config['cache']) ); } elseif (!$container->getParameter('kernel.debug')) { $cacheMetadataFactory = new Definition( CacheClassMetadataFactory::class, array( new Reference('serializer.mapping.cache_class_metadata_factory.inner'), new Reference('serializer.mapping.cache.symfony'), ) ); $cacheMetadataFactory->setPublic(false); $cacheMetadataFactory->setDecoratedService('serializer.mapping.class_metadata_factory'); $container->setDefinition('serializer.mapping.cache_class_metadata_factory', $cacheMetadataFactory); } if (isset($config['name_converter']) && $config['name_converter']) { $container->getDefinition('serializer.normalizer.object')->replaceArgument(1, new Reference($config['name_converter'])); } if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) { $container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', array(new Reference($config['circular_reference_handler']))); } } private function registerPropertyInfoConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('property_info.xml'); $container->getDefinition('property_info')->setPrivate(true); if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); $definition->setPrivate(true); $definition->addTag('property_info.description_extractor', array('priority' => -1000)); $definition->addTag('property_info.type_extractor', array('priority' => -1001)); } } private function registerLockConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('lock.xml'); foreach ($config['resources'] as $resourceName => $resourceStores) { if (0 === count($resourceStores)) { continue; } // Generate stores $storeDefinitions = array(); foreach ($resourceStores as $storeDsn) { $storeDsn = $container->resolveEnvPlaceholders($storeDsn, null, $usedEnvs); switch (true) { case 'flock' === $storeDsn: $storeDefinition = new Reference('lock.store.flock'); break; case 'semaphore' === $storeDsn: $storeDefinition = new Reference('lock.store.semaphore'); break; case $usedEnvs || preg_match('#^[a-z]++://#', $storeDsn): if (!$container->hasDefinition($connectionDefinitionId = $container->hash($storeDsn))) { $connectionDefinition = new Definition(\stdClass::class); $connectionDefinition->setPublic(false); $connectionDefinition->setFactory(array(AbstractAdapter::class, 'createConnection')); $connectionDefinition->setArguments(array($storeDsn, array('lazy' => true))); $container->setDefinition($connectionDefinitionId, $connectionDefinition); } $storeDefinition = new Definition(StoreInterface::class); $storeDefinition->setPublic(false); $storeDefinition->setFactory(array(StoreFactory::class, 'createStore')); $storeDefinition->setArguments(array(new Reference($connectionDefinitionId))); $container->setDefinition($storeDefinitionId = 'lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition); $storeDefinition = new Reference($storeDefinitionId); break; default: throw new InvalidArgumentException(sprintf('Lock store DSN "%s" is not valid in resource "%s"', $storeDsn, $resourceName)); } $storeDefinitions[] = $storeDefinition; } // Wrap array of stores with CombinedStore if (count($storeDefinitions) > 1) { $combinedDefinition = new ChildDefinition('lock.store.combined.abstract'); $combinedDefinition->replaceArgument(0, $storeDefinitions); $container->setDefinition('lock.'.$resourceName.'.store', $combinedDefinition); } else { $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false)); } // Generate factories for each resource $factoryDefinition = new ChildDefinition('lock.factory.abstract'); $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store')); $container->setDefinition('lock.'.$resourceName.'.factory', $factoryDefinition); // Generate services for lock instances $lockDefinition = new Definition(Lock::class); $lockDefinition->setPublic(false); $lockDefinition->setFactory(array(new Reference('lock.'.$resourceName.'.factory'), 'createLock')); $lockDefinition->setArguments(array($resourceName)); $container->setDefinition('lock.'.$resourceName, $lockDefinition); // provide alias for default resource if ('default' === $resourceName) { $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store', false)); $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false)); $container->setAlias('lock', new Alias('lock.'.$resourceName, false)); $container->setAlias(StoreInterface::class, new Alias('lock.store', false)); $container->setAlias(Factory::class, new Alias('lock.factory', false)); $container->setAlias(LockInterface::class, new Alias('lock', false)); } } } private function registerCacheConfiguration(array $config, ContainerBuilder $container) { $version = new Parameter('container.build_id'); $container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version); $container->getDefinition('cache.adapter.system')->replaceArgument(2, $version); $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']); if (isset($config['prefix_seed'])) { $container->setParameter('cache.prefix.seed', $config['prefix_seed']); } if ($container->hasParameter('cache.prefix.seed')) { // Inline any env vars referenced in the parameter $container->setParameter('cache.prefix.seed', $container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true)); } foreach (array('doctrine', 'psr6', 'redis', 'memcached') as $name) { if (isset($config[$name = 'default_'.$name.'_provider'])) { $container->setAlias('cache.'.$name, new Alias(Compiler\CachePoolPass::getServiceProvider($container, $config[$name]), false)); } } foreach (array('app', 'system') as $name) { $config['pools']['cache.'.$name] = array( 'adapter' => $config[$name], 'public' => true, ); } foreach ($config['pools'] as $name => $pool) { $definition = new ChildDefinition($pool['adapter']); $definition->setPublic($pool['public']); unset($pool['adapter'], $pool['public']); $definition->addTag('cache.pool', $pool); $container->setDefinition($name, $definition); } if (method_exists(PropertyAccessor::class, 'createCache')) { $propertyAccessDefinition = $container->register('cache.property_access', AdapterInterface::class); $propertyAccessDefinition->setPublic(false); if (!$container->getParameter('kernel.debug')) { $propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache')); $propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); $propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.system_clearer')); $propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache')); } else { $propertyAccessDefinition->setClass(ArrayAdapter::class); $propertyAccessDefinition->setArguments(array(0, false)); } } if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\Component\Cache\Adapter\ApcuAdapter', 'Symfony\Component\Cache\Adapter\FilesystemAdapter', 'Symfony\Component\Cache\CacheItem', )); } } /** * Gets a hash of the kernel root directory. * * @return string */ private function getKernelRootHash(ContainerBuilder $container) { if (!$this->kernelRootHash) { $this->kernelRootHash = hash('sha256', $container->getParameter('kernel.root_dir')); } return $this->kernelRootHash; } /** * Returns the base path for the XSD files. * * @return string The XSD base path */ public function getXsdValidationBasePath() { return dirname(__DIR__).'/Resources/config/schema'; } public function getNamespace() { return 'http://symfony.com/schema/dic/symfony'; } } ���������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/EventListener/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024552�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/EventListener/ResolveControllerNameSubscriber.php��0000664�0000000�0000000�00000002667�13247321071�0033606�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\EventListener; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** * Guarantees that the _controller key is parsed into its final format. * * @author Ryan Weaver <ryan@knpuniversity.com> */ class ResolveControllerNameSubscriber implements EventSubscriberInterface { private $parser; public function __construct(ControllerNameParser $parser) { $this->parser = $parser; } public function onKernelRequest(GetResponseEvent $event) { $controller = $event->getRequest()->attributes->get('_controller'); if (is_string($controller) && false === strpos($controller, '::') && 2 === substr_count($controller, ':')) { // controller in the a:b:c notation then $event->getRequest()->attributes->set('_controller', $this->parser->parse($controller)); } } public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array('onKernelRequest', 24), ); } } �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php������������������0000664�0000000�0000000�00000002340�13247321071�0030413�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\EventListener; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\SessionListener instead.', SessionListener::class), E_USER_DEPRECATED); /** * Sets the session in the request. * * @author Fabien Potencier <fabien@symfony.com> * * @deprecated since version 3.3, to be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\SessionListener instead */ class SessionListener extends AbstractSessionListener { private $container; public function __construct(ContainerInterface $container) { $this->container = $container; } protected function getSession() { if (!$this->container->has('session')) { return; } return $this->container->get('session'); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/EventListener/TestSessionListener.php��������������0000664�0000000�0000000�00000002243�13247321071�0031255�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\EventListener; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\TestSessionListener instead.', TestSessionListener::class), E_USER_DEPRECATED); use Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener; use Symfony\Component\DependencyInjection\ContainerInterface; /** * TestSessionListener. * * @author Fabien Potencier <fabien@symfony.com> * * @deprecated since version 3.3, to be removed in 4.0. */ class TestSessionListener extends AbstractTestSessionListener { protected $container; public function __construct(ContainerInterface $container) { $this->container = $container; } protected function getSession() { if (!$this->container->has('session')) { return; } return $this->container->get('session'); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php��������������������������������0000664�0000000�0000000�00000020247�13247321071�0025570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass; use Symfony\Component\Console\Application; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass; use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass; use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass; use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass; use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass; use Symfony\Component\Serializer\DependencyInjection\SerializerPass; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass; use Symfony\Component\Form\DependencyInjection\FormPass; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Config\Resource\ClassExistenceResource; use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass; use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass; use Symfony\Component\Translation\DependencyInjection\TranslatorPass; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; use Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass; use Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class FrameworkBundle extends Bundle { public function boot() { ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); if ($this->container->hasParameter('kernel.trusted_proxies')) { @trigger_error('The "kernel.trusted_proxies" parameter is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.', E_USER_DEPRECATED); if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) { Request::setTrustedProxies($trustedProxies, Request::getTrustedHeaderSet()); } } if ($this->container->getParameter('kernel.http_method_override')) { Request::enableHttpMethodParameterOverride(); } if ($trustedHosts = $this->container->getParameter('kernel.trusted_hosts')) { Request::setTrustedHosts($trustedHosts); } } public function build(ContainerBuilder $container) { parent::build($container); $hotPathEvents = array( KernelEvents::REQUEST, KernelEvents::CONTROLLER, KernelEvents::CONTROLLER_ARGUMENTS, KernelEvents::RESPONSE, KernelEvents::FINISH_REQUEST, ); $container->addCompilerPass(new LoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); $container->addCompilerPass(new RegisterControllerArgumentLocatorsPass()); $container->addCompilerPass(new RemoveEmptyControllerArgumentLocatorsPass(), PassConfig::TYPE_BEFORE_REMOVING); $container->addCompilerPass(new RoutingResolverPass()); $container->addCompilerPass(new ProfilerPass()); // must be registered before removing private services as some might be listeners/subscribers // but as late as possible to get resolved parameters $container->addCompilerPass((new RegisterListenersPass())->setHotPathEvents($hotPathEvents), PassConfig::TYPE_BEFORE_REMOVING); $container->addCompilerPass(new TemplatingPass()); $this->addCompilerPassIfExists($container, AddConstraintValidatorsPass::class, PassConfig::TYPE_BEFORE_REMOVING); $container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_AFTER_REMOVING, -255); $this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class); $this->addCompilerPassIfExists($container, AddConsoleCommandPass::class); if (class_exists(TranslatorPass::class)) { // Arguments to be removed in 4.0, relying on the default values $container->addCompilerPass(new TranslatorPass('translator.default', 'translation.loader')); } $container->addCompilerPass(new LoggingTranslatorPass()); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); $this->addCompilerPassIfExists($container, TranslationExtractorPass::class); $this->addCompilerPassIfExists($container, TranslationDumperPass::class); $container->addCompilerPass(new FragmentRendererPass()); $this->addCompilerPassIfExists($container, SerializerPass::class); $this->addCompilerPassIfExists($container, PropertyInfoPass::class); $container->addCompilerPass(new DataCollectorTranslatorPass()); $container->addCompilerPass(new ControllerArgumentValueResolverPass()); $container->addCompilerPass(new CachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 32); $this->addCompilerPassIfExists($container, ValidateWorkflowsPass::class); $container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new CachePoolPrunerPass(), PassConfig::TYPE_AFTER_REMOVING); $this->addCompilerPassIfExists($container, FormPass::class); $container->addCompilerPass(new WorkflowGuardListenerPass()); $container->addCompilerPass(new ResettableServicePass()); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); $container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255); $container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING); } } private function addCompilerPassIfExists(ContainerBuilder $container, $class, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, $priority = 0) { $container->addResource(new ClassExistenceResource($class)); if (class_exists($class)) { $container->addCompilerPass(new $class(), $type, $priority); } } public function registerCommands(Application $application) { // noop } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/HttpCache/�����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023626�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php����������������������������0000664�0000000�0000000�00000004466�13247321071�0026214�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\HttpCache; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * Manages HTTP cache objects in a Container. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class HttpCache extends BaseHttpCache { protected $cacheDir; protected $kernel; /** * @param HttpKernelInterface $kernel An HttpKernelInterface instance * @param string $cacheDir The cache directory (default used if null) */ public function __construct(HttpKernelInterface $kernel, $cacheDir = null) { $this->kernel = $kernel; $this->cacheDir = $cacheDir; parent::__construct($kernel, $this->createStore(), $this->createSurrogate(), array_merge(array('debug' => $kernel->isDebug()), $this->getOptions())); } /** * Forwards the Request to the backend and returns the Response. * * @param Request $request A Request instance * @param bool $raw Whether to catch exceptions or not * @param Response $entry A Response instance (the stale entry if present, null otherwise) * * @return Response A Response instance */ protected function forward(Request $request, $raw = false, Response $entry = null) { $this->getKernel()->boot(); $this->getKernel()->getContainer()->set('cache', $this); return parent::forward($request, $raw, $entry); } /** * Returns an array of options to customize the Cache configuration. * * @return array An array of options */ protected function getOptions() { return array(); } protected function createSurrogate() { return new Esi(); } protected function createStore() { return new Store($this->cacheDir ?: $this->kernel->getCacheDir().'/http_cache'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Kernel/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023203�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php������������������������0000664�0000000�0000000�00000005167�13247321071�0027143�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\RouteCollectionBuilder; /** * A Kernel that provides configuration hooks. * * @author Ryan Weaver <ryan@knpuniversity.com> * @author Fabien Potencier <fabien@symfony.com> */ trait MicroKernelTrait { /** * Add or import routes into your application. * * $routes->import('config/routing.yml'); * $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); * * @param RouteCollectionBuilder $routes */ abstract protected function configureRoutes(RouteCollectionBuilder $routes); /** * Configures the container. * * You can register extensions: * * $c->loadFromExtension('framework', array( * 'secret' => '%secret%' * )); * * Or services: * * $c->register('halloween', 'FooBundle\HalloweenProvider'); * * Or parameters: * * $c->setParameter('halloween', 'lot of fun'); * * @param ContainerBuilder $c * @param LoaderInterface $loader */ abstract protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader); /** * {@inheritdoc} */ public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function (ContainerBuilder $container) use ($loader) { $container->loadFromExtension('framework', array( 'router' => array( 'resource' => 'kernel:loadRoutes', 'type' => 'service', ), )); if ($this instanceof EventSubscriberInterface) { $container->register('kernel', static::class) ->setSynthetic(true) ->setPublic(true) ->addTag('kernel.event_subscriber') ; } $this->configureContainer($container, $loader); $container->addObjectResource($this); }); } /** * @internal */ public function loadRoutes(LoaderInterface $loader) { $routes = new RouteCollectionBuilder($loader); $this->configureRoutes($routes); return $routes->build(); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/LICENSE��������������������������������������������0000664�0000000�0000000�00000002051�13247321071�0022766�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2004-2018 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/README.md������������������������������������������0000664�0000000�0000000�00000000521�13247321071�0023240�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������FrameworkBundle =============== Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/�����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023735�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025202�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml�������������������0000664�0000000�0000000�00000005200�13247321071�0030256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader"> <call method="addGlobalIgnoredName"> <argument>required</argument> <!-- dummy arg to register class_exists as annotation loader only when required --> <argument type="service" id="annotations.dummy_registry" /> </call> </service> <service id="annotations.dummy_registry" class="Doctrine\Common\Annotations\AnnotationRegistry"> <call method="registerUniqueLoader"> <argument>class_exists</argument> </call> </service> <service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader"> <argument type="service" id="annotations.reader" /> <argument type="service"> <service class="Doctrine\Common\Cache\ArrayCache" /> </argument> <argument /><!-- Debug-Flag --> </service> <service id="annotations.filesystem_cache" class="Doctrine\Common\Cache\FilesystemCache"> <argument /><!-- Cache-Directory --> </service> <service id="annotations.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer"> <argument type="service" id="annotations.reader" /> <argument>%kernel.cache_dir%/annotations.php</argument> <argument type="service" id="cache.annotations" /> <argument>#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))#</argument> </service> <service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider"> <argument type="service"> <service class="Symfony\Component\Cache\Adapter\PhpArrayAdapter"> <factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" /> <argument>%kernel.cache_dir%/annotations.php</argument> <argument type="service" id="cache.annotations" /> </service> </argument> </service> <service id="annotation_reader" alias="annotations.reader" /> <service id="Doctrine\Common\Annotations\Reader" alias="annotation_reader" /> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml������������������������0000664�0000000�0000000�00000004672�13247321071�0027237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="asset.request_context.base_path"></parameter> <parameter key="asset.request_context.secure">false</parameter> </parameters> <services> <defaults public="false" /> <service id="assets.packages" class="Symfony\Component\Asset\Packages"> <argument type="service" id="assets.empty_package" /> <!-- default package --> <argument type="collection" /> <!-- named packages --> </service> <service id="Symfony\Component\Asset\Packages" alias="assets.packages" /> <service id="assets.empty_package" class="Symfony\Component\Asset\Package"> <argument type="service" id="assets.empty_version_strategy" /> </service> <service id="assets.context" class="Symfony\Component\Asset\Context\RequestStackContext"> <argument type="service" id="request_stack" /> <argument>%asset.request_context.base_path%</argument> <argument>%asset.request_context.secure%</argument> </service> <service id="assets.path_package" class="Symfony\Component\Asset\PathPackage" abstract="true"> <argument /> <!-- base path --> <argument /> <!-- version strategy --> <argument type="service" id="assets.context" /> </service> <service id="assets.url_package" class="Symfony\Component\Asset\UrlPackage" abstract="true"> <argument /> <!-- base URLs --> <argument /> <!-- version strategy --> <argument type="service" id="assets.context" /> </service> <service id="assets.static_version_strategy" class="Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy" abstract="true"> <argument /> <!-- version --> <argument /> <!-- format --> </service> <service id="assets.empty_version_strategy" class="Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy" /> <service id="assets.json_manifest_version_strategy" class="Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy" abstract="true"> <argument /> <!-- manifest path --> </service> </services> </container> ����������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml�������������������������0000664�0000000�0000000�00000013046�13247321071�0026773�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="cache.app" parent="cache.adapter.filesystem" public="true"> <tag name="cache.pool" clearer="cache.app_clearer" reset="reset" /> </service> <service id="cache.system" parent="cache.adapter.system" public="true"> <tag name="cache.pool" /> </service> <service id="cache.validator" parent="cache.system" public="false"> <tag name="cache.pool" /> </service> <service id="cache.serializer" parent="cache.system" public="false"> <tag name="cache.pool" /> </service> <service id="cache.annotations" parent="cache.system" public="false"> <tag name="cache.pool" /> </service> <service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true"> <factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" /> <tag name="cache.pool" clearer="cache.system_clearer" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <argument /> <!-- version --> <argument>%kernel.cache_dir%/pools</argument> <argument type="service" id="logger" on-invalid="ignore" /> </service> <service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true"> <tag name="cache.pool" clearer="cache.default_clearer" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <argument /> <!-- version --> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> <service id="cache.adapter.doctrine" class="Symfony\Component\Cache\Adapter\DoctrineAdapter" abstract="true"> <tag name="cache.pool" provider="cache.default_doctrine_provider" clearer="cache.default_clearer" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- Doctrine provider service --> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> <service id="cache.adapter.filesystem" class="Symfony\Component\Cache\Adapter\FilesystemAdapter" abstract="true"> <tag name="cache.pool" clearer="cache.default_clearer" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <argument>%kernel.cache_dir%/pools</argument> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> <service id="cache.adapter.psr6" class="Symfony\Component\Cache\Adapter\ProxyAdapter" abstract="true"> <tag name="cache.pool" provider="cache.default_psr6_provider" clearer="cache.default_clearer" /> <argument /> <!-- PSR-6 provider service --> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> </service> <service id="cache.adapter.redis" class="Symfony\Component\Cache\Adapter\RedisAdapter" abstract="true"> <tag name="cache.pool" provider="cache.default_redis_provider" clearer="cache.default_clearer" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- Redis connection service --> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> <service id="cache.adapter.memcached" class="Symfony\Component\Cache\Adapter\MemcachedAdapter" abstract="true"> <tag name="cache.pool" provider="cache.default_memcached_provider" clearer="cache.default_clearer" reset="reset" /> <tag name="monolog.logger" channel="cache" /> <argument /> <!-- Memcached connection service --> <argument /> <!-- namespace --> <argument>0</argument> <!-- default lifetime --> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> <service id="cache.default_clearer" class="Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer"> <argument type="collection" /> </service> <service id="cache.system_clearer" parent="cache.default_clearer" public="true" /> <service id="cache.global_clearer" parent="cache.default_clearer" public="true" /> <service id="cache.app_clearer" alias="cache.default_clearer" public="true" /> <service id="Psr\Cache\CacheItemPoolInterface" alias="cache.app" /> <service id="Symfony\Component\Cache\Adapter\AdapterInterface" alias="cache.app" /> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache_debug.xml�������������������0000664�0000000�0000000�00000001273�13247321071�0030140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <!-- DataCollector (public to prevent inlining, made private in CacheCollectorPass) --> <service id="data_collector.cache" class="Symfony\Component\Cache\DataCollector\CacheDataCollector" public="true"> <tag name="data_collector" template="@WebProfiler/Collector/cache.html.twig" id="cache" priority="275" /> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml��������������������0000664�0000000�0000000�00000006436�13247321071�0030106�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="data_collector.config" class="Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/config.html.twig" id="config" priority="-255" /> <call method="setKernel"><argument type="service" id="kernel" on-invalid="ignore" /></call> </service> <service id="data_collector.request" class="Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector"> <tag name="kernel.event_subscriber" /> <tag name="data_collector" template="@WebProfiler/Collector/request.html.twig" id="request" priority="335" /> </service> <service id="data_collector.ajax" class="Symfony\Component\HttpKernel\DataCollector\AjaxDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/ajax.html.twig" id="ajax" priority="315" /> </service> <service id="data_collector.exception" class="Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/exception.html.twig" id="exception" priority="305" /> </service> <service id="data_collector.events" class="Symfony\Component\HttpKernel\DataCollector\EventDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/events.html.twig" id="events" priority="290" /> <argument type="service" id="debug.event_dispatcher" on-invalid="ignore" /> </service> <service id="data_collector.logger" class="Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/logger.html.twig" id="logger" priority="300" /> <tag name="monolog.logger" channel="profiler" /> <argument type="service" id="logger" on-invalid="ignore" /> <argument>%kernel.cache_dir%/%kernel.container_class%</argument> </service> <service id="data_collector.time" class="Symfony\Component\HttpKernel\DataCollector\TimeDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/time.html.twig" id="time" priority="330" /> <argument type="service" id="kernel" on-invalid="ignore" /> <argument type="service" id="debug.stopwatch" on-invalid="ignore" /> </service> <service id="data_collector.memory" class="Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/memory.html.twig" id="memory" priority="325" /> </service> <service id="data_collector.router" class="Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector"> <tag name="kernel.event_listener" event="kernel.controller" method="onKernelController"/> <tag name="data_collector" template="@WebProfiler/Collector/router.html.twig" id="router" priority="285" /> </service> </services> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml�����������������������0000664�0000000�0000000�00000014163�13247321071�0027373�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="console.error_listener" class="Symfony\Component\Console\EventListener\ErrorListener"> <argument type="service" id="logger" on-invalid="null" /> <tag name="kernel.event_subscriber" /> <tag name="monolog.logger" channel="console" /> </service> <service id="console.command.about" class="Symfony\Bundle\FrameworkBundle\Command\AboutCommand"> <tag name="console.command" command="about" /> </service> <service id="console.command.assets_install" class="Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand"> <argument type="service" id="filesystem" /> <tag name="console.command" command="assets:install" /> </service> <service id="console.command.cache_clear" class="Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand"> <argument type="service" id="cache_clearer" /> <argument type="service" id="filesystem" /> <tag name="console.command" command="cache:clear" /> </service> <service id="console.command.cache_pool_clear" class="Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand"> <argument type="service" id="cache.global_clearer" /> <tag name="console.command" command="cache:pool:clear" /> </service> <service id="console.command.cache_pool_prune" class="Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand"> <argument type="iterator" /> <tag name="console.command" command="cache:pool:prune" /> </service> <service id="console.command.cache_warmup" class="Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand"> <argument type="service" id="cache_warmer" /> <tag name="console.command" command="cache:warmup" /> </service> <service id="console.command.config_debug" class="Symfony\Bundle\FrameworkBundle\Command\ConfigDebugCommand"> <tag name="console.command" command="debug:config" /> </service> <service id="console.command.config_dump_reference" class="Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand"> <tag name="console.command" command="config:dump-reference" /> </service> <service id="console.command.container_debug" class="Symfony\Bundle\FrameworkBundle\Command\ContainerDebugCommand"> <tag name="console.command" command="debug:container" /> </service> <service id="console.command.debug_autowiring" class="Symfony\Bundle\FrameworkBundle\Command\DebugAutowiringCommand"> <tag name="console.command" command="debug:autowiring" /> </service> <service id="console.command.event_dispatcher_debug" class="Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand"> <argument type="service" id="event_dispatcher" /> <tag name="console.command" command="debug:event-dispatcher" /> </service> <service id="console.command.router_debug" class="Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand"> <argument type="service" id="router" /> <tag name="console.command" command="debug:router" /> </service> <service id="console.command.router_match" class="Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand"> <argument type="service" id="router" /> <tag name="console.command" command="router:match" /> </service> <service id="console.command.translation_debug" class="Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand"> <argument type="service" id="translator" /> <argument type="service" id="translation.reader" /> <argument type="service" id="translation.extractor" /> <argument>%translator.default_path%</argument> <argument /> <!-- %twig.default_path% --> <tag name="console.command" command="debug:translation" /> </service> <service id="console.command.translation_update" class="Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand"> <argument type="service" id="translation.writer" /> <argument type="service" id="translation.reader" /> <argument type="service" id="translation.extractor" /> <argument>%kernel.default_locale%</argument> <argument>%translator.default_path%</argument> <argument /> <!-- %twig.default_path% --> <tag name="console.command" command="translation:update" /> </service> <service id="console.command.workflow_dump" class="Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand"> <tag name="console.command" command="workflow:dump" /> </service> <service id="console.command.xliff_lint" class="Symfony\Bundle\FrameworkBundle\Command\XliffLintCommand"> <tag name="console.command" command="lint:xliff" /> </service> <service id="console.command.yaml_lint" class="Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand"> <tag name="console.command" command="lint:yaml" /> </service> <service id="console.command.form_debug" class="Symfony\Component\Form\Command\DebugCommand"> <argument type="service" id="form.registry" /> <argument type="collection" /> <!-- All form types namespaces are stored here by FormPass --> <argument type="collection" /> <!-- All services form types are stored here by FormPass --> <argument type="collection" /> <!-- All type extensions are stored here by FormPass --> <argument type="collection" /> <!-- All type guessers are stored here by FormPass --> <tag name="console.command" command="debug:form" /> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml�������������������������0000664�0000000�0000000�00000002655�13247321071�0027022�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="debug.event_dispatcher" class="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher" decorates="event_dispatcher"> <tag name="monolog.logger" channel="event" /> <argument type="service" id="debug.event_dispatcher.inner" /> <argument type="service" id="debug.stopwatch" /> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="debug.controller_resolver" decorates="controller_resolver" class="Symfony\Component\HttpKernel\Controller\TraceableControllerResolver"> <argument type="service" id="debug.controller_resolver.inner" /> <argument type="service" id="debug.stopwatch" /> <argument type="service" id="argument_resolver" /> </service> <service id="debug.argument_resolver" decorates="argument_resolver" class="Symfony\Component\HttpKernel\Controller\TraceableArgumentResolver"> <argument type="service" id="debug.argument_resolver.inner" /> <argument type="service" id="debug.stopwatch" /> </service> </services> </container> �����������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml��������������������0000664�0000000�0000000�00000002636�13247321071�0030045�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="debug.error_handler.throw_at">-1</parameter> </parameters> <services> <defaults public="false" /> <service id="debug.debug_handlers_listener" class="Symfony\Component\HttpKernel\EventListener\DebugHandlersListener"> <tag name="kernel.event_subscriber" /> <tag name="monolog.logger" channel="php" /> <argument>null</argument><!-- Exception handler --> <argument type="service" id="logger" on-invalid="null" /> <argument>-1</argument><!-- Log levels map for enabled error levels --> <argument>%debug.error_handler.throw_at%</argument> <argument>true</argument> <argument type="service" id="debug.file_link_formatter"></argument> <argument>true</argument> </service> <service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter"> <argument>%debug.file_link_format%</argument> </service> <service id="Symfony\Component\HttpKernel\Debug\FileLinkFormatter" alias="debug.file_link_formatter" /> </services> </container> ��������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml���������������������������0000664�0000000�0000000�00000001234�13247321071�0026504�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="esi" class="Symfony\Component\HttpKernel\HttpCache\Esi" /> <service id="esi_listener" class="Symfony\Component\HttpKernel\EventListener\SurrogateListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="esi" on-invalid="ignore" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml��������������������������0000664�0000000�0000000�00000033361�13247321071�0026675�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <!-- ResolvedFormTypeFactory --> <service id="form.resolved_type_factory" class="Symfony\Component\Form\ResolvedFormTypeFactory" /> <service id="Symfony\Component\Form\ResolvedFormTypeFactoryInterface" alias="form.resolved_type_factory" /> <!-- FormRegistry --> <service id="form.registry" class="Symfony\Component\Form\FormRegistry"> <argument type="collection"> <!-- We don't need to be able to add more extensions. * more types can be registered with the form.type tag * more type extensions can be registered with the form.type_extension tag * more type_guessers can be registered with the form.type_guesser tag --> <argument type="service" id="form.extension" /> </argument> <argument type="service" id="form.resolved_type_factory" /> </service> <service id="Symfony\Component\Form\FormRegistryInterface" alias="form.registry" /> <!-- FormFactory --> <service id="form.factory" class="Symfony\Component\Form\FormFactory" public="true"> <argument type="service" id="form.registry" /> <argument type="service" id="form.resolved_type_factory" /> </service> <service id="Symfony\Component\Form\FormFactoryInterface" alias="form.factory" /> <!-- DependencyInjectionExtension --> <service id="form.extension" class="Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension"> <argument /><!-- All services with tag "form.type" are stored in a service locator by FormPass --> <argument type="collection" /><!-- All services with tag "form.type_extension" are stored here by FormPass --> <argument type="iterator" /><!-- All services with tag "form.type_guesser" are stored here by FormPass --> <argument>null</argument><!-- @deprecated argument in 3.3, to be removed in 4.0 --> </service> <!-- ValidatorTypeGuesser --> <service id="form.type_guesser.validator" class="Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser"> <tag name="form.type_guesser" /> <argument type="service" id="validator.mapping.class_metadata_factory" /> </service> <!-- CoreExtension --> <service id="form.property_accessor" alias="property_accessor" /> <service id="form.choice_list_factory.default" class="Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory" /> <service id="form.choice_list_factory.property_access" class="Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator"> <argument type="service" id="form.choice_list_factory.default"/> <argument type="service" id="form.property_accessor"/> </service> <service id="form.choice_list_factory.cached" class="Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator"> <argument type="service" id="form.choice_list_factory.property_access"/> </service> <service id="form.choice_list_factory" alias="form.choice_list_factory.cached" /> <service id="form.type.form" class="Symfony\Component\Form\Extension\Core\Type\FormType"> <argument type="service" id="form.property_accessor" /> <tag name="form.type" /> </service> <service id="form.type.birthday" class="Symfony\Component\Form\Extension\Core\Type\BirthdayType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.checkbox" class="Symfony\Component\Form\Extension\Core\Type\CheckboxType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.choice" class="Symfony\Component\Form\Extension\Core\Type\ChoiceType"> <tag name="form.type" /> <argument type="service" id="form.choice_list_factory"/> </service> <service id="form.type.collection" class="Symfony\Component\Form\Extension\Core\Type\CollectionType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.country" class="Symfony\Component\Form\Extension\Core\Type\CountryType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.date" class="Symfony\Component\Form\Extension\Core\Type\DateType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.datetime" class="Symfony\Component\Form\Extension\Core\Type\DateTimeType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.email" class="Symfony\Component\Form\Extension\Core\Type\EmailType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.file" class="Symfony\Component\Form\Extension\Core\Type\FileType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.hidden" class="Symfony\Component\Form\Extension\Core\Type\HiddenType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.integer" class="Symfony\Component\Form\Extension\Core\Type\IntegerType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.language" class="Symfony\Component\Form\Extension\Core\Type\LanguageType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.locale" class="Symfony\Component\Form\Extension\Core\Type\LocaleType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.money" class="Symfony\Component\Form\Extension\Core\Type\MoneyType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.number" class="Symfony\Component\Form\Extension\Core\Type\NumberType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.password" class="Symfony\Component\Form\Extension\Core\Type\PasswordType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.percent" class="Symfony\Component\Form\Extension\Core\Type\PercentType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.radio" class="Symfony\Component\Form\Extension\Core\Type\RadioType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.range" class="Symfony\Component\Form\Extension\Core\Type\RangeType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.repeated" class="Symfony\Component\Form\Extension\Core\Type\RepeatedType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.search" class="Symfony\Component\Form\Extension\Core\Type\SearchType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.textarea" class="Symfony\Component\Form\Extension\Core\Type\TextareaType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.text" class="Symfony\Component\Form\Extension\Core\Type\TextType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.time" class="Symfony\Component\Form\Extension\Core\Type\TimeType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.timezone" class="Symfony\Component\Form\Extension\Core\Type\TimezoneType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.url" class="Symfony\Component\Form\Extension\Core\Type\UrlType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.button" class="Symfony\Component\Form\Extension\Core\Type\ButtonType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.submit" class="Symfony\Component\Form\Extension\Core\Type\SubmitType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.reset" class="Symfony\Component\Form\Extension\Core\Type\ResetType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <service id="form.type.currency" class="Symfony\Component\Form\Extension\Core\Type\CurrencyType" public="true"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated> </service> <!-- FormTypeHttpFoundationExtension --> <service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension"> <argument type="service" id="form.type_extension.form.request_handler" /> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" /> </service> <!-- HttpFoundationRequestHandler --> <service id="form.type_extension.form.request_handler" class="Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler"> <argument type="service" id="form.server_params" /> </service> <service id="form.server_params" class="Symfony\Component\Form\Util\ServerParams"> <argument type="service" id="request_stack" /> </service> <!-- FormTypeValidatorExtension --> <service id="form.type_extension.form.validator" class="Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" /> <argument type="service" id="validator" /> </service> <service id="form.type_extension.repeated.validator" class="Symfony\Component\Form\Extension\Validator\Type\RepeatedTypeValidatorExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\RepeatedType" /> </service> <service id="form.type_extension.submit.validator" class="Symfony\Component\Form\Extension\Validator\Type\SubmitTypeValidatorExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\SubmitType" /> </service> <service id="form.type_extension.upload.validator" class="Symfony\Component\Form\Extension\Validator\Type\UploadValidatorExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" /> <argument type="service" id="translator"/> <argument type="string">%validator.translation_domain%</argument> </service> <service id="deprecated.form.registry" class="stdClass"> <property name="registry" type="collection" /> <deprecated>The service "%service_id%" is internal and deprecated since Symfony 3.3 and will be removed in Symfony 4.0</deprecated> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml���������������������0000664�0000000�0000000�00000002431�13247321071�0027704�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="form.type_extension.csrf" class="Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" /> <argument type="service" id="security.csrf.token_manager" /> <argument>%form.type_extension.csrf.enabled%</argument> <argument>%form.type_extension.csrf.field_name%</argument> <argument type="service" id="translator" on-invalid="null" /> <argument>%validator.translation_domain%</argument> <argument type="service" id="form.server_params" /> </service> <service id="deprecated.form.registry.csrf" class="stdClass"> <property name="registry" type="collection" /> <deprecated>The service "%service_id%" is internal and deprecated since Symfony 3.3 and will be removed in Symfony 4.0</deprecated> </service> </services> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_debug.xml��������������������0000664�0000000�0000000�00000003102�13247321071�0030031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="form.resolved_type_factory" class="Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeFactoryDataCollectorProxy"> <argument type="service"> <service class="Symfony\Component\Form\ResolvedFormTypeFactory" /> </argument> <argument type="service" id="data_collector.form" /> </service> <!-- DataCollectorTypeExtension --> <service id="form.type_extension.form.data_collector" class="Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension"> <tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" /> <argument type="service" id="data_collector.form" /> </service> <!-- DataCollector --> <service id="data_collector.form.extractor" class="Symfony\Component\Form\Extension\DataCollector\FormDataExtractor" /> <service id="data_collector.form" class="Symfony\Component\Form\Extension\DataCollector\FormDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/form.html.twig" id="form" priority="310" /> <argument type="service" id="data_collector.form.extractor" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_listener.xml�������������0000664�0000000�0000000�00000001163�13247321071�0031435�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="fragment.listener" class="Symfony\Component\HttpKernel\EventListener\FragmentListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="uri_signer" /> <argument>%fragment.path%</argument> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml�������������0000664�0000000�0000000�00000005067�13247321071�0031425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="fragment.renderer.hinclude.global_template"></parameter> <parameter key="fragment.path">/_fragment</parameter> </parameters> <services> <defaults public="false" /> <service id="fragment.handler" class="Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler"> <argument /> <!-- fragment renderer locator --> <argument type="service" id="request_stack" /> <argument>%kernel.debug%</argument> </service> <service id="fragment.renderer.inline" class="Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer"> <tag name="kernel.fragment_renderer" alias="inline" /> <argument type="service" id="http_kernel" /> <argument type="service" id="event_dispatcher" /> <call method="setFragmentPath"><argument>%fragment.path%</argument></call> </service> <service id="fragment.renderer.hinclude" class="Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer"> <argument /> <!-- templating or Twig service --> <argument type="service" id="uri_signer" /> <argument>%fragment.renderer.hinclude.global_template%</argument> <call method="setFragmentPath"><argument>%fragment.path%</argument></call> </service> <service id="fragment.renderer.esi" class="Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer"> <tag name="kernel.fragment_renderer" alias="esi" /> <argument type="service" id="esi" on-invalid="null" /> <argument type="service" id="fragment.renderer.inline" /> <argument type="service" id="uri_signer" /> <call method="setFragmentPath"><argument>%fragment.path%</argument></call> </service> <service id="fragment.renderer.ssi" class="Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer"> <tag name="kernel.fragment_renderer" alias="ssi" /> <argument type="service" id="ssi" on-invalid="null" /> <argument type="service" id="fragment.renderer.inline" /> <argument type="service" id="uri_signer" /> <call method="setFragmentPath"><argument>%fragment.path%</argument></call> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/identity_translator.xml�����������0000664�0000000�0000000�00000001325�13247321071�0032027�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="translator" class="Symfony\Component\Translation\IdentityTranslator" public="true"> <argument type="service" id="translator.selector" /> </service> <service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" /> <service id="translator.selector" class="Symfony\Component\Translation\MessageSelector" /> </services> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/lock.xml��������������������������0000664�0000000�0000000�00000003175�13247321071�0026662�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="lock.store.flock" class="Symfony\Component\Lock\Store\FlockStore" /> <service id="lock.store.semaphore" class="Symfony\Component\Lock\Store\SemaphoreStore" /> <service id="lock.store.memcached.abstract" class="Symfony\Component\Lock\Store\MemcachedStore" abstract="true"> <argument /> <!-- Memcached connection service --> </service> <service id="lock.store.redis.abstract" class="Symfony\Component\Lock\Store\RedisStore" abstract="true"> <argument /> <!-- Redis connection service --> </service> <service id="lock.store.combined.abstract" class="Symfony\Component\Lock\Store\CombinedStore" abstract="true"> <argument /> <!-- List of stores --> <argument type="service" id="lock.strategy.majority" /> <!-- Strategy --> </service> <service id="lock.strategy.majority" class="Symfony\Component\Lock\Strategy\ConsensusStrategy" /> <service id="lock.factory.abstract" class="Symfony\Component\Lock\Factory" abstract="true"> <tag name="monolog.logger" channel="lock" /> <argument /> <!-- Store --> <call method="setLogger"> <argument type="service" id="logger" on-invalid="ignore" /> </call> </service> </services> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml���������������������0000664�0000000�0000000�00000002522�13247321071�0027716�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="profiler" class="Symfony\Component\HttpKernel\Profiler\Profiler" public="true"> <tag name="monolog.logger" channel="profiler" /> <argument type="service" id="profiler.storage" /> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="profiler.storage" class="Symfony\Component\HttpKernel\Profiler\FileProfilerStorage"> <argument>%profiler.storage.dsn%</argument> </service> <service id="profiler_listener" class="Symfony\Component\HttpKernel\EventListener\ProfilerListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="profiler" /> <argument type="service" id="request_stack" /> <argument type="service" id="profiler.request_matcher" on-invalid="null" /> <argument>%profiler_listener.only_exceptions%</argument> <argument>%profiler_listener.only_master_requests%</argument> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml���������������0000664�0000000�0000000�00000001451�13247321071�0031132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="property_accessor" class="Symfony\Component\PropertyAccess\PropertyAccessor"> <argument /> <!-- magicCall, set by the extension --> <argument /> <!-- throwExceptionOnInvalidIndex, set by the extension --> <argument type="service" id="cache.property_access" on-invalid="ignore" /> </service> <service id="Symfony\Component\PropertyAccess\PropertyAccessorInterface" alias="property_accessor" /> </services> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml�����������������0000664�0000000�0000000�00000002176�13247321071�0030631�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="property_info" class="Symfony\Component\PropertyInfo\PropertyInfoExtractor"> <argument type="collection" /> <argument type="collection" /> <argument type="collection" /> <argument type="collection" /> </service> <service id="Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface" alias="property_info" /> <!-- Extractor --> <service id="property_info.reflection_extractor" class="Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor"> <tag name="property_info.list_extractor" priority="-1000" /> <tag name="property_info.type_extractor" priority="-1002" /> <tag name="property_info.access_extractor" priority="-1000" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml�����������������������0000664�0000000�0000000�00000001076�13247321071�0027420�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="request.add_request_formats_listener" class="Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener"> <tag name="kernel.event_subscriber" /> <argument/> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml�����������������������0000664�0000000�0000000�00000016122�13247321071�0027415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="router.options.generator_class">Symfony\Component\Routing\Generator\UrlGenerator</parameter> <parameter key="router.options.generator_base_class">Symfony\Component\Routing\Generator\UrlGenerator</parameter> <parameter key="router.options.generator_dumper_class">Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper</parameter> <parameter key="router.options.matcher_class">Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher</parameter> <parameter key="router.options.matcher_base_class">Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher</parameter> <parameter key="router.options.matcher_dumper_class">Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper</parameter> <parameter key="router.options.matcher.cache_class">%router.cache_class_prefix%UrlMatcher</parameter> <parameter key="router.options.generator.cache_class">%router.cache_class_prefix%UrlGenerator</parameter> <parameter key="router.request_context.host">localhost</parameter> <parameter key="router.request_context.scheme">http</parameter> <parameter key="router.request_context.base_url"></parameter> </parameters> <services> <defaults public="false" /> <service id="routing.resolver" class="Symfony\Component\Config\Loader\LoaderResolver" /> <service id="routing.loader.xml" class="Symfony\Component\Routing\Loader\XmlFileLoader"> <tag name="routing.loader" /> <argument type="service" id="file_locator" /> </service> <service id="routing.loader.yml" class="Symfony\Component\Routing\Loader\YamlFileLoader"> <tag name="routing.loader" /> <argument type="service" id="file_locator" /> </service> <service id="routing.loader.php" class="Symfony\Component\Routing\Loader\PhpFileLoader"> <tag name="routing.loader" /> <argument type="service" id="file_locator" /> </service> <service id="routing.loader.glob" class="Symfony\Component\Routing\Loader\GlobFileLoader"> <tag name="routing.loader" /> <argument type="service" id="file_locator" /> </service> <service id="routing.loader.directory" class="Symfony\Component\Routing\Loader\DirectoryLoader"> <tag name="routing.loader" /> <argument type="service" id="file_locator" /> </service> <service id="routing.loader.service" class="Symfony\Component\Routing\Loader\DependencyInjection\ServiceRouterLoader"> <tag name="routing.loader" /> <argument type="service" id="service_container" /> </service> <service id="routing.loader" class="Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader" public="true"> <argument type="service" id="controller_name_converter" /> <argument type="service" id="routing.resolver" /> </service> <service id="router.default" class="Symfony\Bundle\FrameworkBundle\Routing\Router"> <argument type="service" id="service_container" /> <argument>%router.resource%</argument> <argument type="collection"> <argument key="cache_dir">%kernel.cache_dir%</argument> <argument key="debug">%kernel.debug%</argument> <argument key="generator_class">%router.options.generator_class%</argument> <argument key="generator_base_class">%router.options.generator_base_class%</argument> <argument key="generator_dumper_class">%router.options.generator_dumper_class%</argument> <argument key="generator_cache_class">%router.options.generator.cache_class%</argument> <argument key="matcher_class">%router.options.matcher_class%</argument> <argument key="matcher_base_class">%router.options.matcher_base_class%</argument> <argument key="matcher_dumper_class">%router.options.matcher_dumper_class%</argument> <argument key="matcher_cache_class">%router.options.matcher.cache_class%</argument> </argument> <argument type="service" id="router.request_context" on-invalid="ignore" /> <call method="setConfigCacheFactory"> <argument type="service" id="config_cache_factory" /> </call> </service> <service id="router" alias="router.default" public="true" /> <service id="Symfony\Component\Routing\RouterInterface" alias="router" /> <service id="Symfony\Component\Routing\Generator\UrlGeneratorInterface" alias="router" /> <service id="Symfony\Component\Routing\Matcher\UrlMatcherInterface" alias="router" /> <service id="Symfony\Component\Routing\RequestContextAwareInterface" alias="router" /> <service id="router.request_context" class="Symfony\Component\Routing\RequestContext"> <argument>%router.request_context.base_url%</argument> <argument>GET</argument> <argument>%router.request_context.host%</argument> <argument>%router.request_context.scheme%</argument> <argument>%request_listener.http_port%</argument> <argument>%request_listener.https_port%</argument> </service> <service id="Symfony\Component\Routing\RequestContext" alias="router.request_context" /> <service id="router.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer"> <tag name="container.service_subscriber" id="router" /> <tag name="kernel.cache_warmer" /> <argument type="service" id="Psr\Container\ContainerInterface" /> </service> <service id="router_listener" class="Symfony\Component\HttpKernel\EventListener\RouterListener"> <tag name="kernel.event_subscriber" /> <tag name="monolog.logger" channel="request" /> <argument type="service" id="router" /> <argument type="service" id="request_stack" /> <argument type="service" id="router.request_context" on-invalid="ignore" /> <argument type="service" id="logger" on-invalid="ignore" /> <argument>%kernel.project_dir%</argument> <argument>%kernel.debug%</argument> </service> <service id="Symfony\Bundle\FrameworkBundle\Controller\RedirectController" public="true"> <argument type="service" id="router" /> <argument>%request_listener.http_port%</argument> <argument>%request_listener.https_port%</argument> </service> <service id="Symfony\Bundle\FrameworkBundle\Controller\TemplateController" public="true"> <argument type="service" id="twig" on-invalid="ignore" /> <argument type="service" id="templating" on-invalid="ignore" /> </service> </services> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026442�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd������������0000664�0000000�0000000�00000035517�13247321071�0031175�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns="http://symfony.com/schema/dic/symfony" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://symfony.com/schema/dic/symfony" elementFormDefault="qualified"> <xsd:element name="config" type="config" /> <xsd:complexType name="config"> <xsd:choice maxOccurs="unbounded"> <xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" /> <xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" /> <xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" /> <xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" /> <xsd:element name="ssi" type="ssi" minOccurs="0" maxOccurs="1" /> <xsd:element name="fragments" type="fragments" minOccurs="0" maxOccurs="1" /> <xsd:element name="web-link" type="web_link" minOccurs="0" maxOccurs="1" /> <xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" /> <xsd:element name="router" type="router" minOccurs="0" maxOccurs="1" /> <xsd:element name="session" type="session" minOccurs="0" maxOccurs="1" /> <xsd:element name="request" type="request" minOccurs="0" maxOccurs="1" /> <xsd:element name="templating" type="templating" minOccurs="0" maxOccurs="1" /> <xsd:element name="translator" type="translator" minOccurs="0" maxOccurs="1" /> <xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" /> <xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" /> <xsd:element name="property-access" type="property_access" minOccurs="0" maxOccurs="1" /> <xsd:element name="serializer" type="serializer" minOccurs="0" maxOccurs="1" /> <xsd:element name="property-info" type="property_info" minOccurs="0" maxOccurs="1" /> <xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" /> <xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" /> </xsd:choice> <xsd:attribute name="http-method-override" type="xsd:boolean" /> <xsd:attribute name="trusted-proxies" type="xsd:string" /> <xsd:attribute name="ide" type="xsd:string" /> <xsd:attribute name="secret" type="xsd:string" /> <xsd:attribute name="default-locale" type="xsd:string" /> <xsd:attribute name="test" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="form"> <xsd:all> <xsd:element name="csrf-protection" type="form_csrf_protection" minOccurs="0" maxOccurs="1" /> </xsd:all> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="form_csrf_protection"> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="field-name" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="csrf_protection"> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="esi"> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="ssi"> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="fragments"> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="path" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="web_link"> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="profiler"> <xsd:all> <xsd:element name="matcher" type="profiler_matcher" minOccurs="0" maxOccurs="1" /> </xsd:all> <xsd:attribute name="collect" type="xsd:string" /> <xsd:attribute name="only-exceptions" type="xsd:string" /> <xsd:attribute name="only-master-requests" type="xsd:string" /> <xsd:attribute name="enabled" type="xsd:string" /> <xsd:attribute name="dsn" type="xsd:string" /> <xsd:attribute name="username" type="xsd:string" /> <xsd:attribute name="password" type="xsd:string" /> <xsd:attribute name="lifetime" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="profiler_matcher"> <xsd:attribute name="ip" type="xsd:string" /> <xsd:attribute name="path" type="xsd:string" /> <xsd:attribute name="service" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="router"> <xsd:attribute name="resource" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="http-port" type="xsd:string" /> <xsd:attribute name="https-port" type="xsd:string" /> <xsd:attribute name="strict-requirements" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="session"> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="storage-id" type="xsd:string" /> <xsd:attribute name="handler-id" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="cookie-lifetime" type="xsd:string" /> <xsd:attribute name="cookie-path" type="xsd:string" /> <xsd:attribute name="cookie-domain" type="xsd:string" /> <xsd:attribute name="cookie-secure" type="xsd:boolean" /> <xsd:attribute name="cookie-httponly" type="xsd:boolean" /> <xsd:attribute name="use-cookies" type="xsd:boolean" /> <xsd:attribute name="cache-limiter" type="xsd:string" /> <xsd:attribute name="gc-maxlifetime" type="xsd:string" /> <xsd:attribute name="gc-divisor" type="xsd:string" /> <xsd:attribute name="gc-probability" type="xsd:string" /> <xsd:attribute name="use-strict-mode" type="xsd:boolean" /> <xsd:attribute name="save-path" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="request"> <xsd:sequence> <xsd:element name="format" type="format" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="format"> <xsd:choice minOccurs="1" maxOccurs="unbounded"> <xsd:element name="mime-type" type="xsd:string" /> </xsd:choice> <xsd:attribute name="name" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="assets"> <xsd:sequence> <xsd:element name="base-url" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="package" type="package" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="base-path" type="xsd:string" /> <xsd:attribute name="version-strategy" type="xsd:string" /> <xsd:attribute name="version" type="xsd:string" /> <xsd:attribute name="version-format" type="xsd:string" /> <xsd:attribute name="json-manifest-path" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="package"> <xsd:sequence> <xsd:element name="base-url" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="base-path" type="xsd:string" /> <xsd:attribute name="version-strategy" type="xsd:string" /> <xsd:attribute name="version" type="xsd:string" /> <xsd:attribute name="version-format" type="xsd:string" /> <xsd:attribute name="json-manifest-path" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="templating"> <xsd:sequence> <xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="engine" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="form" type="form-resources" minOccurs="0" maxOccurs="1" /> </xsd:sequence> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="cache" type="xsd:string" /> <xsd:attribute name="hinclude-default-template" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="form-resources"> <xsd:choice minOccurs="1" maxOccurs="unbounded"> <xsd:element name="resource" type="xsd:string" /> </xsd:choice> </xsd:complexType> <xsd:complexType name="translator"> <xsd:sequence> <xsd:element name="fallback" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="fallback" type="xsd:string" /> <xsd:attribute name="logging" type="xsd:boolean" /> <xsd:attribute name="formatter" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="validation"> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="static-method" type="xsd:string" /> <xsd:element name="mapping" type="file_mapping" /> </xsd:choice> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="cache" type="xsd:string" /> <xsd:attribute name="enable-annotations" type="xsd:boolean" /> <xsd:attribute name="static-method" type="xsd:boolean" /> <xsd:attribute name="translation-domain" type="xsd:string" /> <xsd:attribute name="strict-email" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="file_mapping"> <xsd:sequence> <xsd:element name="path" type="xsd:string" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="annotations"> <xsd:attribute name="cache" type="xsd:string" /> <xsd:attribute name="debug" type="xsd:string" /> <xsd:attribute name="file-cache-dir" type="xsd:string" /> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="property_access"> <xsd:attribute name="magic-call" type="xsd:boolean" /> <xsd:attribute name="throw-exception-on-invalid-index" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="serializer"> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="mapping" type="file_mapping" /> </xsd:choice> <xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="cache" type="xsd:string" /> <xsd:attribute name="enable-annotations" type="xsd:boolean" /> <xsd:attribute name="name-converter" type="xsd:string" /> <xsd:attribute name="circular-reference-handler" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="property_info"> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="cache"> <xsd:sequence> <xsd:element name="app" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="system" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="directory" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="default-doctrine-provider" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="default-psr6-provider" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="default-redis-provider" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="default-memcached-provider" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="pool" type="cache_pool" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="cache_pool"> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="adapter" type="xsd:string" /> <xsd:attribute name="public" type="xsd:boolean" /> <xsd:attribute name="default-lifetime" type="xsd:integer" /> <xsd:attribute name="provider" type="xsd:string" /> <xsd:attribute name="clearer" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="workflow"> <xsd:sequence> <xsd:element name="marking-store" type="marking_store" minOccurs="0" maxOccurs="1" /> <xsd:element name="support" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="place" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="transition" type="transition" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="type" type="workflow_type" /> <xsd:attribute name="initial-place" type="xsd:string" /> <xsd:attribute name="support-strategy" type="xsd:string" /> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="marking_store"> <xsd:sequence> <xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="type" type="marking_store_type" /> <xsd:attribute name="service" type="xsd:string" /> </xsd:complexType> <xsd:simpleType name="marking_store_type"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="multiple_state" /> <xsd:enumeration value="single_state" /> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="transition"> <xsd:sequence> <xsd:element name="from" type="xsd:string" minOccurs="1" maxOccurs="unbounded" /> <xsd:element name="to" type="xsd:string" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> <xsd:simpleType name="workflow_type"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="state_machine" /> <xsd:enumeration value="workflow" /> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="lock"> <xsd:sequence> <xsd:element name="resource" type="lock_resource" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="enabled" type="xsd:boolean" /> </xsd:complexType> <xsd:complexType name="lock_resource"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="name" type="xsd:string" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:schema> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/security_csrf.xml�����������������0000664�0000000�0000000�00000002616�13247321071�0030615�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.csrf.token_generator" class="Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator" /> <service id="Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface" alias="security.csrf.token_generator" /> <service id="security.csrf.token_storage" class="Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage"> <argument type="service" id="session" /> </service> <service id="Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface" alias="security.csrf.token_storage" /> <service id="security.csrf.token_manager" class="Symfony\Component\Security\Csrf\CsrfTokenManager" public="true"> <argument type="service" id="security.csrf.token_generator" /> <argument type="service" id="security.csrf.token_storage" /> <argument type="service" id="request_stack" on-invalid="ignore" /> </service> <service id="Symfony\Component\Security\Csrf\CsrfTokenManagerInterface" alias="security.csrf.token_manager" /> </services> </container> ������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml��������������������0000664�0000000�0000000�00000015246�13247321071�0030105�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="serializer.mapping.cache.file">%kernel.cache_dir%/serialization.php</parameter> <parameter key="serializer.mapping.cache.prefix" /> </parameters> <services> <defaults public="false" /> <service id="serializer" class="Symfony\Component\Serializer\Serializer" public="true"> <argument type="collection" /> <argument type="collection" /> </service> <service id="Symfony\Component\Serializer\SerializerInterface" alias="serializer" /> <service id="Symfony\Component\Serializer\Normalizer\NormalizerInterface" alias="serializer" /> <service id="Symfony\Component\Serializer\Normalizer\DenormalizerInterface" alias="serializer" /> <service id="Symfony\Component\Serializer\Encoder\EncoderInterface" alias="serializer" /> <service id="Symfony\Component\Serializer\Encoder\DecoderInterface" alias="serializer" /> <service id="serializer.property_accessor" alias="property_accessor" /> <!-- Normalizer --> <service id="serializer.normalizer.dateinterval" class="Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer"> <!-- Run before serializer.normalizer.object --> <tag name="serializer.normalizer" priority="-915" /> </service> <service id="serializer.normalizer.data_uri" class="Symfony\Component\Serializer\Normalizer\DataUriNormalizer"> <!-- Run before serializer.normalizer.object --> <tag name="serializer.normalizer" priority="-920" /> </service> <service id="serializer.normalizer.datetime" class="Symfony\Component\Serializer\Normalizer\DateTimeNormalizer"> <!-- Run before serializer.normalizer.object --> <tag name="serializer.normalizer" priority="-910" /> </service> <service id="serializer.normalizer.json_serializable" class="Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer"> <!-- Run before serializer.normalizer.object --> <tag name="serializer.normalizer" priority="-900" /> </service> <service id="serializer.normalizer.object" class="Symfony\Component\Serializer\Normalizer\ObjectNormalizer"> <argument type="service" id="serializer.mapping.class_metadata_factory" /> <argument>null</argument> <!-- name converter --> <argument type="service" id="serializer.property_accessor" /> <argument type="service" id="property_info" on-invalid="ignore" /> <!-- Run after all custom normalizers --> <tag name="serializer.normalizer" priority="-1000" /> </service> <service id="Symfony\Component\Serializer\Normalizer\ObjectNormalizer" alias="serializer.normalizer.object" /> <service id="serializer.denormalizer.array" class="Symfony\Component\Serializer\Normalizer\ArrayDenormalizer"> <!-- Run before the object normalizer --> <tag name="serializer.normalizer" priority="-990" /> </service> <!-- Loader --> <service id="serializer.mapping.chain_loader" class="Symfony\Component\Serializer\Mapping\Loader\LoaderChain"> <argument type="collection" /> </service> <!-- Class Metadata Factory --> <service id="serializer.mapping.class_metadata_factory" class="Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory"> <argument type="service" id="serializer.mapping.chain_loader" /> <argument>null</argument> </service> <service id="Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface" alias="serializer.mapping.class_metadata_factory" /> <!-- Cache --> <service id="serializer.mapping.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer"> <argument type="collection" /><!-- Loaders injected by the extension --> <argument>%serializer.mapping.cache.file%</argument> <argument type="service" id="cache.serializer" /> <tag name="kernel.cache_warmer" /> </service> <service id="serializer.mapping.cache.symfony" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter"> <factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" /> <argument>%serializer.mapping.cache.file%</argument> <argument type="service" id="cache.serializer" /> </service> <service id="serializer.mapping.cache.doctrine.apc" class="Doctrine\Common\Cache\ApcCache"> <call method="setNamespace"> <argument>%serializer.mapping.cache.prefix%</argument> </call> <deprecated>The "%service_id%" service is deprecated since Symfony 3.2 and will be removed in 4.0. APCu should now be automatically used when available.</deprecated> </service> <service id="serializer.mapping.cache.apc" parent="serializer.mapping.cache.doctrine.apc" public="false"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0. APCu should now be automatically used when available.</deprecated> </service> <!-- Encoders --> <service id="serializer.encoder.xml" class="Symfony\Component\Serializer\Encoder\XmlEncoder"> <tag name="serializer.encoder" /> </service> <service id="serializer.encoder.json" class="Symfony\Component\Serializer\Encoder\JsonEncoder"> <tag name="serializer.encoder" /> </service> <service id="serializer.encoder.yaml" class="Symfony\Component\Serializer\Encoder\YamlEncoder"> <tag name="serializer.encoder" /> </service> <service id="serializer.encoder.csv" class="Symfony\Component\Serializer\Encoder\CsvEncoder"> <tag name="serializer.encoder" /> </service> <!-- Name converter --> <service id="serializer.name_converter.camel_case_to_snake_case" class="Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter" /> <!-- PropertyInfo extractor --> <service id="property_info.serializer_extractor" class="Symfony\Component\PropertyInfo\Extractor\SerializerExtractor"> <argument type="service" id="serializer.mapping.class_metadata_factory" /> <tag name="property_info.list_extractor" priority="-999" /> </service> </services> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml����������������������0000664�0000000�0000000�00000010543�13247321071�0027552�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher" public="true"> <argument type="service" id="service_container" /> <tag name="container.hot_path" /> </service> <service id="Symfony\Component\EventDispatcher\EventDispatcherInterface" alias="event_dispatcher" /> <service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel" public="true"> <argument type="service" id="event_dispatcher" /> <argument type="service" id="controller_resolver" /> <argument type="service" id="request_stack" /> <argument type="service" id="argument_resolver" /> <tag name="container.hot_path" /> </service> <service id="Symfony\Component\HttpKernel\HttpKernelInterface" alias="http_kernel" /> <service id="request_stack" class="Symfony\Component\HttpFoundation\RequestStack" public="true" /> <service id="Symfony\Component\HttpFoundation\RequestStack" alias="request_stack" /> <service id="cache_warmer" class="Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate" public="true"> <argument type="tagged" tag="kernel.cache_warmer" /> </service> <service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer"> <argument type="collection"> <argument>Symfony\Component\HttpFoundation\ParameterBag</argument> <argument>Symfony\Component\HttpFoundation\HeaderBag</argument> <argument>Symfony\Component\HttpFoundation\FileBag</argument> <argument>Symfony\Component\HttpFoundation\ServerBag</argument> <argument>Symfony\Component\HttpFoundation\Request</argument> <argument>Symfony\Component\HttpKernel\Kernel</argument> </argument> <deprecated>The "%service_id%" option is deprecated since version 3.3, to be removed in 4.0.</deprecated> </service> <service id="cache_clearer" class="Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer" public="true"> <argument type="tagged" tag="kernel.cache_clearer" /> </service> <service id="kernel" synthetic="true" public="true" /> <service id="Symfony\Component\HttpKernel\KernelInterface" alias="kernel" /> <service id="filesystem" class="Symfony\Component\Filesystem\Filesystem" public="true" /> <service id="Symfony\Component\Filesystem\Filesystem" alias="filesystem" /> <service id="file_locator" class="Symfony\Component\HttpKernel\Config\FileLocator"> <argument type="service" id="kernel" /> <argument>%kernel.root_dir%/Resources</argument> <argument type="collection"> <argument>%kernel.root_dir%</argument> </argument> </service> <service id="Symfony\Component\HttpKernel\Config\FileLocator" alias="file_locator" /> <service id="uri_signer" class="Symfony\Component\HttpKernel\UriSigner"> <argument>%kernel.secret%</argument> </service> <service id="config_cache_factory" class="Symfony\Component\Config\ResourceCheckerConfigCacheFactory"> <argument type="tagged" tag="config_cache.resource_checker" /> </service> <service id="dependency_injection.config.container_parameters_resource_checker" class="Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker"> <argument type="service" id="service_container" /> <tag name="config_cache.resource_checker" priority="-980" /> </service> <service id="config.resource.self_checking_resource_checker" class="Symfony\Component\Config\Resource\SelfCheckingResourceChecker"> <tag name="config_cache.resource_checker" priority="-990" /> </service> <service id="services_resetter" class="Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter" public="true" /> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml�����������������������0000664�0000000�0000000�00000010273�13247321071�0027412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="session.metadata.storage_key">_sf2_meta</parameter> </parameters> <services> <defaults public="false" /> <service id="session" class="Symfony\Component\HttpFoundation\Session\Session" public="true"> <argument type="service" id="session.storage" /> <argument type="service" id="session.attribute_bag" /> <argument type="service" id="session.flash_bag" /> </service> <service id="Symfony\Component\HttpFoundation\Session\SessionInterface" alias="session" /> <service id="Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface" alias="session.storage" /> <service id="SessionHandlerInterface" alias="session.handler" /> <service id="session.storage.metadata_bag" class="Symfony\Component\HttpFoundation\Session\Storage\MetadataBag"> <argument>%session.metadata.storage_key%</argument> <argument>%session.metadata.update_threshold%</argument> </service> <service id="session.storage.native" class="Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage"> <argument>%session.storage.options%</argument> <argument type="service" id="session.handler" /> <argument type="service" id="session.storage.metadata_bag" /> </service> <service id="session.storage.php_bridge" class="Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage"> <argument type="service" id="session.handler" /> <argument type="service" id="session.storage.metadata_bag" /> </service> <service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag" /> <service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" /> <service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag" /> <service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage"> <argument>%kernel.cache_dir%/sessions</argument> <argument>MOCKSESSID</argument> <argument type="service" id="session.storage.metadata_bag" /> </service> <service id="session.handler.native_file" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler"> <argument type="service"> <service class="Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler"> <argument>%session.save_path%</argument> </service> </argument> </service> <service id="session.handler.write_check" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use the `session.lazy_write` ini setting instead.</deprecated> </service> <service id="session_listener" class="Symfony\Component\HttpKernel\EventListener\SessionListener"> <tag name="kernel.event_subscriber" /> <argument type="service"> <service class="Symfony\Component\DependencyInjection\ServiceLocator"> <tag name="container.service_locator" /> <argument type="collection"> <argument key="session" type="service" id="session" on-invalid="ignore" /> </argument> </service> </argument> </service> <service id="session.save_listener" class="Symfony\Component\HttpKernel\EventListener\SaveSessionListener"> <tag name="kernel.event_subscriber" /> </service> <!-- for BC --> <service id="session.storage.filesystem" alias="session.storage.mock_file" /> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml���������������������������0000664�0000000�0000000�00000001234�13247321071�0026522�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="ssi" class="Symfony\Component\HttpKernel\HttpCache\Ssi" /> <service id="ssi_listener" class="Symfony\Component\HttpKernel\EventListener\SurrogateListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="ssi" on-invalid="ignore" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml��������������������0000664�0000000�0000000�00000004712�13247321071�0030074�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine"> <argument type="service" id="service_container" /> <argument type="collection" /> <!-- engines --> </service> <service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser"> <argument type="service" id="kernel" /> </service> <service id="templating.filename_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser" /> <service id="templating.locator" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator"> <argument type="service" id="file_locator" /> <argument>%kernel.cache_dir%</argument> </service> <service id="templating.finder" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder"> <argument type="service" id="kernel" /> <argument type="service" id="templating.filename_parser" /> <argument>%kernel.root_dir%/Resources</argument> </service> <service id="templating.cache_warmer.template_paths" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer"> <tag name="kernel.cache_warmer" priority="20" /> <argument type="service" id="templating.finder" /> <argument type="service" id="templating.locator" /> </service> <service id="templating.loader.filesystem" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader"> <argument type="service" id="templating.locator" /> </service> <service id="templating.loader.cache" class="Symfony\Component\Templating\Loader\CacheLoader"> <argument type="service" id="templating.loader.wrapped" /> <argument>%templating.loader.cache.path%</argument> </service> <service id="templating.loader.chain" class="Symfony\Component\Templating\Loader\ChainLoader"> </service> <service id="templating.loader" alias="templating.loader.filesystem" public="true" /> </services> </container> ������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml��������������0000664�0000000�0000000�00000001604�13247321071�0031237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="debug.templating.engine.php" class="Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine"> <argument type="service" id="templating.name_parser" /> <argument type="service" id="templating.engine.php.helpers_locator" /> <argument type="service" id="templating.loader" /> <argument type="service" id="debug.stopwatch" /> <argument type="service" id="templating.globals" /> <call method="setCharset"><argument>%kernel.charset%</argument></call> </service> </services> </container> ����������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml����������������0000664�0000000�0000000�00000010451�13247321071�0030740�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="templating.engine.php" class="Symfony\Bundle\FrameworkBundle\Templating\PhpEngine"> <argument type="service" id="templating.name_parser" /> <argument type="service" id="templating.engine.php.helpers_locator" /> <argument type="service" id="templating.loader" /> <argument type="service" id="templating.globals" /> <call method="setCharset"><argument>%kernel.charset%</argument></call> </service> <service id="templating.engine.php.helpers_locator"> <tag name="container.service_locator" /> <argument type="collection" /> </service> <service id="templating.helper.slots" class="Symfony\Component\Templating\Helper\SlotsHelper"> <tag name="templating.helper" alias="slots" /> </service> <service id="templating.helper.request" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper"> <tag name="templating.helper" alias="request" /> <argument type="service" id="request_stack" /> </service> <service id="templating.helper.session" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper"> <tag name="templating.helper" alias="session" /> <argument type="service" id="request_stack" /> </service> <service id="templating.helper.router" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper"> <tag name="templating.helper" alias="router" /> <argument type="service" id="router" /> </service> <service id="templating.helper.assets" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper"> <tag name="templating.helper" alias="assets" /> <argument /> <!-- packages --> </service> <service id="templating.helper.actions" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper"> <tag name="templating.helper" alias="actions" /> <argument type="service" id="fragment.handler" /> </service> <service id="templating.helper.code" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper"> <tag name="templating.helper" alias="code" /> <argument type="service" id="debug.file_link_formatter"></argument> <argument>%kernel.project_dir%</argument> <argument>%kernel.charset%</argument> </service> <service id="templating.helper.translator" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper"> <tag name="templating.helper" alias="translator" /> <argument type="service" id="translator" /> </service> <service id="templating.helper.form" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper"> <tag name="templating.helper" alias="form" /> <argument type="service" id="templating.form.renderer" /> </service> <service id="templating.helper.stopwatch" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper"> <tag name="templating.helper" alias="stopwatch" /> <argument type="service" id="debug.stopwatch" on-invalid="ignore" /> </service> <service id="templating.form.engine" class="Symfony\Component\Form\Extension\Templating\TemplatingRendererEngine"> <argument type="service" id="templating.engine.php" /> <argument>%templating.helper.form.resources%</argument> </service> <service id="templating.form.renderer" class="Symfony\Component\Form\FormRenderer"> <argument type="service" id="templating.form.engine" /> <argument type="service" id="security.csrf.token_manager" on-invalid="null" /> </service> <service id="templating.globals" class="Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables"> <argument type="service" id="service_container" /> </service> </services> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml��������������������������0000664�0000000�0000000�00000003161�13247321071�0026704�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="test.client.parameters" type="collection"></parameter> </parameters> <services> <defaults public="false" /> <service id="test.client" class="Symfony\Bundle\FrameworkBundle\Client" shared="false" public="true"> <argument type="service" id="kernel" /> <argument>%test.client.parameters%</argument> <argument type="service" id="test.client.history" /> <argument type="service" id="test.client.cookiejar" /> </service> <service id="test.client.history" class="Symfony\Component\BrowserKit\History" shared="false" /> <service id="test.client.cookiejar" class="Symfony\Component\BrowserKit\CookieJar" shared="false" /> <service id="test.session.listener" class="Symfony\Component\HttpKernel\EventListener\TestSessionListener"> <tag name="kernel.event_subscriber" /> <argument type="service"> <service class="Symfony\Component\DependencyInjection\ServiceLocator"> <tag name="container.service_locator" /> <argument type="collection"> <argument key="session" type="service" id="session" on-invalid="ignore" /> </argument> </service> </argument> </service> </services> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml�������������������0000664�0000000�0000000�00000016103�13247321071�0030263�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="translator.default" class="Symfony\Bundle\FrameworkBundle\Translation\Translator"> <argument /> <!-- translation loaders locator --> <argument type="service" id="translator.formatter" /> <argument>%kernel.default_locale%</argument> <argument type="collection" /> <!-- translation loaders ids --> <argument type="collection"> <argument key="cache_dir">%kernel.cache_dir%/translations</argument> <argument key="debug">%kernel.debug%</argument> </argument> <call method="setConfigCacheFactory"> <argument type="service" id="config_cache_factory" /> </call> </service> <service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" /> <service id="translator.logging" class="Symfony\Component\Translation\LoggingTranslator"> <argument type="service" id="translator.logging.inner" /> <argument type="service" id="logger" /> <tag name="monolog.logger" channel="translation" /> </service> <service id="translator.formatter.default" class="Symfony\Component\Translation\Formatter\MessageFormatter"> <argument type="service" id="translator.selector" /> </service> <service id="translation.loader.php" class="Symfony\Component\Translation\Loader\PhpFileLoader"> <tag name="translation.loader" alias="php" /> </service> <service id="translation.loader.yml" class="Symfony\Component\Translation\Loader\YamlFileLoader"> <tag name="translation.loader" alias="yaml" legacy-alias="yml" /> </service> <service id="translation.loader.xliff" class="Symfony\Component\Translation\Loader\XliffFileLoader"> <tag name="translation.loader" alias="xlf" legacy-alias="xliff" /> </service> <service id="translation.loader.po" class="Symfony\Component\Translation\Loader\PoFileLoader"> <tag name="translation.loader" alias="po" /> </service> <service id="translation.loader.mo" class="Symfony\Component\Translation\Loader\MoFileLoader"> <tag name="translation.loader" alias="mo" /> </service> <service id="translation.loader.qt" class="Symfony\Component\Translation\Loader\QtFileLoader"> <tag name="translation.loader" alias="ts" /> </service> <service id="translation.loader.csv" class="Symfony\Component\Translation\Loader\CsvFileLoader"> <tag name="translation.loader" alias="csv" /> </service> <service id="translation.loader.res" class="Symfony\Component\Translation\Loader\IcuResFileLoader"> <tag name="translation.loader" alias="res" /> </service> <service id="translation.loader.dat" class="Symfony\Component\Translation\Loader\IcuDatFileLoader"> <tag name="translation.loader" alias="dat" /> </service> <service id="translation.loader.ini" class="Symfony\Component\Translation\Loader\IniFileLoader"> <tag name="translation.loader" alias="ini" /> </service> <service id="translation.loader.json" class="Symfony\Component\Translation\Loader\JsonFileLoader"> <tag name="translation.loader" alias="json" /> </service> <service id="translation.dumper.php" class="Symfony\Component\Translation\Dumper\PhpFileDumper"> <tag name="translation.dumper" alias="php" /> </service> <service id="translation.dumper.xliff" class="Symfony\Component\Translation\Dumper\XliffFileDumper"> <tag name="translation.dumper" alias="xlf" /> </service> <service id="translation.dumper.po" class="Symfony\Component\Translation\Dumper\PoFileDumper"> <tag name="translation.dumper" alias="po" /> </service> <service id="translation.dumper.mo" class="Symfony\Component\Translation\Dumper\MoFileDumper"> <tag name="translation.dumper" alias="mo" /> </service> <service id="translation.dumper.yml" class="Symfony\Component\Translation\Dumper\YamlFileDumper"> <tag name="translation.dumper" alias="yml" /> </service> <service id="translation.dumper.yaml" class="Symfony\Component\Translation\Dumper\YamlFileDumper"> <argument>yaml</argument> <tag name="translation.dumper" alias="yaml" /> </service> <service id="translation.dumper.qt" class="Symfony\Component\Translation\Dumper\QtFileDumper"> <tag name="translation.dumper" alias="ts" /> </service> <service id="translation.dumper.csv" class="Symfony\Component\Translation\Dumper\CsvFileDumper"> <tag name="translation.dumper" alias="csv" /> </service> <service id="translation.dumper.ini" class="Symfony\Component\Translation\Dumper\IniFileDumper"> <tag name="translation.dumper" alias="ini" /> </service> <service id="translation.dumper.json" class="Symfony\Component\Translation\Dumper\JsonFileDumper"> <tag name="translation.dumper" alias="json" /> </service> <service id="translation.dumper.res" class="Symfony\Component\Translation\Dumper\IcuResFileDumper"> <tag name="translation.dumper" alias="res" /> </service> <service id="translation.extractor.php" class="Symfony\Component\Translation\Extractor\PhpExtractor"> <tag name="translation.extractor" alias="php" /> </service> <service id="translation.loader" class="Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader"> <deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use "translation.reader" instead.</deprecated> </service> <service id="translation.reader" class="Symfony\Component\Translation\Reader\TranslationReader" /> <service id="translation.extractor" class="Symfony\Component\Translation\Extractor\ChainExtractor" /> <service id="translation.writer" class="Symfony\Component\Translation\Writer\TranslationWriter" /> <service id="translation.warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TranslationsCacheWarmer"> <tag name="container.service_subscriber" id="translator" /> <tag name="kernel.cache_warmer" /> <argument type="service" id="Psr\Container\ContainerInterface" /> </service> <service id="translator_listener" class="Symfony\Component\HttpKernel\EventListener\TranslatorListener"> <argument type="service" id="translator" /> <argument type="service" id="request_stack" /> <tag name="kernel.event_subscriber" /> </service> </services> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_debug.xml�������������0000664�0000000�0000000�00000001712�13247321071�0031431�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <!-- DataCollectorTranslator --> <service id="translator.data_collector" class="Symfony\Component\Translation\DataCollectorTranslator"> <argument type="service" id="translator.data_collector.inner" /> </service> <!-- DataCollector --> <service id="data_collector.translation" class="Symfony\Component\Translation\DataCollector\TranslationDataCollector"> <tag name="data_collector" template="@WebProfiler/Collector/translation.html.twig" id="translation" priority="275" /> <argument type="service" id="translator.data_collector" /> </service> </services> </container> ������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml���������������������0000664�0000000�0000000�00000007405�13247321071�0027717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="validator.mapping.cache.prefix" /> <parameter key="validator.mapping.cache.file">%kernel.cache_dir%/validation.php</parameter> </parameters> <services> <defaults public="false" /> <service id="validator" class="Symfony\Component\Validator\Validator\ValidatorInterface" public="true"> <factory service="validator.builder" method="getValidator" /> </service> <service id="Symfony\Component\Validator\Validator\ValidatorInterface" alias="validator" /> <service id="validator.builder" class="Symfony\Component\Validator\ValidatorBuilderInterface"> <factory class="Symfony\Component\Validator\Validation" method="createValidatorBuilder" /> <call method="setConstraintValidatorFactory"> <argument type="service" id="validator.validator_factory" /> </call> <call method="setTranslator"> <argument type="service" id="translator" /> </call> <call method="setTranslationDomain"> <argument>%validator.translation_domain%</argument> </call> </service> <service id="validator.mapping.class_metadata_factory" alias="validator" /> <service id="validator.mapping.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer"> <argument type="service" id="validator.builder" /> <argument>%validator.mapping.cache.file%</argument> <argument type="service" id="cache.validator" /> <tag name="kernel.cache_warmer" /> </service> <service id="validator.mapping.cache.symfony" class="Symfony\Component\Validator\Mapping\Cache\Psr6Cache"> <argument type="service"> <service class="Symfony\Component\Cache\Adapter\PhpArrayAdapter"> <factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" /> <argument>%validator.mapping.cache.file%</argument> <argument type="service" id="cache.validator" /> </service> </argument> </service> <service id="validator.mapping.cache.doctrine.apc" class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache"> <argument type="service"> <service class="Doctrine\Common\Cache\ApcCache"> <call method="setNamespace"> <argument>%validator.mapping.cache.prefix%</argument> </call> </service> </argument> <deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use a Psr6 cache like "validator.mapping.cache.symfony" instead.</deprecated> </service> <service id="validator.validator_factory" class="Symfony\Component\Validator\ContainerConstraintValidatorFactory"> <argument /> <!-- Constraint validators locator --> </service> <service id="validator.expression" class="Symfony\Component\Validator\Constraints\ExpressionValidator"> <tag name="validator.constraint_validator" alias="validator.expression" /> </service> <service id="validator.email" class="Symfony\Component\Validator\Constraints\EmailValidator"> <argument></argument> <tag name="validator.constraint_validator" alias="Symfony\Component\Validator\Constraints\EmailValidator" /> </service> </services> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.xml���������������0000664�0000000�0000000�00000001742�13247321071�0031063�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="debug.validator" decorates="validator" decoration-priority="255" class="Symfony\Component\Validator\Validator\TraceableValidator"> <argument type="service" id="debug.validator.inner" /> <tag name="kernel.reset" method="reset" /> </service> <!-- DataCollector --> <service id="data_collector.validator" class="Symfony\Component\Validator\DataCollector\ValidatorDataCollector"> <argument type="service" id="debug.validator"/> <tag name="data_collector" template="@WebProfiler/Collector/validator.html.twig" id="validator" priority="320" /> </service> </services> </container> ������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml���������������������������0000664�0000000�0000000�00000007771�13247321071�0026515�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="controller_name_converter" class="Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser"> <tag name="monolog.logger" channel="request" /> <argument type="service" id="kernel" /> </service> <service id="controller_resolver" class="Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver"> <tag name="monolog.logger" channel="request" /> <argument type="service" id="service_container" /> <argument type="service" id="controller_name_converter" /> <argument type="service" id="logger" on-invalid="ignore" /> </service> <service id="argument_metadata_factory" class="Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory" /> <service id="argument_resolver" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver"> <argument type="service" id="argument_metadata_factory" /> <argument /> <!-- argument value resolvers --> </service> <service id="argument_resolver.request_attribute" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver"> <tag name="controller.argument_value_resolver" priority="100" /> </service> <service id="argument_resolver.request" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestValueResolver"> <tag name="controller.argument_value_resolver" priority="50" /> </service> <service id="argument_resolver.session" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver"> <tag name="controller.argument_value_resolver" priority="50" /> </service> <service id="argument_resolver.service" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver"> <tag name="controller.argument_value_resolver" priority="-50" /> <argument /> </service> <service id="argument_resolver.default" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver"> <tag name="controller.argument_value_resolver" priority="-100" /> </service> <service id="argument_resolver.variadic" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\VariadicValueResolver"> <tag name="controller.argument_value_resolver" priority="-150" /> </service> <service id="response_listener" class="Symfony\Component\HttpKernel\EventListener\ResponseListener"> <tag name="kernel.event_subscriber" /> <argument>%kernel.charset%</argument> </service> <service id="streamed_response_listener" class="Symfony\Component\HttpKernel\EventListener\StreamedResponseListener"> <tag name="kernel.event_subscriber" /> </service> <service id="locale_listener" class="Symfony\Component\HttpKernel\EventListener\LocaleListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="request_stack" /> <argument>%kernel.default_locale%</argument> <argument type="service" id="router" on-invalid="ignore" /> </service> <service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener"> <tag name="kernel.event_subscriber" /> </service> <service id="resolve_controller_name_subscriber" class="Symfony\Bundle\FrameworkBundle\EventListener\ResolveControllerNameSubscriber"> <argument type="service" id="controller_name_converter" /> <tag name="kernel.event_subscriber" /> </service> </services> </container> �������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/web_link.xml����������������������0000664�0000000�0000000�00000001052�13247321071�0027514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="web_link.add_link_header_listener" class="Symfony\Component\WebLink\EventListener\AddLinkHeaderListener"> <tag name="kernel.event_subscriber" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml����������������������0000664�0000000�0000000�00000003306�13247321071�0027600�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="workflow.abstract" class="Symfony\Component\Workflow\Workflow" abstract="true" public="true"> <argument /> <!-- workflow definition --> <argument type="constant">null</argument> <!-- marking store --> <argument type="service" id="event_dispatcher" on-invalid="ignore" /> <argument /> <!-- name --> </service> <service id="state_machine.abstract" class="Symfony\Component\Workflow\StateMachine" abstract="true" public="true"> <argument /> <!-- workflow definition --> <argument type="constant">null</argument> <!-- marking store --> <argument type="service" id="event_dispatcher" on-invalid="ignore" /> <argument /> <!-- name --> </service> <service id="workflow.marking_store.multiple_state" class="Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore" abstract="true" /> <service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" /> <service id="workflow.registry" class="Symfony\Component\Workflow\Registry" /> <service id="Symfony\Component\Workflow\Registry" alias="workflow.registry" /> <service id="workflow.security.expression_language" class="Symfony\Component\Workflow\EventListener\ExpressionLanguage" /> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025072�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/������������������������������0000775�0000000�0000000�00000000000�13247321071�0025775�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/attributes.html.php�����������0000664�0000000�0000000�00000000743�13247321071�0031643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php foreach ($attr as $k => $v): ?> <?php if ('placeholder' === $k || 'title' === $k): ?> <?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?> <?php elseif (true === $v): ?> <?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?> <?php elseif (false !== $v): ?> <?php printf('%s="%s" ', $view->escape($k), $view->escape($v)) ?> <?php endif ?> <?php endforeach ?> �����������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php����0000664�0000000�0000000�00000000330�13247321071�0033226�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"<?php if ($disabled): ?> disabled="disabled"<?php endif ?> <?php echo $attr ? ' '.$view['form']->block($form, 'attributes') : '' ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_label.html.php���������0000664�0000000�0000000�00000000000�13247321071�0032111�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_row.html.php�����������0000664�0000000�0000000�00000000074�13247321071�0031654�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<div> <?php echo $view['form']->widget($form) ?> </div> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php��������0000664�0000000�0000000�00000000675�13247321071�0032337�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if (!$label) { $label = isset($label_format) ? strtr($label_format, array('%name%' => $name, '%id%' => $id)) : $view['form']->humanize($name); } ?> <button type="<?php echo isset($type) ? $view->escape($type) : 'button' ?>" <?php echo $view['form']->block($form, 'button_attributes') ?>><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($label, array(), $translation_domain) : $label) ?></button> �������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php������0000664�0000000�0000000�00000000371�13247321071�0032603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<input type="checkbox" <?php echo $view['form']->block($form, 'widget_attributes') ?> <?php if (strlen($value) > 0): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?> <?php if ($checked): ?> checked="checked"<?php endif ?> /> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php����0000664�0000000�0000000�00000000512�13247321071�0033147�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($disabled): ?>disabled="disabled" <?php endif ?> <?php foreach ($choice_attr as $k => $v): ?> <?php if ($v === true): ?> <?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?> <?php elseif ($v !== false): ?> <?php printf('%s="%s" ', $view->escape($k), $view->escape($v)) ?> <?php endif ?> <?php endforeach ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_options.html.php�������0000664�0000000�0000000�00000000103�13247321071�0032450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'choice_widget_options') ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget.html.php��������0000664�0000000�0000000�00000000300�13247321071�0032237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($expanded): ?> <?php echo $view['form']->block($form, 'choice_widget_expanded') ?> <?php else: ?> <?php echo $view['form']->block($form, 'choice_widget_collapsed') ?> <?php endif ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������choice_widget_collapsed.html.php��������������������������������������������������������������������0000664�0000000�0000000�00000002247�13247321071�0034222�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form��������������������������������������������������������������������������������������������������<select <?php if ($required && null === $placeholder && $placeholder_in_choices === false && $multiple === false && (!isset($attr['size']) || $attr['size'] <= 1)): $required = false; endif; ?> <?php echo $view['form']->block($form, 'widget_attributes', array( 'required' => $required, )) ?> <?php if ($multiple): ?> multiple="multiple"<?php endif ?> > <?php if (null !== $placeholder): ?><option value=""<?php if ($required && empty($value) && '0' !== $value): ?> selected="selected"<?php endif?>><?php echo '' != $placeholder ? $view->escape(false !== $translation_domain ? $view['translator']->trans($placeholder, array(), $translation_domain) : $placeholder) : '' ?></option><?php endif; ?> <?php if (count($preferred_choices) > 0): ?> <?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?> <?php if (count($choices) > 0 && null !== $separator): ?> <option disabled="disabled"><?php echo $separator ?></option> <?php endif ?> <?php endif ?> <?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $choices)) ?> </select> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������choice_widget_expanded.html.php���������������������������������������������������������������������0000664�0000000�0000000�00000000456�13247321071�0034044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form��������������������������������������������������������������������������������������������������<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <?php foreach ($form as $child): ?> <?php echo $view['form']->widget($child) ?> <?php echo $view['form']->label($child, null, array('translation_domain' => $choice_translation_domain)) ?> <?php endforeach ?> </div> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_options.html.php0000664�0000000�0000000�00000002142�13247321071�0034020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; $translatorHelper = $view['translator']; // outside of the loop for performance reasons! ?> <?php $formHelper = $view['form']; ?> <?php foreach ($choices as $group_label => $choice): ?> <?php if (is_array($choice) || $choice instanceof ChoiceGroupView): ?> <optgroup label="<?php echo $view->escape(false !== $choice_translation_domain ? $translatorHelper->trans($group_label, array(), $choice_translation_domain) : $group_label) ?>"> <?php echo $formHelper->block($form, 'choice_widget_options', array('choices' => $choice)) ?> </optgroup> <?php else: ?> <option value="<?php echo $view->escape($choice->value) ?>" <?php echo $formHelper->block($form, 'choice_attributes', array('choice_attr' => $choice->attr)) ?><?php if ($is_selected($choice->value, $value)): ?> selected="selected"<?php endif?>><?php echo $view->escape(false !== $choice_translation_domain ? $translatorHelper->trans($choice->label, array(), $choice_translation_domain) : $choice->label) ?></option> <?php endif ?> <?php endforeach ?> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/collection_widget.html.php����0000664�0000000�0000000�00000000310�13247321071�0033141�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if (isset($prototype)): ?> <?php $attr['data-prototype'] = $view->escape($view['form']->row($prototype)) ?> <?php endif ?> <?php echo $view['form']->widget($form, array('attr' => $attr)) ?> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/color_widget.html.php���������0000664�0000000�0000000�00000000157�13247321071�0032135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'color')); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/container_attributes.html.php�0000664�0000000�0000000�00000000111�13247321071�0033672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'widget_container_attributes') ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php����������0000664�0000000�0000000�00000000763�13247321071�0031737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($widget == 'single_text'): ?> <?php echo $view['form']->block($form, 'form_widget_simple'); ?> <?php else: ?> <div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <?php echo str_replace(array('{{ year }}', '{{ month }}', '{{ day }}'), array( $view['form']->widget($form['year']), $view['form']->widget($form['month']), $view['form']->widget($form['day']), ), $date_pattern) ?> </div> <?php endif ?> �������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/datetime_widget.html.php������0000664�0000000�0000000�00000000515�13247321071�0032611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($widget == 'single_text'): ?> <?php echo $view['form']->block($form, 'form_widget_simple'); ?> <?php else: ?> <div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <?php echo $view['form']->widget($form['date']).' '.$view['form']->widget($form['time']) ?> </div> <?php endif ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php���������0000664�0000000�0000000�00000000161�13247321071�0032101�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'email')) ?> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form.html.php�����������������0000664�0000000�0000000�00000000201�13247321071�0030405�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->start($form) ?> <?php echo $view['form']->widget($form) ?> <?php echo $view['form']->end($form) ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_enctype.html.php���������0000664�0000000�0000000�00000000123�13247321071�0032137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($form->vars['multipart']): ?>enctype="multipart/form-data"<?php endif ?> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_end.html.php�������������0000664�0000000�0000000�00000000164�13247321071�0031243�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if (!isset($render_rest) || $render_rest): ?> <?php echo $view['form']->rest($form) ?> <?php endif ?> </form> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_errors.html.php����������0000664�0000000�0000000�00000000307�13247321071�0032010�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if (count($errors) > 0): ?> <ul> <?php foreach ($errors as $error): ?> <li><?php echo $error->getMessage() ?></li> <?php endforeach; ?> </ul> <?php endif ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php�����������0000664�0000000�0000000�00000001215�13247321071�0031552�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if (false !== $label): ?> <?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?> <?php if (!$compound) { $label_attr['for'] = $id; } ?> <?php if (!$label) { $label = isset($label_format) ? strtr($label_format, array('%name%' => $name, '%id%' => $id)) : $view['form']->humanize($name); } ?> <label<?php if ($label_attr) { echo ' '.$view['form']->block($form, 'attributes', array('attr' => $label_attr)); } ?>><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($label, array(), $translation_domain) : $label) ?></label> <?php endif ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_rest.html.php������������0000664�0000000�0000000�00000000247�13247321071�0031454�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php foreach ($form as $child): ?> <?php if (!$child->isRendered()): ?> <?php echo $view['form']->row($child) ?> <?php endif; ?> <?php endforeach; ?> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_row.html.php�������������0000664�0000000�0000000�00000000231�13247321071�0031277�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<div> <?php echo $view['form']->label($form) ?> <?php echo $view['form']->errors($form) ?> <?php echo $view['form']->widget($form) ?> </div> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_rows.html.php������������0000664�0000000�0000000�00000000147�13247321071�0031470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php foreach ($form as $child) : ?> <?php echo $view['form']->row($child) ?> <?php endforeach; ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_start.html.php�����������0000664�0000000�0000000�00000001075�13247321071�0031634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $method = strtoupper($method) ?> <?php $form_method = $method === 'GET' || $method === 'POST' ? $method : 'POST' ?> <form name="<?php echo $name ?>" method="<?php echo strtolower($form_method) ?>"<?php if ($action !== ''): ?> action="<?php echo $action ?>"<?php endif ?><?php foreach ($attr as $k => $v) { printf(' %s="%s"', $view->escape($k), $view->escape($v)); } ?><?php if ($multipart): ?> enctype="multipart/form-data"<?php endif ?>> <?php if ($form_method !== $method): ?> <input type="hidden" name="_method" value="<?php echo $method ?>" /> <?php endif ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget.html.php����������0000664�0000000�0000000�00000000267�13247321071�0031764�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($compound): ?> <?php echo $view['form']->block($form, 'form_widget_compound')?> <?php else: ?> <?php echo $view['form']->block($form, 'form_widget_simple')?> <?php endif ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php�0000664�0000000�0000000�00000000455�13247321071�0033667�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <?php if (!$form->parent && $errors): ?> <?php echo $view['form']->errors($form) ?> <?php endif ?> <?php echo $view['form']->block($form, 'form_rows') ?> <?php echo $view['form']->rest($form) ?> </div> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_simple.html.php���0000664�0000000�0000000�00000000370�13247321071�0033330�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<input type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>" <?php echo $view['form']->block($form, 'widget_attributes') ?><?php if (!empty($value) || is_numeric($value)): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?> /> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_row.html.php�����������0000664�0000000�0000000�00000000053�13247321071�0031571�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->widget($form) ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php��������0000664�0000000�0000000�00000000162�13247321071�0032246�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'hidden')) ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/integer_widget.html.php�������0000664�0000000�0000000�00000000162�13247321071�0032450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'number')) ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/money_widget.html.php���������0000664�0000000�0000000�00000000155�13247321071�0032144�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo str_replace('{{ widget }}', $view['form']->block($form, 'form_widget_simple'), $money_pattern) ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php��������0000664�0000000�0000000�00000000160�13247321071�0032301�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php������0000664�0000000�0000000�00000000164�13247321071�0032657�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'password')) ?> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php�������0000664�0000000�0000000�00000000162�13247321071�0032453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?> % ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/radio_widget.html.php���������0000664�0000000�0000000�00000000306�13247321071�0032111�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<input type="radio" <?php echo $view['form']->block($form, 'widget_attributes') ?> value="<?php echo $view->escape($value) ?>" <?php if ($checked): ?> checked="checked"<?php endif ?> /> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php���������0000664�0000000�0000000�00000000157�13247321071�0032113�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'range')); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/repeated_row.html.php���������0000664�0000000�0000000�00000000067�13247321071�0032134�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_rows') ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php���������0000664�0000000�0000000�00000000154�13247321071�0032136�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'button_widget', array('type' => isset($type) ? $type : 'reset')) ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/search_widget.html.php��������0000664�0000000�0000000�00000000162�13247321071�0032260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'search')) ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php��������0000664�0000000�0000000�00000000155�13247321071�0032320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'button_widget', array('type' => isset($type) ? $type : 'submit')) ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/tel_widget.html.php�����������0000664�0000000�0000000�00000000155�13247321071�0031601�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'tel')); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/textarea_widget.html.php������0000664�0000000�0000000�00000000170�13247321071�0032627�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<textarea <?php echo $view['form']->block($form, 'widget_attributes') ?>><?php echo $view->escape($value) ?></textarea> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php����������0000664�0000000�0000000�00000001504�13247321071�0031752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php if ($widget == 'single_text'): ?> <?php echo $view['form']->block($form, 'form_widget_simple'); ?> <?php else: ?> <?php $vars = $widget == 'text' ? array('attr' => array('size' => 1)) : array() ?> <div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <?php // There should be no spaces between the colons and the widgets, that's why // this block is written in a single PHP tag echo $view['form']->widget($form['hour'], $vars); if ($with_minutes) { echo ':'; echo $view['form']->widget($form['minute'], $vars); } if ($with_seconds) { echo ':'; echo $view['form']->widget($form['second'], $vars); } ?> </div> <?php endif ?> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/url_widget.html.php�����������0000664�0000000�0000000�00000000157�13247321071�0031621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'url')) ?> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php����0000664�0000000�0000000�00000000423�13247321071�0033201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"<?php if ($disabled): ?> disabled="disabled"<?php endif ?> <?php if ($required): ?> required="required"<?php endif ?> <?php echo $attr ? ' '.$view['form']->block($form, 'attributes') : '' ?> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������widget_container_attributes.html.php����������������������������������������������������������������0000664�0000000�0000000�00000000227�13247321071�0035166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form��������������������������������������������������������������������������������������������������<?php if (!empty($id)): ?>id="<?php echo $view->escape($id) ?>"<?php endif ?> <?php echo $attr ? ' '.$view['form']->block($form, 'attributes') : '' ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/�������������������������0000775�0000000�0000000�00000000000�13247321071�0026745�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php������0000664�0000000�0000000�00000000140�13247321071�0032616�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<tr> <td></td> <td> <?php echo $view['form']->widget($form); ?> </td> </tr> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_row.html.php��������0000664�0000000�0000000�00000000314�13247321071�0032251�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<tr> <td> <?php echo $view['form']->label($form); ?> </td> <td> <?php echo $view['form']->errors($form); ?> <?php echo $view['form']->widget($form); ?> </td> </tr> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_widget_compound.html.php�����������������������������������������������������������������������0000664�0000000�0000000�00000000570�13247321071�0034556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable���������������������������������������������������������������������������������������������<table <?php echo $view['form']->block($form, 'widget_container_attributes'); ?>> <?php if (!$form->parent && $errors): ?> <tr> <td colspan="2"> <?php echo $view['form']->errors($form); ?> </td> </tr> <?php endif; ?> <?php echo $view['form']->block($form, 'form_rows'); ?> <?php echo $view['form']->rest($form); ?> </table> ����������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/hidden_row.html.php������0000664�0000000�0000000�00000000164�13247321071�0032544�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<tr style="display: none"> <td colspan="2"> <?php echo $view['form']->widget($form); ?> </td> </tr> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Routing/�������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023412�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php���������0000664�0000000�0000000�00000003207�13247321071�0032254�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Routing; use Symfony\Component\Routing\Loader\AnnotationClassLoader; use Symfony\Component\Routing\Route; /** * AnnotatedRouteControllerLoader is an implementation of AnnotationClassLoader * that sets the '_controller' default based on the class and method names. * * @author Fabien Potencier <fabien@symfony.com> */ class AnnotatedRouteControllerLoader extends AnnotationClassLoader { /** * Configures the _controller default parameter of a given Route instance. * * @param mixed $annot The annotation class instance */ protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) { if ('__invoke' === $method->getName()) { $route->setDefault('_controller', $class->getName()); } else { $route->setDefault('_controller', $class->getName().'::'.$method->getName()); } } /** * Makes the default route name more sane by removing common keywords. * * @return string */ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { return preg_replace(array( '/(bundle|controller)_/', '/action(_\d+)?$/', '/__/', ), array( '_', '\\1', '_', ), parent::getDefaultRouteName($class, $method)); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php�����������������������0000664�0000000�0000000�00000006416�13247321071�0027324�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Routing; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Component\Config\Exception\FileLoaderLoadException; use Symfony\Component\Config\Loader\DelegatingLoader as BaseDelegatingLoader; use Symfony\Component\Config\Loader\LoaderResolverInterface; /** * DelegatingLoader delegates route loading to other loaders using a loader resolver. * * This implementation resolves the _controller attribute from the short notation * to the fully-qualified form (from a:b:c to class::method). * * @author Fabien Potencier <fabien@symfony.com> */ class DelegatingLoader extends BaseDelegatingLoader { protected $parser; private $loading = false; /** * @param ControllerNameParser $parser A ControllerNameParser instance * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance */ public function __construct(ControllerNameParser $parser, LoaderResolverInterface $resolver) { $this->parser = $parser; parent::__construct($resolver); } /** * {@inheritdoc} */ public function load($resource, $type = null) { if ($this->loading) { // This can happen if a fatal error occurs in parent::load(). // Here is the scenario: // - while routes are being loaded by parent::load() below, a fatal error // occurs (e.g. parse error in a controller while loading annotations); // - PHP abruptly empties the stack trace, bypassing all catch/finally blocks; // it then calls the registered shutdown functions; // - the ErrorHandler catches the fatal error and re-injects it for rendering // thanks to HttpKernel->terminateWithException() (that calls handleException()); // - at this stage, if we try to load the routes again, we must prevent // the fatal error from occurring a second time, // otherwise the PHP process would be killed immediately; // - while rendering the exception page, the router can be required // (by e.g. the web profiler that needs to generate an URL); // - this handles the case and prevents the second fatal error // by triggering an exception beforehand. throw new FileLoaderLoadException($resource, null, null, null, $type); } $this->loading = true; try { $collection = parent::load($resource, $type); } finally { $this->loading = false; } foreach ($collection->all() as $route) { if (!is_string($controller = $route->getDefault('_controller')) || !$controller) { continue; } try { $controller = $this->parser->parse($controller); } catch (\InvalidArgumentException $e) { // unable to optimize unknown notation } $route->setDefault('_controller', $controller); } return $collection; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php�����������������0000664�0000000�0000000�00000002332�13247321071�0030477�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Routing; use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseMatcher; /** * @author Fabien Potencier <fabien@symfony.com> */ class RedirectableUrlMatcher extends BaseMatcher { /** * Redirects the user to another URL. * * @param string $path The path info to redirect to * @param string $route The route that matched * @param string $scheme The URL scheme (null to keep the current one) * * @return array An array of parameters */ public function redirect($path, $route, $scheme = null) { return array( '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', 'path' => $path, 'permanent' => true, 'scheme' => $scheme, 'httpPort' => $this->context->getHttpPort(), 'httpsPort' => $this->context->getHttpsPort(), '_route' => $route, ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php���������������������������������0000664�0000000�0000000�00000013741�13247321071�0025411�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Routing; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\Routing\Router as BaseRouter; use Symfony\Component\Routing\RequestContext; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** * This Router creates the Loader only when the cache is empty. * * @author Fabien Potencier <fabien@symfony.com> */ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface { private $container; private $collectedParameters = array(); /** * @param ContainerInterface $container A ContainerInterface instance * @param mixed $resource The main resource to load * @param array $options An array of options * @param RequestContext $context The context */ public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null) { $this->container = $container; $this->resource = $resource; $this->context = $context ?: new RequestContext(); $this->setOptions($options); } /** * {@inheritdoc} */ public function getRouteCollection() { if (null === $this->collection) { $this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']); $this->resolveParameters($this->collection); $this->collection->addResource(new ContainerParametersResource($this->collectedParameters)); } return $this->collection; } /** * {@inheritdoc} */ public function warmUp($cacheDir) { $currentDir = $this->getOption('cache_dir'); // force cache generation $this->setOption('cache_dir', $cacheDir); $this->getMatcher(); $this->getGenerator(); $this->setOption('cache_dir', $currentDir); } /** * Replaces placeholders with service container parameter values in: * - the route defaults, * - the route requirements, * - the route path, * - the route host, * - the route schemes, * - the route methods. */ private function resolveParameters(RouteCollection $collection) { foreach ($collection as $route) { foreach ($route->getDefaults() as $name => $value) { $route->setDefault($name, $this->resolve($value)); } foreach ($route->getRequirements() as $name => $value) { $route->setRequirement($name, $this->resolve($value)); } $route->setPath($this->resolve($route->getPath())); $route->setHost($this->resolve($route->getHost())); $schemes = array(); foreach ($route->getSchemes() as $scheme) { $schemes = array_merge($schemes, explode('|', $this->resolve($scheme))); } $route->setSchemes($schemes); $methods = array(); foreach ($route->getMethods() as $method) { $methods = array_merge($methods, explode('|', $this->resolve($method))); } $route->setMethods($methods); $route->setCondition($this->resolve($route->getCondition())); } } /** * Recursively replaces placeholders with the service container parameters. * * @param mixed $value The source which might contain "%placeholders%" * * @return mixed The source with the placeholders replaced by the container * parameters. Arrays are resolved recursively. * * @throws ParameterNotFoundException When a placeholder does not exist as a container parameter * @throws RuntimeException When a container value is not a string or a numeric value */ private function resolve($value) { if (is_array($value)) { foreach ($value as $key => $val) { $value[$key] = $this->resolve($val); } return $value; } if (!is_string($value)) { return $value; } $container = $this->container; $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($container, $value) { // skip %% if (!isset($match[1])) { return '%%'; } if (preg_match('/^env\(\w+\)$/', $match[1])) { throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1])); } $resolved = $container->getParameter($match[1]); if (is_string($resolved) || is_numeric($resolved)) { $this->collectedParameters[$match[1]] = $resolved; return (string) $resolved; } throw new RuntimeException(sprintf( 'The container parameter "%s", used in the route configuration value "%s", '. 'must be a string or numeric, but it is of type %s.', $match[1], $value, gettype($resolved) ) ); }, $value); return str_replace('%%', '%', $escapedValue); } /** * {@inheritdoc} */ public static function getSubscribedServices() { return array( 'routing.loader' => LoaderInterface::class, ); } } �������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024067�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php��������������������0000664�0000000�0000000�00000003472�13247321071�0027777�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Psr\Container\ContainerInterface; use Symfony\Component\Templating\DelegatingEngine as BaseDelegatingEngine; use Symfony\Component\HttpFoundation\Response; /** * DelegatingEngine selects an engine for a given template. * * @author Fabien Potencier <fabien@symfony.com> */ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface { protected $container; public function __construct(ContainerInterface $container, array $engineIds) { $this->container = $container; $this->engines = $engineIds; } /** * {@inheritdoc} */ public function getEngine($name) { $this->resolveEngines(); return parent::getEngine($name); } /** * {@inheritdoc} */ public function renderResponse($view, array $parameters = array(), Response $response = null) { $engine = $this->getEngine($view); if ($engine instanceof EngineInterface) { return $engine->renderResponse($view, $parameters, $response); } if (null === $response) { $response = new Response(); } $response->setContent($engine->render($view, $parameters)); return $response; } /** * Resolved engine ids to their real engine instances from the container. */ private function resolveEngines() { foreach ($this->engines as $i => $engine) { if (is_string($engine)) { $this->engines[$i] = $this->container->get($engine); } } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php���������������������0000664�0000000�0000000�00000002057�13247321071�0027632�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\Templating\EngineInterface as BaseEngineInterface; use Symfony\Component\HttpFoundation\Response; /** * EngineInterface is the interface each engine must implement. * * @author Fabien Potencier <fabien@symfony.com> */ interface EngineInterface extends BaseEngineInterface { /** * Renders a view and returns a Response. * * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * @param Response $response A Response instance * * @return Response A Response instance * * @throws \RuntimeException if the template cannot be rendered */ public function renderResponse($view, array $parameters = array(), Response $response = null); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php���������������������0000664�0000000�0000000�00000004200�13247321071�0027625�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** * GlobalVariables is the entry point for Symfony global variables in PHP templates. * * @author Fabien Potencier <fabien@symfony.com> */ class GlobalVariables { protected $container; public function __construct(ContainerInterface $container) { $this->container = $container; } /** * @return TokenInterface|null */ public function getToken() { if (!$this->container->has('security.token_storage')) { return; } return $this->container->get('security.token_storage')->getToken(); } public function getUser() { if (!$token = $this->getToken()) { return; } $user = $token->getUser(); if (!is_object($user)) { return; } return $user; } /** * @return Request|null The HTTP request object */ public function getRequest() { if ($this->container->has('request_stack')) { return $this->container->get('request_stack')->getCurrentRequest(); } } /** * @return Session|null The session */ public function getSession() { if ($request = $this->getRequest()) { return $request->getSession(); } } /** * @return string The current environment string (e.g 'dev') */ public function getEnvironment() { return $this->container->getParameter('kernel.environment'); } /** * @return bool The current debug mode */ public function getDebug() { return (bool) $this->container->getParameter('kernel.debug'); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/���������������������������������0000775�0000000�0000000�00000000000�13247321071�0025306�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php����������������0000664�0000000�0000000�00000003001�13247321071�0030551�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpKernel\Controller\ControllerReference; /** * ActionsHelper manages action inclusions. * * @author Fabien Potencier <fabien@symfony.com> */ class ActionsHelper extends Helper { private $handler; public function __construct(FragmentHandler $handler) { $this->handler = $handler; } /** * Returns the fragment content for a given URI. * * @param string $uri A URI * @param array $options An array of options * * @return string The fragment content * * @see FragmentHandler::render() */ public function render($uri, array $options = array()) { $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); return $this->handler->render($uri, $strategy, $options); } public function controller($controller, $attributes = array(), $query = array()) { return new ControllerReference($controller, $attributes, $query); } /** * {@inheritdoc} */ public function getName() { return 'actions'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php�����������������0000664�0000000�0000000�00000003140�13247321071�0030417�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Asset\Packages; use Symfony\Component\Templating\Helper\Helper; /** * AssetsHelper helps manage asset URLs. * * @author Fabien Potencier <fabien@symfony.com> */ class AssetsHelper extends Helper { private $packages; public function __construct(Packages $packages) { $this->packages = $packages; } /** * Returns the public url/path of an asset. * * If the package used to generate the path is an instance of * UrlPackage, you will always get a URL and not a path. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string The public path of the asset */ public function getUrl($path, $packageName = null) { return $this->packages->getUrl($path, $packageName); } /** * Returns the version of an asset. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string The asset version */ public function getVersion($path, $packageName = null) { return $this->packages->getVersion($path, $packageName); } /** * {@inheritdoc} */ public function getName() { return 'assets'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php�������������������0000664�0000000�0000000�00000016751�13247321071�0030043�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\Templating\Helper\Helper; /** * @author Fabien Potencier <fabien@symfony.com> */ class CodeHelper extends Helper { protected $fileLinkFormat; protected $rootDir; protected $charset; /** * @param string|FileLinkFormatter $fileLinkFormat The format for links to source files * @param string $rootDir The project root directory * @param string $charset The charset */ public function __construct($fileLinkFormat, $rootDir, $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->rootDir = str_replace('\\', '/', $rootDir).'/'; $this->charset = $charset; } /** * Formats an array as a string. * * @param array $args The argument array * * @return string */ public function formatArgsAsText(array $args) { return strip_tags($this->formatArgs($args)); } public function abbrClass($class) { $parts = explode('\\', $class); $short = array_pop($parts); return sprintf('<abbr title="%s">%s</abbr>', $class, $short); } public function abbrMethod($method) { if (false !== strpos($method, '::')) { list($class, $method) = explode('::', $method, 2); $result = sprintf('%s::%s()', $this->abbrClass($class), $method); } elseif ('Closure' === $method) { $result = sprintf('<abbr title="%s">%1$s</abbr>', $method); } else { $result = sprintf('<abbr title="%s">%1$s</abbr>()', $method); } return $result; } /** * Formats an array as a string. * * @param array $args The argument array * * @return string */ public function formatArgs(array $args) { $result = array(); foreach ($args as $key => $item) { if ('object' === $item[0]) { $parts = explode('\\', $item[1]); $short = array_pop($parts); $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short); } elseif ('array' === $item[0]) { $formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); } elseif ('string' === $item[0]) { $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset())); } elseif ('null' === $item[0]) { $formattedValue = '<em>null</em>'; } elseif ('boolean' === $item[0]) { $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>'; } elseif ('resource' === $item[0]) { $formattedValue = '<em>resource</em>'; } else { $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true)); } $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); } return implode(', ', $result); } /** * Returns an excerpt of a code file around the given line number. * * @param string $file A file path * @param int $line The selected line number * * @return string An HTML string */ public function fileExcerpt($file, $line) { if (is_readable($file)) { if (extension_loaded('fileinfo')) { $finfo = new \finfo(); // Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) { return; } } // highlight_file could throw warnings // see https://bugs.php.net/bug.php?id=25725 $code = @highlight_file($file, true); // remove main code/span tags $code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code); $content = explode('<br />', $code); $lines = array(); for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) { $lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>'; } return '<ol start="'.max($line - 3, 1).'">'.implode("\n", $lines).'</ol>'; } } /** * Formats a file path. * * @param string $file An absolute file path * @param int $line The line number * @param string $text Use this text for the link rather than the file path * * @return string */ public function formatFile($file, $line, $text = null) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; if (null === $text) { $file = trim($file); $fileStr = $file; if (0 === strpos($fileStr, $this->rootDir)) { $fileStr = str_replace($this->rootDir, '', str_replace('\\', '/', $fileStr)); $fileStr = htmlspecialchars($fileStr, $flags, $this->charset); $fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr); } $text = sprintf('%s at line %d', $fileStr, $line); } if (false !== $link = $this->getFileLink($file, $line)) { return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text); } return $text; } /** * Returns the link for a given file/line pair. * * @param string $file An absolute file path * @param int $line The line number * * @return string A link of false */ public function getFileLink($file, $line) { if ($fmt = $this->fileLinkFormat) { return is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); } return false; } public function formatFileFromText($text) { return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { return 'in '.$this->formatFile($match[2], $match[3]); }, $text); } /** * {@inheritdoc} */ public function getName() { return 'code'; } protected static function fixCodeMarkup($line) { // </span> ending tag from previous line $opening = strpos($line, '<span'); $closing = strpos($line, '</span>'); if (false !== $closing && (false === $opening || $closing < $opening)) { $line = substr_replace($line, '', $closing, 7); } // missing </span> tag at the end of line $opening = strpos($line, '<span'); $closing = strpos($line, '</span>'); if (false !== $opening && (false === $closing || $closing > $opening)) { $line .= '</span>'; } return $line; } } �����������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php�������������������0000664�0000000�0000000�00000016437�13247321071�0030075�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Form\FormRendererInterface; use Symfony\Component\Form\FormView; /** * FormHelper provides helpers to help display forms. * * @author Fabien Potencier <fabien@symfony.com> * @author Bernhard Schussek <bschussek@gmail.com> */ class FormHelper extends Helper { private $renderer; public function __construct(FormRendererInterface $renderer) { $this->renderer = $renderer; } /** * {@inheritdoc} */ public function getName() { return 'form'; } /** * Sets a theme for a given view. * * The theme format is "<Bundle>:<Controller>". * * @param FormView $view A FormView instance * @param string|array $themes A theme or an array of theme * @param bool $useDefaultThemes If true, will use default themes defined in the renderer */ public function setTheme(FormView $view, $themes, $useDefaultThemes = true) { $this->renderer->setTheme($view, $themes, $useDefaultThemes); } /** * Renders the HTML for a form. * * Example usage: * * <?php echo view['form']->form($form) ?> * * You can pass options during the call: * * <?php echo view['form']->form($form, array('attr' => array('class' => 'foo'))) ?> * * <?php echo view['form']->form($form, array('separator' => '+++++')) ?> * * This method is mainly intended for prototyping purposes. If you want to * control the layout of a form in a more fine-grained manner, you are * advised to use the other helper methods for rendering the parts of the * form individually. You can also create a custom form theme to adapt * the look of the form. * * @param FormView $view The view for which to render the form * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function form(FormView $view, array $variables = array()) { return $this->renderer->renderBlock($view, 'form', $variables); } /** * Renders the form start tag. * * Example usage templates: * * <?php echo $view['form']->start($form) ?>> * * @param FormView $view The view for which to render the start tag * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function start(FormView $view, array $variables = array()) { return $this->renderer->renderBlock($view, 'form_start', $variables); } /** * Renders the form end tag. * * Example usage templates: * * <?php echo $view['form']->end($form) ?>> * * @param FormView $view The view for which to render the end tag * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function end(FormView $view, array $variables = array()) { return $this->renderer->renderBlock($view, 'form_end', $variables); } /** * Renders the HTML for a given view. * * Example usage: * * <?php echo $view['form']->widget($form) ?> * * You can pass options during the call: * * <?php echo $view['form']->widget($form, array('attr' => array('class' => 'foo'))) ?> * * <?php echo $view['form']->widget($form, array('separator' => '+++++')) ?> * * @param FormView $view The view for which to render the widget * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function widget(FormView $view, array $variables = array()) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables); } /** * Renders the entire form field "row". * * @param FormView $view The view for which to render the row * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function row(FormView $view, array $variables = array()) { return $this->renderer->searchAndRenderBlock($view, 'row', $variables); } /** * Renders the label of the given view. * * @param FormView $view The view for which to render the label * @param string $label The label * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ public function label(FormView $view, $label = null, array $variables = array()) { if (null !== $label) { $variables += array('label' => $label); } return $this->renderer->searchAndRenderBlock($view, 'label', $variables); } /** * Renders the errors of the given view. * * @return string The HTML markup */ public function errors(FormView $view) { return $this->renderer->searchAndRenderBlock($view, 'errors'); } /** * Renders views which have not already been rendered. * * @param FormView $view The parent view * @param array $variables An array of variables * * @return string The HTML markup */ public function rest(FormView $view, array $variables = array()) { return $this->renderer->searchAndRenderBlock($view, 'rest', $variables); } /** * Renders a block of the template. * * @param FormView $view The view for determining the used themes * @param string $blockName The name of the block to render * @param array $variables The variable to pass to the template * * @return string The HTML markup */ public function block(FormView $view, $blockName, array $variables = array()) { return $this->renderer->renderBlock($view, $blockName, $variables); } /** * Returns a CSRF token. * * Use this helper for CSRF protection without the overhead of creating a * form. * * <code> * echo $view['form']->csrfToken('rm_user_'.$user->getId()); * </code> * * Check the token in your action using the same CSRF token id. * * <code> * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { * throw new \RuntimeException('CSRF attack detected.'); * } * </code> * * @param string $tokenId The CSRF token id of the protected action * * @return string A CSRF token * * @throws \BadMethodCallException when no CSRF provider was injected in the constructor */ public function csrfToken($tokenId) { return $this->renderer->renderCsrfToken($tokenId); } public function humanize($text) { return $this->renderer->humanize($text); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php����������������0000664�0000000�0000000�00000003101�13247321071�0030602�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\HttpFoundation\RequestStack; /** * RequestHelper provides access to the current request parameters. * * @author Fabien Potencier <fabien@symfony.com> */ class RequestHelper extends Helper { protected $requestStack; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } /** * Returns a parameter from the current request object. * * @param string $key The name of the parameter * @param string $default A default value * * @return mixed * * @see Request::get() */ public function getParameter($key, $default = null) { return $this->getRequest()->get($key, $default); } /** * Returns the locale. * * @return string */ public function getLocale() { return $this->getRequest()->getLocale(); } private function getRequest() { if (!$this->requestStack->getCurrentRequest()) { throw new \LogicException('A Request must be available.'); } return $this->requestStack->getCurrentRequest(); } /** * {@inheritdoc} */ public function getName() { return 'request'; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php�����������������0000664�0000000�0000000�00000004173�13247321071�0030444�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * RouterHelper manages links between pages in a template context. * * @author Fabien Potencier <fabien@symfony.com> */ class RouterHelper extends Helper { protected $generator; public function __construct(UrlGeneratorInterface $router) { $this->generator = $router; } /** * Generates a URL reference (as an absolute or relative path) to the route with the given parameters. * * @param string $name The name of the route * @param mixed $parameters An array of parameters * @param bool $relative Whether to generate a relative or absolute path * * @return string The generated URL reference * * @see UrlGeneratorInterface */ public function path($name, $parameters = array(), $relative = false) { return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); } /** * Generates a URL reference (as an absolute URL or network path) to the route with the given parameters. * * @param string $name The name of the route * @param mixed $parameters An array of parameters * @param bool $schemeRelative Whether to omit the scheme in the generated URL reference * * @return string The generated URL reference * * @see UrlGeneratorInterface */ public function url($name, $parameters = array(), $schemeRelative = false) { return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); } /** * {@inheritdoc} */ public function getName() { return 'router'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php����������������0000664�0000000�0000000�00000003513�13247321071�0030604�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\HttpFoundation\RequestStack; /** * SessionHelper provides read-only access to the session attributes. * * @author Fabien Potencier <fabien@symfony.com> */ class SessionHelper extends Helper { protected $session; protected $requestStack; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } /** * Returns an attribute. * * @param string $name The attribute name * @param mixed $default The default value * * @return mixed */ public function get($name, $default = null) { return $this->getSession()->get($name, $default); } public function getFlash($name, array $default = array()) { return $this->getSession()->getFlashBag()->get($name, $default); } public function getFlashes() { return $this->getSession()->getFlashBag()->all(); } public function hasFlash($name) { return $this->getSession()->getFlashBag()->has($name); } private function getSession() { if (null === $this->session) { if (!$this->requestStack->getMasterRequest()) { throw new \LogicException('A Request must be available.'); } $this->session = $this->requestStack->getMasterRequest()->getSession(); } return $this->session; } /** * {@inheritdoc} */ public function getName() { return 'session'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php��������������0000664�0000000�0000000�00000002174�13247321071�0031137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Templating\Helper\Helper; /** * StopwatchHelper provides methods time your PHP templates. * * @author Wouter J <wouter@wouterj.nl> */ class StopwatchHelper extends Helper { private $stopwatch; public function __construct(Stopwatch $stopwatch = null) { $this->stopwatch = $stopwatch; } public function getName() { return 'stopwatch'; } public function __call($method, $arguments = array()) { if (null !== $this->stopwatch) { if (method_exists($this->stopwatch, $method)) { return call_user_func_array(array($this->stopwatch, $method), $arguments); } throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method)); } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php�������������0000664�0000000�0000000�00000002403�13247321071�0031307�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Translation\TranslatorInterface; /** * @author Fabien Potencier <fabien@symfony.com> */ class TranslatorHelper extends Helper { protected $translator; public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } /** * @see TranslatorInterface::trans() */ public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) { return $this->translator->trans($id, $parameters, $domain, $locale); } /** * @see TranslatorInterface::transChoice() */ public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) { return $this->translator->transChoice($id, $number, $parameters, $domain, $locale); } /** * {@inheritdoc} */ public function getName() { return 'translator'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/���������������������������������0000775�0000000�0000000�00000000000�13247321071�0025275�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php�������������0000664�0000000�0000000�00000002744�13247321071�0031270�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; use Symfony\Component\Templating\Storage\FileStorage; use Symfony\Component\Templating\Loader\LoaderInterface; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\TemplateReferenceInterface; /** * FilesystemLoader is a loader that read templates from the filesystem. * * @author Fabien Potencier <fabien@symfony.com> */ class FilesystemLoader implements LoaderInterface { protected $locator; public function __construct(FileLocatorInterface $locator) { $this->locator = $locator; } /** * {@inheritdoc} */ public function load(TemplateReferenceInterface $template) { try { $file = $this->locator->locate($template); } catch (\InvalidArgumentException $e) { return false; } return new FileStorage($file); } /** * {@inheritdoc} */ public function isFresh(TemplateReferenceInterface $template, $time) { if (false === $storage = $this->load($template)) { return false; } if (!is_readable((string) $storage)) { return false; } return filemtime((string) $storage) < $time; } } ����������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php��������������0000664�0000000�0000000�00000005203�13247321071�0031105�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\TemplateReferenceInterface; /** * TemplateLocator locates templates in bundles. * * @author Fabien Potencier <fabien@symfony.com> */ class TemplateLocator implements FileLocatorInterface { protected $locator; protected $cache; private $cacheHits = array(); /** * @param FileLocatorInterface $locator A FileLocatorInterface instance * @param string $cacheDir The cache path */ public function __construct(FileLocatorInterface $locator, $cacheDir = null) { if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) { $this->cache = require $cache; } $this->locator = $locator; } /** * Returns a full path for a given file. * * @return string The full path for the file */ protected function getCacheKey($template) { return $template->getLogicalName(); } /** * Returns a full path for a given file. * * @param TemplateReferenceInterface $template A template * @param string $currentPath Unused * @param bool $first Unused * * @return string The full path for the file * * @throws \InvalidArgumentException When the template is not an instance of TemplateReferenceInterface * @throws \InvalidArgumentException When the template file can not be found */ public function locate($template, $currentPath = null, $first = true) { if (!$template instanceof TemplateReferenceInterface) { throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.'); } $key = $this->getCacheKey($template); if (isset($this->cacheHits[$key])) { return $this->cacheHits[$key]; } if (isset($this->cache[$key])) { return $this->cacheHits[$key] = realpath($this->cache[$key]) ?: $this->cache[$key]; } try { return $this->cacheHits[$key] = $this->locator->locate($template->getPath(), $currentPath); } catch (\InvalidArgumentException $e) { throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e); } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php���������������������������0000664�0000000�0000000�00000004005�13247321071�0026454�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Psr\Container\ContainerInterface; use Symfony\Component\Templating\PhpEngine as BasePhpEngine; use Symfony\Component\Templating\Loader\LoaderInterface; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\HttpFoundation\Response; /** * This engine knows how to render Symfony templates. * * @author Fabien Potencier <fabien@symfony.com> */ class PhpEngine extends BasePhpEngine implements EngineInterface { protected $container; public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null) { $this->container = $container; parent::__construct($parser, $loader); if (null !== $globals) { $this->addGlobal('app', $globals); } } /** * {@inheritdoc} */ public function get($name) { if (!isset($this->helpers[$name])) { throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); } if (is_string($this->helpers[$name])) { $this->helpers[$name] = $this->container->get($this->helpers[$name]); $this->helpers[$name]->setCharset($this->charset); } return $this->helpers[$name]; } /** * {@inheritdoc} */ public function setHelpers(array $helpers) { $this->helpers = $helpers; } /** * {@inheritdoc} */ public function renderResponse($view, array $parameters = array(), Response $response = null) { if (null === $response) { $response = new Response(); } $response->setContent($this->render($view, $parameters)); return $response; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php��������������0000664�0000000�0000000�00000002260�13247321071�0031171�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; /** * TemplateFilenameParser converts template filenames to * TemplateReferenceInterface instances. * * @author Fabien Potencier <fabien@symfony.com> */ class TemplateFilenameParser implements TemplateNameParserInterface { /** * {@inheritdoc} */ public function parse($name) { if ($name instanceof TemplateReferenceInterface) { return $name; } $parts = explode('/', str_replace('\\', '/', $name)); $elements = explode('.', array_pop($parts)); if (3 > count($elements)) { return false; } $engine = array_pop($elements); $format = array_pop($elements); return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php������������������0000664�0000000�0000000�00000004656�13247321071�0030344�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\Templating\TemplateReferenceInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser; /** * TemplateNameParser converts template names from the short notation * "bundle:section:template.format.engine" to TemplateReferenceInterface * instances. * * @author Fabien Potencier <fabien@symfony.com> */ class TemplateNameParser extends BaseTemplateNameParser { protected $kernel; protected $cache = array(); public function __construct(KernelInterface $kernel) { $this->kernel = $kernel; } /** * {@inheritdoc} */ public function parse($name) { if ($name instanceof TemplateReferenceInterface) { return $name; } elseif (isset($this->cache[$name])) { return $this->cache[$name]; } // normalize name $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name))); if (false !== strpos($name, '..')) { throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); } if ($this->isAbsolutePath($name) || !preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || 0 === strpos($name, '@')) { return parent::parse($name); } $template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]); if ($template->get('bundle')) { try { $this->kernel->getBundle($template->get('bundle')); } catch (\Exception $e) { throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e); } } return $this->cache[$name] = $template; } private function isAbsolutePath($file) { $isAbsolute = (bool) preg_match('#^(?:/|[a-zA-Z]:)#', $file); if ($isAbsolute) { @trigger_error('Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.', E_USER_DEPRECATED); } return $isAbsolute; } } ����������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php�������������������0000664�0000000�0000000�00000003337�13247321071�0030200�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; /** * Internal representation of a template. * * @author Victor Berchet <victor@suumit.com> */ class TemplateReference extends BaseTemplateReference { public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null) { $this->parameters = array( 'bundle' => $bundle, 'controller' => $controller, 'name' => $name, 'format' => $format, 'engine' => $engine, ); } /** * Returns the path to the template * - as a path when the template is not part of a bundle * - as a resource when the template is part of a bundle. * * @return string A path to the template or a resource */ public function getPath() { $controller = str_replace('\\', '/', $this->get('controller')); $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine'); return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path; } /** * {@inheritdoc} */ public function getLogicalName() { return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php����������������������0000664�0000000�0000000�00000002361�13247321071�0027442�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Templating; use Psr\Container\ContainerInterface; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Templating\Loader\LoaderInterface; /** * Times the time spent to render a template. * * @author Fabien Potencier <fabien@symfony.com> */ class TimedPhpEngine extends PhpEngine { protected $stopwatch; public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null) { parent::__construct($parser, $container, $loader, $globals); $this->stopwatch = $stopwatch; } /** * {@inheritdoc} */ public function render($name, array $parameters = array()) { $e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template'); $ret = parent::render($name, $parameters); $e->stop(); return $ret; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Test/����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022702�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php����������������������������0000664�0000000�0000000�00000017061�13247321071�0026274�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ResettableContainerInterface; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\KernelInterface; /** * KernelTestCase is the base class for tests needing a Kernel. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class KernelTestCase extends TestCase { protected static $class; /** * @var KernelInterface */ protected static $kernel; /** * Finds the directory where the phpunit.xml(.dist) is stored. * * If you run tests with the PHPUnit CLI tool, everything will work as expected. * If not, override this method in your test classes. * * @return string The directory where phpunit.xml(.dist) is stored * * @throws \RuntimeException * * @deprecated since 3.4 and will be removed in 4.0. */ protected static function getPhpUnitXmlDir() { @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) { throw new \RuntimeException('You must override the KernelTestCase::createKernel() method.'); } $dir = static::getPhpUnitCliConfigArgument(); if (null === $dir && (is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml') || is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml.dist'))) { $dir = getcwd(); } // Can't continue if (null === $dir) { throw new \RuntimeException('Unable to guess the Kernel directory.'); } if (!is_dir($dir)) { $dir = dirname($dir); } return $dir; } /** * Finds the value of the CLI configuration option. * * PHPUnit will use the last configuration argument on the command line, so this only returns * the last configuration argument. * * @return string The value of the PHPUnit CLI configuration option * * @deprecated since 3.4 and will be removed in 4.0. */ private static function getPhpUnitCliConfigArgument() { @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); $dir = null; $reversedArgs = array_reverse($_SERVER['argv']); foreach ($reversedArgs as $argIndex => $testArg) { if (preg_match('/^-[^ \-]*c$/', $testArg) || '--configuration' === $testArg) { $dir = realpath($reversedArgs[$argIndex - 1]); break; } elseif (0 === strpos($testArg, '--configuration=')) { $argPath = substr($testArg, strlen('--configuration=')); $dir = realpath($argPath); break; } elseif (0 === strpos($testArg, '-c')) { $argPath = substr($testArg, strlen('-c')); $dir = realpath($argPath); break; } } return $dir; } /** * Attempts to guess the kernel location. * * When the Kernel is located, the file is required. * * @return string The Kernel class name * * @throws \RuntimeException */ protected static function getKernelClass() { if (isset($_SERVER['KERNEL_CLASS']) || isset($_ENV['KERNEL_CLASS'])) { $class = isset($_ENV['KERNEL_CLASS']) ? $_ENV['KERNEL_CLASS'] : $_SERVER['KERNEL_CLASS']; if (!class_exists($class)) { throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the %s::createKernel() method.', $class, static::class)); } return $class; } else { @trigger_error(sprintf('Using the KERNEL_DIR environment variable or the automatic guessing based on the phpunit.xml / phpunit.xml.dist file location is deprecated since Symfony 3.4. Set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel instead. Not setting the KERNEL_CLASS environment variable will throw an exception on 4.0 unless you override the %1$::createKernel() or %1$::getKernelClass() method.', static::class), E_USER_DEPRECATED); } if (isset($_SERVER['KERNEL_DIR']) || isset($_ENV['KERNEL_DIR'])) { $dir = isset($_ENV['KERNEL_DIR']) ? $_ENV['KERNEL_DIR'] : $_SERVER['KERNEL_DIR']; if (!is_dir($dir)) { $phpUnitDir = static::getPhpUnitXmlDir(); if (is_dir("$phpUnitDir/$dir")) { $dir = "$phpUnitDir/$dir"; } } } else { $dir = static::getPhpUnitXmlDir(); } $finder = new Finder(); $finder->name('*Kernel.php')->depth(0)->in($dir); $results = iterator_to_array($finder); if (!count($results)) { throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to https://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.'); } $file = current($results); $class = $file->getBasename('.php'); require_once $file; return $class; } /** * Boots the Kernel for this test. * * @return KernelInterface A KernelInterface instance */ protected static function bootKernel(array $options = array()) { static::ensureKernelShutdown(); static::$kernel = static::createKernel($options); static::$kernel->boot(); return static::$kernel; } /** * Creates a Kernel. * * Available options: * * * environment * * debug * * @return KernelInterface A KernelInterface instance */ protected static function createKernel(array $options = array()) { if (null === static::$class) { static::$class = static::getKernelClass(); } if (isset($options['environment'])) { $env = $options['environment']; } elseif (isset($_ENV['APP_ENV'])) { $env = $_ENV['APP_ENV']; } elseif (isset($_SERVER['APP_ENV'])) { $env = $_SERVER['APP_ENV']; } else { $env = 'test'; } if (isset($options['debug'])) { $debug = $options['debug']; } elseif (isset($_ENV['APP_DEBUG'])) { $debug = $_ENV['APP_DEBUG']; } elseif (isset($_SERVER['APP_DEBUG'])) { $debug = $_SERVER['APP_DEBUG']; } else { $debug = true; } return new static::$class($env, $debug); } /** * Shuts the kernel down if it was used in the test. */ protected static function ensureKernelShutdown() { if (null !== static::$kernel) { $container = static::$kernel->getContainer(); static::$kernel->shutdown(); if ($container instanceof ResettableContainerInterface) { $container->reset(); } } } /** * Clean up Kernel usage in this test. */ protected function tearDown() { static::ensureKernelShutdown(); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php�������������������������������0000664�0000000�0000000�00000002002�13247321071�0025556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Test; use Symfony\Bundle\FrameworkBundle\Client; /** * WebTestCase is the base class for functional tests. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class WebTestCase extends KernelTestCase { /** * Creates a Client. * * @param array $options An array of options to pass to the createKernel class * @param array $server An array of server parameters * * @return Client A Client instance */ protected static function createClient(array $options = array(), array $server = array()) { $kernel = static::bootKernel($options); $client = $kernel->getContainer()->get('test.client'); $client->setServerParameters($server); return $client; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/���������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023065�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/���������������������������������0000775�0000000�0000000�00000000000�13247321071�0025246�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php����0000664�0000000�0000000�00000002507�13247321071�0032716�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\WarmedClass; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; /** * @group legacy */ class ClassCacheCacheWarmerTest extends TestCase { public function testWithDeclaredClasses() { $this->assertTrue(class_exists(WarmedClass::class, true)); $dir = sys_get_temp_dir(); @unlink($dir.'/classes.php'); file_put_contents($dir.'/classes.map', sprintf('<?php return %s;', var_export(array(WarmedClass::class), true))); $warmer = new ClassCacheCacheWarmer(array(DeclaredClass::class)); $warmer->warmUp($dir); $this->assertSame(<<<'EOTXT' <?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures { class WarmedClass extends DeclaredClass { } } EOTXT , file_get_contents($dir.'/classes.php') ); @unlink($dir.'/classes.map'); @unlink($dir.'/classes.php'); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php����0000664�0000000�0000000�00000006336�13247321071�0033042�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; class SerializerCacheWarmerTest extends TestCase { public function testWarmUp() { if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) { $this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.'); } $loaders = array( new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'), new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'), ); $file = sys_get_temp_dir().'/cache-serializer.php'; @unlink($file); $fallbackPool = new ArrayAdapter(); $warmer = new SerializerCacheWarmer($loaders, $file, $fallbackPool); $warmer->warmUp(dirname($file)); $this->assertFileExists($file); $values = require $file; $this->assertInternalType('array', $values); $this->assertCount(2, $values); $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person', $values); $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author', $values); $values = $fallbackPool->getValues(); $this->assertInternalType('array', $values); $this->assertCount(2, $values); $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person', $values); $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author', $values); } public function testWarmUpWithoutLoader() { if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) { $this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.'); } $file = sys_get_temp_dir().'/cache-serializer-without-loader.php'; @unlink($file); $fallbackPool = new ArrayAdapter(); $warmer = new SerializerCacheWarmer(array(), $file, $fallbackPool); $warmer->warmUp(dirname($file)); $this->assertFileExists($file); $values = require $file; $this->assertInternalType('array', $values); $this->assertCount(0, $values); $values = $fallbackPool->getValues(); $this->assertInternalType('array', $values); $this->assertCount(0, $values); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php�����������0000664�0000000�0000000�00000003742�13247321071�0031530�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser; use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle; class TemplateFinderTest extends TestCase { public function testFindAllTemplates() { $kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') ->disableOriginalConstructor() ->getMock() ; $kernel ->expects($this->any()) ->method('getBundle') ; $kernel ->expects($this->once()) ->method('getBundles') ->will($this->returnValue(array('BaseBundle' => new BaseBundle()))) ; $parser = new TemplateFilenameParser(); $finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources'); $templates = array_map( function ($template) { return $template->getLogicalName(); }, $finder->findAllTemplates() ); $this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders'); $this->assertContains('BaseBundle::base.format.engine', $templates); $this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates); $this->assertContains('BaseBundle:controller:base.format.engine', $templates); $this->assertContains('BaseBundle:controller:custom.format.engine', $templates); $this->assertContains('::this.is.a.template.format.engine', $templates); $this->assertContains('::resource.format.engine', $templates); } } ������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php�0000664�0000000�0000000�00000006352�13247321071�0033502�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer; use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\Filesystem\Filesystem; class TemplatePathsCacheWarmerTest extends TestCase { /** @var Filesystem */ private $filesystem; /** @var TemplateFinderInterface */ private $templateFinder; /** @var FileLocator */ private $fileLocator; /** @var TemplateLocator */ private $templateLocator; private $tmpDir; protected function setUp() { $this->templateFinder = $this ->getMockBuilder(TemplateFinderInterface::class) ->setMethods(array('findAllTemplates')) ->getMock(); $this->fileLocator = $this ->getMockBuilder(FileLocator::class) ->setMethods(array('locate')) ->setConstructorArgs(array('/path/to/fallback')) ->getMock(); $this->templateLocator = new TemplateLocator($this->fileLocator); $this->tmpDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('cache_template_paths_', true); $this->filesystem = new Filesystem(); $this->filesystem->mkdir($this->tmpDir); } protected function tearDown() { $this->filesystem->remove($this->tmpDir); } public function testWarmUp() { $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') ->will($this->returnValue(array($template))); $this->fileLocator ->expects($this->once()) ->method('locate') ->with($template->getPath()) ->will($this->returnValue(dirname($this->tmpDir).'/path/to/template.html.twig')); $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); $warmer->warmUp($this->tmpDir); $this->assertFileEquals(__DIR__.'/../Fixtures/TemplatePathsCache/templates.php', $this->tmpDir.'/templates.php'); } public function testWarmUpEmpty() { $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') ->will($this->returnValue(array())); $this->fileLocator ->expects($this->never()) ->method('locate'); $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); $warmer->warmUp($this->tmpDir); $this->assertFileExists($this->tmpDir.'/templates.php'); $this->assertSame(file_get_contents(__DIR__.'/../Fixtures/TemplatePathsCache/templates-empty.php'), file_get_contents($this->tmpDir.'/templates.php')); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php�����0000664�0000000�0000000�00000010033�13247321071�0032643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Validator\ValidatorBuilder; class ValidatorCacheWarmerTest extends TestCase { public function testWarmUp() { $validatorBuilder = new ValidatorBuilder(); $validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml'); $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml'); $validatorBuilder->addMethodMapping('loadValidatorMetadata'); $validatorBuilder->enableAnnotationMapping(); $file = sys_get_temp_dir().'/cache-validator.php'; @unlink($file); $fallbackPool = new ArrayAdapter(); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); $warmer->warmUp(dirname($file)); $this->assertFileExists($file); $values = require $file; $this->assertInternalType('array', $values); $this->assertCount(2, $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person', $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values); $values = $fallbackPool->getValues(); $this->assertInternalType('array', $values); $this->assertCount(2, $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person', $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values); } public function testWarmUpWithAnnotations() { $validatorBuilder = new ValidatorBuilder(); $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/categories.yml'); $validatorBuilder->enableAnnotationMapping(); $file = sys_get_temp_dir().'/cache-validator-with-annotations.php'; @unlink($file); $fallbackPool = new ArrayAdapter(); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); $warmer->warmUp(dirname($file)); $this->assertFileExists($file); $values = require $file; $this->assertInternalType('array', $values); $this->assertCount(1, $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values); // Simple check to make sure that at least one constraint is actually cached, in this case the "id" property Type. $this->assertContains('"int"', $values['Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category']); $values = $fallbackPool->getValues(); $this->assertInternalType('array', $values); $this->assertCount(2, $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values); $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory', $values); } public function testWarmUpWithoutLoader() { $validatorBuilder = new ValidatorBuilder(); $file = sys_get_temp_dir().'/cache-validator-without-loaders.php'; @unlink($file); $fallbackPool = new ArrayAdapter(); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); $warmer->warmUp(dirname($file)); $this->assertFileExists($file); $values = require $file; $this->assertInternalType('array', $values); $this->assertCount(0, $values); $values = $fallbackPool->getValues(); $this->assertInternalType('array', $values); $this->assertCount(0, $values); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php�������������������������������0000664�0000000�0000000�00000003413�13247321071�0025655�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests; use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase; use Symfony\Component\HttpFoundation\Response; class ClientTest extends WebTestCase { public function testRebootKernelBetweenRequests() { $mock = $this->getKernelMock(); $mock->expects($this->once())->method('shutdown'); $client = new Client($mock); $client->request('GET', '/'); $client->request('GET', '/'); } public function testDisabledRebootKernel() { $mock = $this->getKernelMock(); $mock->expects($this->never())->method('shutdown'); $client = new Client($mock); $client->disableReboot(); $client->request('GET', '/'); $client->request('GET', '/'); } public function testEnableRebootKernel() { $mock = $this->getKernelMock(); $mock->expects($this->once())->method('shutdown'); $client = new Client($mock); $client->disableReboot(); $client->request('GET', '/'); $client->request('GET', '/'); $client->enableReboot(); $client->request('GET', '/'); } private function getKernelMock() { $mock = $this->getMockBuilder($this->getKernelClass()) ->setMethods(array('shutdown', 'boot', 'handle')) ->disableOriginalConstructor() ->getMock(); $mock->expects($this->any())->method('handle')->willReturn(new Response('foo')); return $mock; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024443�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/�������������������0000775�0000000�0000000�00000000000�13247321071�0027714�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CacheClearCommandTest.php���������������������������������������������������������������������������0000664�0000000�0000000�00000007006�13247321071�0034462�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand���������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture\TestAppKernel; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Config\ConfigCacheFactory; use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; class CacheClearCommandTest extends TestCase { /** @var TestAppKernel */ private $kernel; /** @var Filesystem */ private $fs; private $rootDir; protected function setUp() { $this->fs = new Filesystem(); $this->kernel = new TestAppKernel('test', true); $this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true); $this->kernel->setRootDir($this->rootDir); $this->fs->mkdir($this->rootDir); } protected function tearDown() { $this->fs->remove($this->rootDir); } public function testCacheIsFreshAfterCacheClearedWithWarmup() { $input = new ArrayInput(array('cache:clear')); $application = new Application($this->kernel); $application->setCatchExceptions(false); $application->doRun($input, new NullOutput()); // Ensure that all *.meta files are fresh $finder = new Finder(); $metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta'); // simply check that cache is warmed up $this->assertNotEmpty($metaFiles); $configCacheFactory = new ConfigCacheFactory(true); foreach ($metaFiles as $file) { $configCacheFactory->cache(substr($file, 0, -5), function () use ($file) { $this->fail(sprintf('Meta file "%s" is not fresh', (string) $file)); }); } // check that app kernel file present in meta file of container's cache $containerClass = $this->kernel->getContainer()->getParameter('kernel.container_class'); $containerRef = new \ReflectionClass($containerClass); $containerFile = dirname(dirname($containerRef->getFileName())).'/'.$containerClass.'.php'; $containerMetaFile = $containerFile.'.meta'; $kernelRef = new \ReflectionObject($this->kernel); $kernelFile = $kernelRef->getFileName(); /** @var ResourceInterface[] $meta */ $meta = unserialize(file_get_contents($containerMetaFile)); $found = false; foreach ($meta as $resource) { if ((string) $resource === $kernelFile) { $found = true; break; } } $this->assertTrue($found, 'Kernel file should present as resource'); if (defined('HHVM_VERSION')) { return; } $containerRef = new \ReflectionClass(require $containerFile); $containerFile = str_replace('tes_'.DIRECTORY_SEPARATOR, 'test'.DIRECTORY_SEPARATOR, $containerRef->getFileName()); $this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/�����������0000775�0000000�0000000�00000000000�13247321071�0031342�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������TestAppKernel.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000002072�13247321071�0034516�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture�������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture; use Psr\Log\NullLogger; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; class TestAppKernel extends Kernel { public function registerBundles() { return array( new FrameworkBundle(), ); } public function setRootDir($rootDir) { $this->rootDir = $rootDir; } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(__DIR__.DIRECTORY_SEPARATOR.'config.yml'); } protected function build(ContainerBuilder $container) { $container->register('logger', NullLogger::class); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/config.yml�0000664�0000000�0000000�00000000034�13247321071�0033327�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: secret: test ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php������������0000664�0000000�0000000�00000005747�13247321071�0031345�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Symfony\Component\HttpKernel\KernelInterface; class CachePruneCommandTest extends TestCase { public function testCommandWithPools() { $tester = $this->getCommandTester($this->getKernel(), $this->getRewindableGenerator()); $tester->execute(array()); } public function testCommandWithNoPools() { $tester = $this->getCommandTester($this->getKernel(), $this->getEmptyRewindableGenerator()); $tester->execute(array()); } /** * @return RewindableGenerator */ private function getRewindableGenerator() { return new RewindableGenerator(function () { yield 'foo_pool' => $this->getPruneableInterfaceMock(); yield 'bar_pool' => $this->getPruneableInterfaceMock(); }, 2); } /** * @return RewindableGenerator */ private function getEmptyRewindableGenerator() { return new RewindableGenerator(function () { return new \ArrayIterator(array()); }, 0); } /** * @return \PHPUnit_Framework_MockObject_MockObject|KernelInterface */ private function getKernel() { $container = $this ->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface') ->getMock(); $kernel = $this ->getMockBuilder(KernelInterface::class) ->getMock(); $kernel ->expects($this->any()) ->method('getContainer') ->willReturn($container); $kernel ->expects($this->once()) ->method('getBundles') ->willReturn(array()); return $kernel; } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableInterface */ private function getPruneableInterfaceMock() { $pruneable = $this ->getMockBuilder(PruneableInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune'); return $pruneable; } /** * @return CommandTester */ private function getCommandTester(KernelInterface $kernel, RewindableGenerator $generator) { $application = new Application($kernel); $application->add(new CachePoolPruneCommand($generator)); return new CommandTester($application->find('cache:pool:prune')); } } �������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php�����������0000664�0000000�0000000�00000007621�13247321071�0031550�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; class RouterDebugCommandTest extends TestCase { public function testDebugAllRoutes() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => null), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Name Method Scheme Host Path', $tester->getDisplay()); } public function testDebugSingleRoute() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => 'foo'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Route Name | foo', $tester->getDisplay()); } /** * @expectedException \InvalidArgumentException */ public function testDebugInvalidRoute() { $this->createCommandTester()->execute(array('name' => 'test')); } /** * @group legacy * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct() expects an instance of "Symfony\Component\Routing\RouterInterface" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. */ public function testLegacyDebugCommand() { $application = new Application($this->getKernel()); $application->add(new RouterDebugCommand()); $tester = new CommandTester($application->find('debug:router')); $tester->execute(array()); $this->assertRegExp('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay()); } /** * @return CommandTester */ private function createCommandTester() { $application = new Application($this->getKernel()); $application->add(new RouterDebugCommand($this->getRouter())); return new CommandTester($application->find('debug:router')); } private function getRouter() { $routeCollection = new RouteCollection(); $routeCollection->add('foo', new Route('foo')); $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router ->expects($this->any()) ->method('getRouteCollection') ->will($this->returnValue($routeCollection)); return $router; } private function getKernel() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->atLeastOnce()) ->method('has') ->will($this->returnCallback(function ($id) { if ('console.command_loader' === $id) { return false; } return true; })) ; $container ->expects($this->any()) ->method('get') ->with('router') ->willReturn($this->getRouter()) ; $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getContainer') ->willReturn($container) ; $kernel ->expects($this->once()) ->method('getBundles') ->willReturn(array()) ; return $kernel; } } ���������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php�����������0000664�0000000�0000000�00000010673�13247321071�0031557�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand; use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RequestContext; class RouterMatchCommandTest extends TestCase { public function testWithMatchPath() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('path_info' => '/foo', 'foo'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Route Name | foo', $tester->getDisplay()); } public function testWithNotMatchPath() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('path_info' => '/test', 'foo'), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of failure'); $this->assertContains('None of the routes match the path "/test"', $tester->getDisplay()); } /** * @group legacy * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand::__construct() expects an instance of "Symfony\Component\Routing\RouterInterface" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct() expects an instance of "Symfony\Component\Routing\RouterInterface" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. */ public function testLegacyMatchCommand() { $application = new Application($this->getKernel()); $application->add(new RouterMatchCommand()); $application->add(new RouterDebugCommand()); $tester = new CommandTester($application->find('router:match')); $tester->execute(array('path_info' => '/')); $this->assertContains('None of the routes match the path "/"', $tester->getDisplay()); } /** * @return CommandTester */ private function createCommandTester() { $application = new Application($this->getKernel()); $application->add(new RouterMatchCommand($this->getRouter())); $application->add(new RouterDebugCommand($this->getRouter())); return new CommandTester($application->find('router:match')); } private function getRouter() { $routeCollection = new RouteCollection(); $routeCollection->add('foo', new Route('foo')); $requestContext = new RequestContext(); $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router ->expects($this->any()) ->method('getRouteCollection') ->will($this->returnValue($routeCollection)); $router ->expects($this->any()) ->method('getContext') ->will($this->returnValue($requestContext)); return $router; } private function getKernel() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->atLeastOnce()) ->method('has') ->will($this->returnCallback(function ($id) { if ('console.command_loader' === $id) { return false; } return true; })) ; $container ->expects($this->any()) ->method('get') ->with('router') ->willReturn($this->getRouter()) ; $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getContainer') ->willReturn($container) ; $kernel ->expects($this->once()) ->method('getBundles') ->willReturn(array()) ; return $kernel; } } ���������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php������0000664�0000000�0000000�00000023033�13247321071�0032561�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel; class TranslationDebugCommandTest extends TestCase { private $fs; private $translationDir; public function testDebugMissingMessages() { $tester = $this->createCommandTester(array('foo' => 'foo')); $tester->execute(array('locale' => 'en', 'bundle' => 'foo')); $this->assertRegExp('/missing/', $tester->getDisplay()); } public function testDebugUnusedMessages() { $tester = $this->createCommandTester(array(), array('foo' => 'foo')); $tester->execute(array('locale' => 'en', 'bundle' => 'foo')); $this->assertRegExp('/unused/', $tester->getDisplay()); } public function testDebugFallbackMessages() { $tester = $this->createCommandTester(array(), array('foo' => 'foo')); $tester->execute(array('locale' => 'fr', 'bundle' => 'foo')); $this->assertRegExp('/fallback/', $tester->getDisplay()); } public function testNoDefinedMessages() { $tester = $this->createCommandTester(); $tester->execute(array('locale' => 'fr', 'bundle' => 'test')); $this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay()); } public function testDebugDefaultDirectory() { $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar')); $tester->execute(array('locale' => 'en')); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); } public function testDebugDefaultRootDirectory() { $this->fs->remove($this->translationDir); $this->fs = new Filesystem(); $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true); $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar')); $tester->execute(array('locale' => 'en')); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); } public function testDebugCustomDirectory() { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel->expects($this->once()) ->method('getBundle') ->with($this->equalTo($this->translationDir)) ->willThrowException(new \InvalidArgumentException()); $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'), $kernel); $tester->execute(array('locale' => 'en', 'bundle' => $this->translationDir)); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); } /** * @expectedException \InvalidArgumentException */ public function testDebugInvalidDirectory() { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel->expects($this->once()) ->method('getBundle') ->with($this->equalTo('dir')) ->will($this->throwException(new \InvalidArgumentException())); $tester = $this->createCommandTester(array(), array(), $kernel); $tester->execute(array('locale' => 'en', 'bundle' => 'dir')); } protected function setUp() { $this->fs = new Filesystem(); $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true); $this->fs->mkdir($this->translationDir.'/Resources/translations'); $this->fs->mkdir($this->translationDir.'/Resources/views'); $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); } protected function tearDown() { $this->fs->remove($this->translationDir); } /** * @return CommandTester */ private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), $kernel = null) { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() ->getMock(); $translator ->expects($this->any()) ->method('getFallbackLocales') ->will($this->returnValue(array('en'))); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') ->will( $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { $catalogue->add($extractedMessages); }) ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') ->will( $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); }) ); if (null === $kernel) { $returnValues = array( array('foo', $this->getBundle($this->translationDir)), array('test', $this->getBundle('test')), ); if (HttpKernel\Kernel::VERSION_ID < 40000) { $returnValues = array( array('foo', true, $this->getBundle($this->translationDir)), array('test', true, $this->getBundle('test')), ); } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundle') ->will($this->returnValueMap($returnValues)); } $kernel ->expects($this->any()) ->method('getRootDir') ->will($this->returnValue($this->translationDir)); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array())); $kernel ->expects($this->any()) ->method('getContainer') ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates'); $application = new Application($kernel); $application->add($command); return new CommandTester($application->find('debug:translation')); } /** * @group legacy * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand::__construct() expects an instance of "Symfony\Component\Translation\TranslatorInterface" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. */ public function testLegacyDebugCommand() { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() ->getMock(); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array())); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') ->will($this->returnValueMap(array( array('translation.extractor', 1, $extractor), array('translation.reader', 1, $loader), array('translator', 1, $translator), array('kernel', 1, $kernel), ))); $kernel ->expects($this->any()) ->method('getContainer') ->will($this->returnValue($container)); $command = new TranslationDebugCommand(); $command->setContainer($container); $application = new Application($kernel); $application->add($command); $tester = new CommandTester($application->find('debug:translation')); $tester->execute(array('locale' => 'en')); $this->assertContains('No defined or extracted', $tester->getDisplay()); } private function getBundle($path) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle ->expects($this->any()) ->method('getPath') ->will($this->returnValue($path)) ; return $bundle; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php�����0000664�0000000�0000000�00000025014�13247321071�0032756�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel; class TranslationUpdateCommandTest extends TestCase { private $fs; private $translationDir; public function testDumpMessagesAndClean() { $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } public function testDumpMessagesAndCleanInRootDirectory() { $this->fs->remove($this->translationDir); $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true); $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true)); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } public function testDumpTwoMessagesAndClean() { $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo', 'bar' => 'bar'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/bar/', $tester->getDisplay()); $this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay()); } public function testDumpMessagesForSpecificDomain() { $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain')); $this->assertRegExp('/bar/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } public function testWriteMessages() { $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true)); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } public function testWriteMessagesInRootDirectory() { $this->fs->remove($this->translationDir); $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true); $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', '--force' => true)); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } public function testWriteMessagesForSpecificDomain() { $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain')); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } protected function setUp() { $this->fs = new Filesystem(); $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true); $this->fs->mkdir($this->translationDir.'/Resources/translations'); $this->fs->mkdir($this->translationDir.'/Resources/views'); $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); } protected function tearDown() { $this->fs->remove($this->translationDir); } /** * @return CommandTester */ private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), HttpKernel\KernelInterface $kernel = null) { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() ->getMock(); $translator ->expects($this->any()) ->method('getFallbackLocales') ->will($this->returnValue(array('en'))); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') ->will( $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { foreach ($extractedMessages as $domain => $messages) { $catalogue->add($messages, $domain); } }) ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') ->will( $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); }) ); $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $writer ->expects($this->any()) ->method('getFormats') ->will( $this->returnValue(array('xlf', 'yml')) ); if (null === $kernel) { $returnValues = array( array('foo', $this->getBundle($this->translationDir)), array('test', $this->getBundle('test')), ); if (HttpKernel\Kernel::VERSION_ID < 40000) { $returnValues = array( array('foo', true, $this->getBundle($this->translationDir)), array('test', true, $this->getBundle('test')), ); } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundle') ->will($this->returnValueMap($returnValues)); } $kernel ->expects($this->any()) ->method('getRootDir') ->will($this->returnValue($this->translationDir)); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array())); $kernel ->expects($this->any()) ->method('getContainer') ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates'); $application = new Application($kernel); $application->add($command); return new CommandTester($application->find('translation:update')); } /** * @group legacy * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand::__construct() expects an instance of "Symfony\Component\Translation\Writer\TranslationWriterInterface" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. */ public function testLegacyUpdateCommand() { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() ->getMock(); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock(); $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array())); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') ->will($this->returnValueMap(array( array('translation.extractor', 1, $extractor), array('translation.reader', 1, $loader), array('translation.writer', 1, $writer), array('translator', 1, $translator), array('kernel', 1, $kernel), ))); $kernel ->expects($this->any()) ->method('getContainer') ->will($this->returnValue($container)); $command = new TranslationUpdateCommand(); $command->setContainer($container); $application = new Application($kernel); $application->add($command); $tester = new CommandTester($application->find('translation:update')); $tester->execute(array('locale' => 'en')); $this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay()); } private function getBundle($path) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle ->expects($this->any()) ->method('getPath') ->will($this->returnValue($path)) ; return $bundle; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php��������������0000664�0000000�0000000�00000013141�13247321071�0031044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\HttpKernel\KernelInterface; /** * Tests the YamlLintCommand. * * @author Robin Chalas <robin.chalas@gmail.com> */ class YamlLintCommandTest extends TestCase { private $files; public function testLintCorrectFile() { $tester = $this->createCommandTester(); $filename = $this->createFile('foo: bar'); $tester->execute( array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) ); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertContains('OK', trim($tester->getDisplay())); } public function testLintIncorrectFile() { $incorrectContent = ' foo: bar'; $tester = $this->createCommandTester(); $filename = $this->createFile($incorrectContent); $tester->execute(array('filename' => $filename), array('decorated' => false)); $this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error'); $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); } /** * @expectedException \RuntimeException */ public function testLintFileNotReadable() { $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); $tester->execute(array('filename' => $filename), array('decorated' => false)); } public function testGetHelp() { $command = new YamlLintCommand(); $expected = <<<EOF The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT the first encountered syntax error. You can validates YAML contents passed from STDIN: <info>cat filename | php %command.full_name%</info> You can also validate the syntax of a file: <info>php %command.full_name% filename</info> Or of a whole directory: <info>php %command.full_name% dirname</info> <info>php %command.full_name% dirname --format=json</info> Or find all files in a bundle: <info>php %command.full_name% @AcmeDemoBundle</info> EOF; $this->assertEquals($expected, $command->getHelp()); } public function testLintFilesFromBundleDirectory() { $tester = $this->createCommandTester($this->getKernelAwareApplicationMock()); $tester->execute( array('filename' => '@AppBundle/Resources'), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) ); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertContains('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay())); } /** * @return string Path to the new file */ private function createFile($content) { $filename = tempnam(sys_get_temp_dir().'/yml-lint-test', 'sf-'); file_put_contents($filename, $content); $this->files[] = $filename; return $filename; } /** * @return CommandTester */ private function createCommandTester($application = null) { if (!$application) { $application = new BaseApplication(); $application->add(new YamlLintCommand()); } $command = $application->find('lint:yaml'); if ($application) { $command->setApplication($application); } return new CommandTester($command); } private function getKernelAwareApplicationMock() { $kernel = $this->getMockBuilder(KernelInterface::class) ->disableOriginalConstructor() ->getMock(); $kernel ->expects($this->once()) ->method('locateResource') ->with('@AppBundle/Resources') ->willReturn(sys_get_temp_dir().'/yml-lint-test'); $application = $this->getMockBuilder(Application::class) ->disableOriginalConstructor() ->getMock(); $application ->expects($this->once()) ->method('getKernel') ->willReturn($kernel); $application ->expects($this->once()) ->method('getHelperSet') ->willReturn(new HelperSet()); $application ->expects($this->any()) ->method('getDefinition') ->willReturn(new InputDefinition()); $application ->expects($this->once()) ->method('find') ->with('lint:yaml') ->willReturn(new YamlLintCommand()); return $application; } protected function setUp() { @mkdir(sys_get_temp_dir().'/yml-lint-test'); $this->files = array(); } protected function tearDown() { foreach ($this->files as $file) { if (file_exists($file)) { unlink($file); } } rmdir(sys_get_temp_dir().'/yml-lint-test'); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024467�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php������������������0000664�0000000�0000000�00000021601�13247321071�0030303�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\ApplicationTester; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpKernel\KernelInterface; class ApplicationTest extends TestCase { public function testBundleInterfaceImplementation() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $kernel = $this->getKernel(array($bundle), true); $application = new Application($kernel); $application->doRun(new ArrayInput(array('list')), new NullOutput()); } public function testBundleCommandsAreRegistered() { $bundle = $this->createBundleMock(array()); $kernel = $this->getKernel(array($bundle), true); $application = new Application($kernel); $application->doRun(new ArrayInput(array('list')), new NullOutput()); // Calling twice: registration should only be done once. $application->doRun(new ArrayInput(array('list')), new NullOutput()); } public function testBundleCommandsAreRetrievable() { $bundle = $this->createBundleMock(array()); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $application->all(); // Calling twice: registration should only be done once. $application->all(); } public function testBundleSingleCommandIsRetrievable() { $command = new Command('example'); $bundle = $this->createBundleMock(array($command)); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $this->assertSame($command, $application->get('example')); } public function testBundleCommandCanBeFound() { $command = new Command('example'); $bundle = $this->createBundleMock(array($command)); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $this->assertSame($command, $application->find('example')); } public function testBundleCommandCanBeFoundByAlias() { $command = new Command('example'); $command->setAliases(array('alias')); $bundle = $this->createBundleMock(array($command)); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $this->assertSame($command, $application->find('alias')); } public function testBundleCommandsHaveRightContainer() { $command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer')); $command->setCode(function () {}); $command->expects($this->exactly(2))->method('setContainer'); $application = new Application($this->getKernel(array(), true)); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add($command); $tester = new ApplicationTester($application); // set container is called here $tester->run(array('command' => 'foo')); // as the container might have change between two runs, setContainer must called again $tester->run(array('command' => 'foo')); } public function testBundleCommandCanOverriddeAPreExistingCommandWithTheSameName() { $command = new Command('example'); $bundle = $this->createBundleMock(array($command)); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $newCommand = new Command('example'); $application->add($newCommand); $this->assertSame($newCommand, $application->get('example')); } public function testRunOnlyWarnsOnUnregistrableCommand() { $container = new ContainerBuilder(); $container->register('event_dispatcher', EventDispatcher::class); $container->register(ThrowingCommand::class, ThrowingCommand::class); $container->setParameter('console.command.ids', array(ThrowingCommand::class => ThrowingCommand::class)); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->method('getBundles') ->willReturn(array($this->createBundleMock( array((new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })) ))); $kernel ->method('getContainer') ->willReturn($container); $application = new Application($kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'fine')); $output = $tester->getDisplay(); $this->assertSame(0, $tester->getStatusCode()); $this->assertContains('Some commands could not be registered:', $output); $this->assertContains('throwing', $output); $this->assertContains('fine', $output); } public function testRegistrationErrorsAreDisplayedOnCommandNotFound() { $container = new ContainerBuilder(); $container->register('event_dispatcher', EventDispatcher::class); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->method('getBundles') ->willReturn(array($this->createBundleMock( array((new Command(null))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })) ))); $kernel ->method('getContainer') ->willReturn($container); $application = new Application($kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'fine')); $output = $tester->getDisplay(); $this->assertSame(1, $tester->getStatusCode()); $this->assertContains('Some commands could not be registered:', $output); $this->assertContains('Command "fine" is not defined.', $output); } private function getKernel(array $bundles, $useDispatcher = false) { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); if ($useDispatcher) { $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher ->expects($this->atLeastOnce()) ->method('dispatch') ; $container ->expects($this->atLeastOnce()) ->method('get') ->with($this->equalTo('event_dispatcher')) ->will($this->returnValue($dispatcher)); } $container ->expects($this->exactly(2)) ->method('hasParameter') ->withConsecutive(array('console.command.ids'), array('console.lazy_command.ids')) ->willReturnOnConsecutiveCalls(true, true) ; $container ->expects($this->exactly(2)) ->method('getParameter') ->withConsecutive(array('console.lazy_command.ids'), array('console.command.ids')) ->willReturnOnConsecutiveCalls(array(), array()) ; $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue($bundles)) ; $kernel ->expects($this->any()) ->method('getContainer') ->will($this->returnValue($container)) ; return $kernel; } private function createBundleMock(array $commands) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle ->expects($this->once()) ->method('registerCommands') ->will($this->returnCallback(function (Application $application) use ($commands) { $application->addCommands($commands); })) ; return $bundle; } } class ThrowingCommand extends Command { public function __construct() { throw new \Exception('throwing'); } } �������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/��������������������������0000775�0000000�0000000�00000000000�13247321071�0026605�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php0000664�0000000�0000000�00000022176�13247321071�0033770�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; abstract class AbstractDescriptorTest extends TestCase { /** @dataProvider getDescribeRouteCollectionTestData */ public function testDescribeRouteCollection(RouteCollection $routes, $expectedDescription) { $this->assertDescription($expectedDescription, $routes); } public function getDescribeRouteCollectionTestData() { return $this->getDescriptionTestData(ObjectsProvider::getRouteCollections()); } /** @dataProvider getDescribeRouteTestData */ public function testDescribeRoute(Route $route, $expectedDescription) { $this->assertDescription($expectedDescription, $route); } public function getDescribeRouteTestData() { return $this->getDescriptionTestData(ObjectsProvider::getRoutes()); } /** @dataProvider getDescribeContainerParametersTestData */ public function testDescribeContainerParameters(ParameterBag $parameters, $expectedDescription) { $this->assertDescription($expectedDescription, $parameters); } public function getDescribeContainerParametersTestData() { return $this->getDescriptionTestData(ObjectsProvider::getContainerParameters()); } /** @dataProvider getDescribeContainerBuilderTestData */ public function testDescribeContainerBuilder(ContainerBuilder $builder, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $builder, $options); } public function getDescribeContainerBuilderTestData() { return $this->getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); } /** @dataProvider getDescribeContainerDefinitionTestData */ public function testDescribeContainerDefinition(Definition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition); } public function getDescribeContainerDefinitionTestData() { return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); } /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */ public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition, array('show_arguments' => true)); } public function getDescribeContainerDefinitionWithArgumentsShownTestData() { $definitions = ObjectsProvider::getContainerDefinitions(); $definitionsWithArgs = array(); foreach ($definitions as $key => $definition) { $definitionsWithArgs[str_replace('definition_', 'definition_arguments_', $key)] = $definition; } return $this->getDescriptionTestData($definitionsWithArgs); } /** @dataProvider getDescribeContainerAliasTestData */ public function testDescribeContainerAlias(Alias $alias, $expectedDescription) { $this->assertDescription($expectedDescription, $alias); } public function getDescribeContainerAliasTestData() { return $this->getDescriptionTestData(ObjectsProvider::getContainerAliases()); } /** @dataProvider getDescribeContainerDefinitionWhichIsAnAliasTestData */ public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $expectedDescription, ContainerBuilder $builder, $options = array()) { $this->assertDescription($expectedDescription, $builder, $options); } public function getDescribeContainerDefinitionWhichIsAnAliasTestData() { $builder = current(ObjectsProvider::getContainerBuilders()); $builder->setDefinition('service_1', $builder->getDefinition('definition_1')); $builder->setDefinition('service_2', $builder->getDefinition('definition_2')); $aliases = ObjectsProvider::getContainerAliases(); $aliasesWithDefinitions = array(); foreach ($aliases as $name => $alias) { $aliasesWithDefinitions[str_replace('alias_', 'alias_with_definition_', $name)] = $alias; } $i = 0; $data = $this->getDescriptionTestData($aliasesWithDefinitions); foreach ($aliases as $name => $alias) { $data[$i][] = $builder; $data[$i][] = array('id' => $name); ++$i; } return $data; } /** @dataProvider getDescribeContainerParameterTestData */ public function testDescribeContainerParameter($parameter, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $parameter, $options); } public function getDescribeContainerParameterTestData() { $data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter()); $data[0][] = array('parameter' => 'database_name'); $data[1][] = array('parameter' => 'twig.form.resources'); return $data; } /** @dataProvider getDescribeEventDispatcherTestData */ public function testDescribeEventDispatcher(EventDispatcher $eventDispatcher, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $eventDispatcher, $options); } public function getDescribeEventDispatcherTestData() { return $this->getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); } /** @dataProvider getDescribeCallableTestData */ public function testDescribeCallable($callable, $expectedDescription) { $this->assertDescription($expectedDescription, $callable); } public function getDescribeCallableTestData() { return $this->getDescriptionTestData(ObjectsProvider::getCallables()); } abstract protected function getDescriptor(); abstract protected function getFormat(); private function assertDescription($expectedDescription, $describedObject, array $options = array()) { $options['raw_output'] = true; $options['raw_text'] = true; $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); if ('txt' === $this->getFormat()) { $options['output'] = new SymfonyStyle(new ArrayInput(array()), $output); } $this->getDescriptor()->describe($output, $describedObject, $options); if ('json' === $this->getFormat()) { $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), JSON_PRETTY_PRINT)); } else { $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); } } private function getDescriptionTestData(array $objects) { $data = array(); foreach ($objects as $name => $object) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s.%s', __DIR__, $name, $this->getFormat())); $data[] = array($object, $description); } return $data; } private function getContainerBuilderDescriptionTestData(array $objects) { $variations = array( 'services' => array('show_private' => true), 'public' => array('show_private' => false), 'tag1' => array('show_private' => true, 'tag' => 'tag1'), 'tags' => array('group_by' => 'tags', 'show_private' => true), 'arguments' => array('show_private' => false, 'show_arguments' => true), ); $data = array(); foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s_%s.%s', __DIR__, $name, $suffix, $this->getFormat())); $data[] = array($object, $description, $options); } } return $data; } private function getEventDispatcherDescriptionTestData(array $objects) { $variations = array( 'events' => array(), 'event1' => array('event' => 'event1'), ); $data = array(); foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s_%s.%s', __DIR__, $name, $suffix, $this->getFormat())); $data[] = array($object, $description, $options); } } return $data; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php����0000664�0000000�0000000�00000001124�13247321071�0033124�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor; class JsonDescriptorTest extends AbstractDescriptorTest { protected function getDescriptor() { return new JsonDescriptor(); } protected function getFormat() { return 'json'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php0000664�0000000�0000000�00000001136�13247321071�0034000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\MarkdownDescriptor; class MarkdownDescriptorTest extends AbstractDescriptorTest { protected function getDescriptor() { return new MarkdownDescriptor(); } protected function getFormat() { return 'md'; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php�������0000664�0000000�0000000�00000014405�13247321071�0032426�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\CompiledRoute; use Symfony\Component\Routing\RouteCollection; class ObjectsProvider { public static function getRouteCollections() { $collection1 = new RouteCollection(); foreach (self::getRoutes() as $name => $route) { $collection1->add($name, $route); } return array('route_collection_1' => $collection1); } public static function getRoutes() { return array( 'route_1' => new RouteStub( '/hello/{name}', array('name' => 'Joseph'), array('name' => '[a-z]+'), array('opt1' => 'val1', 'opt2' => 'val2'), 'localhost', array('http', 'https'), array('get', 'head') ), 'route_2' => new RouteStub( '/name/add', array(), array(), array('opt1' => 'val1', 'opt2' => 'val2'), 'localhost', array('http', 'https'), array('put', 'post') ), ); } public static function getContainerParameters() { return array( 'parameters_1' => new ParameterBag(array( 'integer' => 12, 'string' => 'Hello world!', 'boolean' => true, 'array' => array(12, 'Hello world!', true), )), ); } public static function getContainerParameter() { $builder = new ContainerBuilder(); $builder->setParameter('database_name', 'symfony'); $builder->setParameter('twig.form.resources', array( 'bootstrap_3_horizontal_layout.html.twig', 'bootstrap_3_layout.html.twig', 'form_div_layout.html.twig', 'form_table_layout.html.twig', )); return array( 'parameter' => $builder, 'array_parameter' => $builder, ); } public static function getContainerBuilders() { $builder1 = new ContainerBuilder(); $builder1->setDefinitions(self::getContainerDefinitions()); $builder1->setAliases(self::getContainerAliases()); return array('builder_1' => $builder1); } public static function getContainerDefinitions() { $definition1 = new Definition('Full\\Qualified\\Class1'); $definition2 = new Definition('Full\\Qualified\\Class2'); return array( 'definition_1' => $definition1 ->setPublic(true) ->setSynthetic(false) ->setLazy(true) ->setAbstract(true) ->addArgument(new Reference('definition2')) ->addArgument('%parameter%') ->addArgument(new Definition('inline_service', array('arg1', 'arg2'))) ->addArgument(array( 'foo', new Reference('definition2'), new Definition('inline_service'), )) ->addArgument(new IteratorArgument(array( new Reference('definition_1'), new Reference('definition_2'), ))) ->setFactory(array('Full\\Qualified\\FactoryClass', 'get')), 'definition_2' => $definition2 ->setPublic(false) ->setSynthetic(true) ->setFile('/path/to/file') ->setLazy(false) ->setAbstract(false) ->addTag('tag1', array('attr1' => 'val1', 'attr2' => 'val2')) ->addTag('tag1', array('attr3' => 'val3')) ->addTag('tag2') ->addMethodCall('setMailer', array(new Reference('mailer'))) ->setFactory(array(new Reference('factory.service'), 'get')), ); } public static function getContainerAliases() { return array( 'alias_1' => new Alias('service_1', true), 'alias_2' => new Alias('service_2', false), ); } public static function getEventDispatchers() { $eventDispatcher = new EventDispatcher(); $eventDispatcher->addListener('event1', 'global_function', 255); $eventDispatcher->addListener('event1', function () { return 'Closure'; }, -1); $eventDispatcher->addListener('event2', new CallableClass()); return array('event_dispatcher_1' => $eventDispatcher); } public static function getCallables() { return array( 'callable_1' => 'array_key_exists', 'callable_2' => array('Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'), 'callable_3' => array(new CallableClass(), 'method'), 'callable_4' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass::staticMethod', 'callable_5' => array('Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'), 'callable_6' => function () { return 'Closure'; }, 'callable_7' => new CallableClass(), ); } } class CallableClass { public function __invoke() { } public static function staticMethod() { } public function method() { } } class ExtendedCallableClass extends CallableClass { public static function staticMethod() { } } class RouteStub extends Route { public function compile() { return new CompiledRoute('', '#PATH_REGEX#', array(), array(), '#HOST_REGEX#'); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php����0000664�0000000�0000000�00000001350�13247321071�0033140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\TextDescriptor; class TextDescriptorTest extends AbstractDescriptorTest { protected function setUp() { putenv('COLUMNS=121'); } protected function tearDown() { putenv('COLUMNS'); } protected function getDescriptor() { return new TextDescriptor(); } protected function getFormat() { return 'txt'; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/XmlDescriptorTest.php�����0000664�0000000�0000000�00000001120�13247321071�0032747�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\XmlDescriptor; class XmlDescriptorTest extends AbstractDescriptorTest { protected function getDescriptor() { return new XmlDescriptor(); } protected function getFormat() { return 'xml'; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025210�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php��������0000664�0000000�0000000�00000003521�13247321071�0032371�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class AbstractControllerTest extends ControllerTraitTest { protected function createController() { return new TestAbstractController(); } } class TestAbstractController extends AbstractController { use TestControllerTrait; private $throwOnUnexpectedService; public function __construct($throwOnUnexpectedService = true) { $this->throwOnUnexpectedService = $throwOnUnexpectedService; } public function setContainer(ContainerInterface $container) { if (!$this->throwOnUnexpectedService) { return parent::setContainer($container); } $expected = self::getSubscribedServices(); foreach ($container->getServiceIds() as $id) { if ('service_container' === $id) { continue; } if (!isset($expected[$id])) { throw new \UnexpectedValueException(sprintf('Service "%s" is not expected, as declared by %s::getSubscribedServices()', $id, AbstractController::class)); } $type = substr($expected[$id], 1); if (!$container->get($id) instanceof $type) { throw new \UnexpectedValueException(sprintf('Service "%s" is expected to be an instance of "%s", as declared by %s::getSubscribedServices()', $id, $type, AbstractController::class)); } } return parent::setContainer($container); } public function fooAction() { } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php������0000664�0000000�0000000�00000021561�13247321071�0032667�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Composer\Autoload\ClassLoader; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Component\HttpKernel\Kernel; class ControllerNameParserTest extends TestCase { protected $loader; protected function setUp() { $this->loader = new ClassLoader(); $this->loader->add('TestBundle', __DIR__.'/../Fixtures'); $this->loader->add('TestApplication', __DIR__.'/../Fixtures'); $this->loader->register(); } protected function tearDown() { $this->loader->unregister(); $this->loader = null; } public function testParse() { $parser = $this->createParser(); $this->assertEquals('TestBundle\FooBundle\Controller\DefaultController::indexAction', $parser->parse('FooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction', $parser->parse('FooBundle:Sub\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Fabpot\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioCmsFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\FooBundle\Controller\Test\DefaultController::indexAction', $parser->parse('FooBundle:Test\\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\FooBundle\Controller\Test\DefaultController::indexAction', $parser->parse('FooBundle:Test/Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); try { $parser->parse('foo:'); $this->fail('->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string'); } } public function testBuild() { $parser = $this->createParser(); $this->assertEquals('FoooooBundle:Default:index', $parser->build('TestBundle\FooBundle\Controller\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string'); $this->assertEquals('FoooooBundle:Sub\Default:index', $parser->build('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string'); try { $parser->build('TestBundle\FooBundle\Controller\DefaultController::index'); $this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } try { $parser->build('TestBundle\FooBundle\Controller\Default::indexAction'); $this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } try { $parser->build('Foo\Controller\DefaultController::indexAction'); $this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string'); } } /** * @dataProvider getMissingControllersTest */ public function testMissingControllers($name) { $parser = $this->createParser(); try { $parser->parse($name); $this->fail('->parse() throws a \InvalidArgumentException if the class is found but does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the class is found but does not exist'); } } public function getMissingControllersTest() { // a normal bundle $bundles = array( array('FooBundle:Fake:index'), ); // a bundle with children if (Kernel::VERSION_ID < 40000) { $bundles[] = array('SensioFooBundle:Fake:index'); } return $bundles; } /** * @dataProvider getInvalidBundleNameTests */ public function testInvalidBundleName($bundleName, $suggestedBundleName) { $parser = $this->createParser(); try { $parser->parse($bundleName); $this->fail('->parse() throws a \InvalidArgumentException if the bundle does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the bundle does not exist'); if (false === $suggestedBundleName) { // make sure we don't have a suggestion $this->assertNotContains('Did you mean', $e->getMessage()); } else { $this->assertContains(sprintf('Did you mean "%s"', $suggestedBundleName), $e->getMessage()); } } } public function getInvalidBundleNameTests() { return array( 'Alternative will be found using levenshtein' => array('FoodBundle:Default:index', 'FooBundle:Default:index'), 'Alternative will be found using partial match' => array('FabpotFooBund:Default:index', 'FabpotFooBundle:Default:index'), 'Bundle does not exist at all' => array('CrazyBundle:Default:index', false), ); } private function createParser() { $bundles = array( 'SensioFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')), 'SensioCmsFooBundle' => array($this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle')), 'FooBundle' => array($this->getBundle('TestBundle\FooBundle', 'FooBundle')), 'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')), ); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundle') ->will($this->returnCallback(function ($bundle) use ($bundles) { if (!isset($bundles[$bundle])) { throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle)); } return $bundles[$bundle]; })) ; $bundles = array( 'SensioFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), 'SensioCmsFooBundle' => $this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle'), 'FoooooBundle' => $this->getBundle('TestBundle\FooBundle', 'FoooooBundle'), 'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'), 'FabpotFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), ); $kernel ->expects($this->any()) ->method('getBundles') ->will($this->returnValue($bundles)) ; return new ControllerNameParser($kernel); } private function getBundle($namespace, $name) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle->expects($this->any())->method('getName')->will($this->returnValue($name)); $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace)); return $bundle; } } �����������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php��������0000664�0000000�0000000�00000017533�13247321071�0032437�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Psr\Container\ContainerInterface as Psr11ContainerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Tests\Controller\ContainerControllerResolverTest; class ControllerResolverTest extends ContainerControllerResolverTest { public function testGetControllerOnContainerAware() { $resolver = $this->createControllerResolver(); $request = Request::create('/'); $request->attributes->set('_controller', 'Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction'); $controller = $resolver->getController($request); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); $this->assertSame('testAction', $controller[1]); } public function testGetControllerOnContainerAwareInvokable() { $resolver = $this->createControllerResolver(); $request = Request::create('/'); $request->attributes->set('_controller', 'Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController'); $controller = $resolver->getController($request); $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer()); } public function testGetControllerWithBundleNotation() { $shortName = 'FooBundle:Default:test'; $parser = $this->createMockParser(); $parser->expects($this->once()) ->method('parse') ->with($shortName) ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')) ; $resolver = $this->createControllerResolver(null, null, $parser); $request = Request::create('/'); $request->attributes->set('_controller', $shortName); $controller = $resolver->getController($request); $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); $this->assertSame('testAction', $controller[1]); } public function testContainerAwareControllerGetsContainerWhenNotSet() { class_exists(AbstractControllerTest::class); $controller = new ContainerAwareController(); $container = new Container(); $container->set(TestAbstractController::class, $controller); $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.':testAction'); $this->assertSame(array($controller, 'testAction'), $resolver->getController($request)); $this->assertSame($container, $controller->getContainer()); } public function testAbstractControllerGetsContainerWhenNotSet() { class_exists(AbstractControllerTest::class); $controller = new TestAbstractController(false); $container = new Container(); $container->set(TestAbstractController::class, $controller); $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.'::fooAction'); $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); $this->assertSame($container, $controller->setContainer($container)); } public function testAbstractControllerServiceWithFcqnIdGetsContainerWhenNotSet() { class_exists(AbstractControllerTest::class); $controller = new DummyController(); $container = new Container(); $container->set(DummyController::class, $controller); $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); $request->attributes->set('_controller', DummyController::class.':fooAction'); $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); $this->assertSame($container, $controller->getContainer()); } public function testAbstractControllerGetsNoContainerWhenSet() { class_exists(AbstractControllerTest::class); $controller = new TestAbstractController(false); $controllerContainer = new Container(); $controller->setContainer($controllerContainer); $container = new Container(); $container->set(TestAbstractController::class, $controller); $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.'::fooAction'); $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); $this->assertSame($controllerContainer, $controller->setContainer($container)); } public function testAbstractControllerServiceWithFcqnIdGetsNoContainerWhenSet() { class_exists(AbstractControllerTest::class); $controller = new DummyController(); $controllerContainer = new Container(); $controller->setContainer($controllerContainer); $container = new Container(); $container->set(DummyController::class, $controller); $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); $request->attributes->set('_controller', DummyController::class.':fooAction'); $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); $this->assertSame($controllerContainer, $controller->getContainer()); } protected function createControllerResolver(LoggerInterface $logger = null, Psr11ContainerInterface $container = null, ControllerNameParser $parser = null) { if (!$parser) { $parser = $this->createMockParser(); } if (!$container) { $container = $this->createMockContainer(); } return new ControllerResolver($container, $parser, $logger); } protected function createMockParser() { return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock(); } protected function createMockContainer() { return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); } } class ContainerAwareController implements ContainerAwareInterface { private $container; public function setContainer(ContainerInterface $container = null) { $this->container = $container; } public function getContainer() { return $this->container; } public function testAction() { } public function __invoke() { } } class DummyController extends AbstractController { public function getContainer() { return $this->container; } public function fooAction() { } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php����������������0000664�0000000�0000000�00000001157�13247321071�0030710�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\File\File; class ControllerTest extends ControllerTraitTest { protected function createController() { return new TestController(); } } class TestController extends Controller { use TestControllerTrait; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php�����������0000664�0000000�0000000�00000050436�13247321071�0031720�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\User\User; use Symfony\Component\Serializer\SerializerInterface; abstract class ControllerTraitTest extends TestCase { abstract protected function createController(); public function testForward() { $request = Request::create('/'); $request->setLocale('fr'); $request->setRequestFormat('xml'); $requestStack = new RequestStack(); $requestStack->push($request); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { return new Response($request->getRequestFormat().'--'.$request->getLocale()); })); $container = new Container(); $container->set('request_stack', $requestStack); $container->set('http_kernel', $kernel); $controller = $this->createController(); $controller->setContainer($container); $response = $controller->forward('a_controller'); $this->assertEquals('xml--fr', $response->getContent()); } public function testGetUser() { $user = new User('user', 'pass'); $token = new UsernamePasswordToken($user, 'pass', 'default', array('ROLE_USER')); $controller = $this->createController(); $controller->setContainer($this->getContainerWithTokenStorage($token)); $this->assertSame($controller->getUser(), $user); } public function testGetUserAnonymousUserConvertedToNull() { $token = new AnonymousToken('default', 'anon.'); $controller = $this->createController(); $controller->setContainer($this->getContainerWithTokenStorage($token)); $this->assertNull($controller->getUser()); } public function testGetUserWithEmptyTokenStorage() { $controller = $this->createController(); $controller->setContainer($this->getContainerWithTokenStorage(null)); $this->assertNull($controller->getUser()); } /** * @expectedException \LogicException * @expectedExceptionMessage The SecurityBundle is not registered in your application. */ public function testGetUserWithEmptyContainer() { $controller = $this->createController(); $controller->setContainer(new Container()); $controller->getUser(); } /** * @param $token * * @return Container */ private function getContainerWithTokenStorage($token = null) { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock(); $tokenStorage ->expects($this->once()) ->method('getToken') ->will($this->returnValue($token)); $container = new Container(); $container->set('security.token_storage', $tokenStorage); return $container; } public function testJson() { $controller = $this->createController(); $controller->setContainer(new Container()); $response = $controller->json(array()); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); } public function testJsonWithSerializer() { $container = new Container(); $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $serializer ->expects($this->once()) ->method('serialize') ->with(array(), 'json', array('json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS)) ->will($this->returnValue('[]')); $container->set('serializer', $serializer); $controller = $this->createController(); $controller->setContainer($container); $response = $controller->json(array()); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); } public function testJsonWithSerializerContextOverride() { $container = new Container(); $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $serializer ->expects($this->once()) ->method('serialize') ->with(array(), 'json', array('json_encode_options' => 0, 'other' => 'context')) ->will($this->returnValue('[]')); $container->set('serializer', $serializer); $controller = $this->createController(); $controller->setContainer($container); $response = $controller->json(array(), 200, array(), array('json_encode_options' => 0, 'other' => 'context')); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); $response->setEncodingOptions(JSON_FORCE_OBJECT); $this->assertEquals('{}', $response->getContent()); } public function testFile() { $container = new Container(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $container->set('http_kernel', $kernel); $controller = $this->createController(); $controller->setContainer($container); /* @var BinaryFileResponse $response */ $response = $controller->file(new File(__FILE__)); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition')); $this->assertContains(basename(__FILE__), $response->headers->get('content-disposition')); } public function testFileAsInline() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $response = $controller->file(new File(__FILE__), null, ResponseHeaderBag::DISPOSITION_INLINE); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition')); $this->assertContains(basename(__FILE__), $response->headers->get('content-disposition')); } public function testFileWithOwnFileName() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $fileName = 'test.php'; $response = $controller->file(new File(__FILE__), $fileName); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition')); $this->assertContains($fileName, $response->headers->get('content-disposition')); } public function testFileWithOwnFileNameAsInline() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $fileName = 'test.php'; $response = $controller->file(new File(__FILE__), $fileName, ResponseHeaderBag::DISPOSITION_INLINE); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition')); $this->assertContains($fileName, $response->headers->get('content-disposition')); } public function testFileFromPath() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $response = $controller->file(__FILE__); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition')); $this->assertContains(basename(__FILE__), $response->headers->get('content-disposition')); } public function testFileFromPathWithCustomizedFileName() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $response = $controller->file(__FILE__, 'test.php'); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); if ($response->headers->get('content-type')) { $this->assertSame('text/x-php', $response->headers->get('content-type')); } $this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition')); $this->assertContains('test.php', $response->headers->get('content-disposition')); } /** * @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException */ public function testFileWhichDoesNotExist() { $controller = $this->createController(); /* @var BinaryFileResponse $response */ $response = $controller->file('some-file.txt', 'test.php'); } public function testIsGranted() { $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true); $container = new Container(); $container->set('security.authorization_checker', $authorizationChecker); $controller = $this->createController(); $controller->setContainer($container); $this->assertTrue($controller->isGranted('foo')); } /** * @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException */ public function testdenyAccessUnlessGranted() { $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); $container = new Container(); $container->set('security.authorization_checker', $authorizationChecker); $controller = $this->createController(); $controller->setContainer($container); $controller->denyAccessUnlessGranted('foo'); } public function testRenderViewTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); $container->set('twig', $twig); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->renderView('foo')); } public function testRenderTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); $container->set('twig', $twig); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->render('foo')->getContent()); } public function testStreamTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $container = new Container(); $container->set('twig', $twig); $controller = $this->createController(); $controller->setContainer($container); $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); } public function testRedirectToRoute() { $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); $container = new Container(); $container->set('router', $router); $controller = $this->createController(); $controller->setContainer($container); $response = $controller->redirectToRoute('foo'); $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertSame('/foo', $response->getTargetUrl()); $this->assertSame(302, $response->getStatusCode()); } /** * @runInSeparateProcess */ public function testAddFlash() { $flashBag = new FlashBag(); $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $session->expects($this->once())->method('getFlashBag')->willReturn($flashBag); $container = new Container(); $container->set('session', $session); $controller = $this->createController(); $controller->setContainer($container); $controller->addFlash('foo', 'bar'); $this->assertSame(array('bar'), $flashBag->get('foo')); } public function testCreateAccessDeniedException() { $controller = $this->createController(); $this->assertInstanceOf('Symfony\Component\Security\Core\Exception\AccessDeniedException', $controller->createAccessDeniedException()); } public function testIsCsrfTokenValid() { $tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); $tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true); $container = new Container(); $container->set('security.csrf.token_manager', $tokenManager); $controller = $this->createController(); $controller->setContainer($container); $this->assertTrue($controller->isCsrfTokenValid('foo', 'bar')); } public function testGenerateUrl() { $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); $container = new Container(); $container->set('router', $router); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals('/foo', $controller->generateUrl('foo')); } public function testRedirect() { $controller = $this->createController(); $response = $controller->redirect('http://dunglas.fr', 301); $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertSame('http://dunglas.fr', $response->getTargetUrl()); $this->assertSame(301, $response->getStatusCode()); } public function testRenderViewTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); $container->set('templating', $templating); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->renderView('foo')); } public function testRenderTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); $container->set('templating', $templating); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->render('foo')->getContent()); } public function testStreamTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $container = new Container(); $container->set('templating', $templating); $controller = $this->createController(); $controller->setContainer($container); $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); } public function testCreateNotFoundException() { $controller = $this->createController(); $this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\NotFoundHttpException', $controller->createNotFoundException()); } public function testCreateForm() { $form = $this->getMockBuilder('Symfony\Component\Form\FormInterface')->getMock(); $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory->expects($this->once())->method('create')->willReturn($form); $container = new Container(); $container->set('form.factory', $formFactory); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals($form, $controller->createForm('foo')); } public function testCreateFormBuilder() { $formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock(); $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder); $container = new Container(); $container->set('form.factory', $formFactory); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals($formBuilder, $controller->createFormBuilder('foo')); } public function testGetDoctrine() { $doctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $container = new Container(); $container->set('doctrine', $doctrine); $controller = $this->createController(); $controller->setContainer($container); $this->assertEquals($doctrine, $controller->getDoctrine()); } } trait TestControllerTrait { use ControllerTrait { generateUrl as public; redirect as public; forward as public; getUser as public; json as public; file as public; isGranted as public; denyAccessUnlessGranted as public; redirectToRoute as public; addFlash as public; isCsrfTokenValid as public; renderView as public; render as public; stream as public; createNotFoundException as public; createAccessDeniedException as public; createForm as public; createFormBuilder as public; getDoctrine as public; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php��������0000664�0000000�0000000�00000027534�13247321071�0032401�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Bundle\FrameworkBundle\Controller\RedirectController; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; /** * @author Marcin Sikon <marcin.sikon@gmail.com> */ class RedirectControllerTest extends TestCase { public function testEmptyRoute() { $request = new Request(); $controller = new RedirectController(); try { $controller->redirectAction($request, '', true); $this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown'); } catch (HttpException $e) { $this->assertSame(410, $e->getStatusCode()); } try { $controller->redirectAction($request, '', false); $this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown'); } catch (HttpException $e) { $this->assertSame(404, $e->getStatusCode()); } } /** * @dataProvider provider */ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expectedAttributes) { $request = new Request(); $route = 'new-route'; $url = '/redirect-url'; $attributes = array( 'route' => $route, 'permanent' => $permanent, '_route' => 'current-route', '_route_params' => array( 'route' => $route, 'permanent' => $permanent, 'additional-parameter' => 'value', 'ignoreAttributes' => $ignoreAttributes, ), ); $request->attributes = new ParameterBag($attributes); $router = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $router ->expects($this->once()) ->method('generate') ->with($this->equalTo($route), $this->equalTo($expectedAttributes)) ->will($this->returnValue($url)); $controller = new RedirectController($router); $returnResponse = $controller->redirectAction($request, $route, $permanent, $ignoreAttributes); $this->assertRedirectUrl($returnResponse, $url); $this->assertEquals($expectedCode, $returnResponse->getStatusCode()); } public function provider() { return array( array(true, false, 301, array('additional-parameter' => 'value')), array(false, false, 302, array('additional-parameter' => 'value')), array(false, true, 302, array()), array(false, array('additional-parameter'), 302, array()), ); } public function testEmptyPath() { $request = new Request(); $controller = new RedirectController(); try { $controller->urlRedirectAction($request, '', true); $this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown'); } catch (HttpException $e) { $this->assertSame(410, $e->getStatusCode()); } try { $controller->urlRedirectAction($request, '', false); $this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown'); } catch (HttpException $e) { $this->assertSame(404, $e->getStatusCode()); } } public function testFullURL() { $request = new Request(); $controller = new RedirectController(); $returnResponse = $controller->urlRedirectAction($request, 'http://foo.bar/'); $this->assertRedirectUrl($returnResponse, 'http://foo.bar/'); $this->assertEquals(302, $returnResponse->getStatusCode()); } public function testUrlRedirectDefaultPorts() { $host = 'www.example.com'; $baseUrl = '/base'; $path = '/redirect-path'; $httpPort = 1080; $httpsPort = 1443; $expectedUrl = "https://$host:$httpsPort$baseUrl$path"; $request = $this->createRequestObject('http', $host, $httpPort, $baseUrl); $controller = $this->createRedirectController(null, $httpsPort); $returnValue = $controller->urlRedirectAction($request, $path, false, 'https'); $this->assertRedirectUrl($returnValue, $expectedUrl); $expectedUrl = "http://$host:$httpPort$baseUrl$path"; $request = $this->createRequestObject('https', $host, $httpPort, $baseUrl); $controller = $this->createRedirectController($httpPort); $returnValue = $controller->urlRedirectAction($request, $path, false, 'http'); $this->assertRedirectUrl($returnValue, $expectedUrl); } /** * @group legacy */ public function testUrlRedirectDefaultPortParameters() { $host = 'www.example.com'; $baseUrl = '/base'; $path = '/redirect-path'; $httpPort = 1080; $httpsPort = 1443; $expectedUrl = "https://$host:$httpsPort$baseUrl$path"; $request = $this->createRequestObject('http', $host, $httpPort, $baseUrl); $controller = $this->createLegacyRedirectController(null, $httpsPort); $returnValue = $controller->urlRedirectAction($request, $path, false, 'https'); $this->assertRedirectUrl($returnValue, $expectedUrl); $expectedUrl = "http://$host:$httpPort$baseUrl$path"; $request = $this->createRequestObject('https', $host, $httpPort, $baseUrl); $controller = $this->createLegacyRedirectController($httpPort); $returnValue = $controller->urlRedirectAction($request, $path, false, 'http'); $this->assertRedirectUrl($returnValue, $expectedUrl); } public function urlRedirectProvider() { return array( // Standard ports array('http', null, null, 'http', 80, ''), array('http', 80, null, 'http', 80, ''), array('https', null, null, 'http', 80, ''), array('https', 80, null, 'http', 80, ''), array('http', null, null, 'https', 443, ''), array('http', null, 443, 'https', 443, ''), array('https', null, null, 'https', 443, ''), array('https', null, 443, 'https', 443, ''), // Non-standard ports array('http', null, null, 'http', 8080, ':8080'), array('http', 4080, null, 'http', 8080, ':4080'), array('http', 80, null, 'http', 8080, ''), array('https', null, null, 'http', 8080, ''), array('https', null, 8443, 'http', 8080, ':8443'), array('https', null, 443, 'http', 8080, ''), array('https', null, null, 'https', 8443, ':8443'), array('https', null, 4443, 'https', 8443, ':4443'), array('https', null, 443, 'https', 8443, ''), array('http', null, null, 'https', 8443, ''), array('http', 8080, 4443, 'https', 8443, ':8080'), array('http', 80, 4443, 'https', 8443, ''), ); } /** * @dataProvider urlRedirectProvider */ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, $requestPort, $expectedPort) { $host = 'www.example.com'; $baseUrl = '/base'; $path = '/redirect-path'; $expectedUrl = "$scheme://$host$expectedPort$baseUrl$path"; $request = $this->createRequestObject($requestScheme, $host, $requestPort, $baseUrl); $controller = $this->createRedirectController(); $returnValue = $controller->urlRedirectAction($request, $path, false, $scheme, $httpPort, $httpsPort); $this->assertRedirectUrl($returnValue, $expectedUrl); } public function pathQueryParamsProvider() { return array( array('http://www.example.com/base/redirect-path', '/redirect-path', ''), array('http://www.example.com/base/redirect-path?foo=bar', '/redirect-path?foo=bar', ''), array('http://www.example.com/base/redirect-path?foo=bar', '/redirect-path', 'foo=bar'), array('http://www.example.com/base/redirect-path?foo=bar&abc=example', '/redirect-path?foo=bar', 'abc=example'), array('http://www.example.com/base/redirect-path?foo=bar&abc=example&baz=def', '/redirect-path?foo=bar', 'abc=example&baz=def'), ); } /** * @dataProvider pathQueryParamsProvider */ public function testPathQueryParams($expectedUrl, $path, $queryString) { $scheme = 'http'; $host = 'www.example.com'; $baseUrl = '/base'; $port = 80; $request = $this->createRequestObject($scheme, $host, $port, $baseUrl, $queryString); $controller = $this->createRedirectController(); $returnValue = $controller->urlRedirectAction($request, $path, false, $scheme, $port, null); $this->assertRedirectUrl($returnValue, $expectedUrl); } private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '') { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->any()) ->method('getScheme') ->will($this->returnValue($scheme)); $request ->expects($this->any()) ->method('getHost') ->will($this->returnValue($host)); $request ->expects($this->any()) ->method('getPort') ->will($this->returnValue($port)); $request ->expects($this->any()) ->method('getBaseUrl') ->will($this->returnValue($baseUrl)); $request ->expects($this->any()) ->method('getQueryString') ->will($this->returnValue($queryString)); return $request; } private function createRedirectController($httpPort = null, $httpsPort = null) { return new RedirectController(null, $httpPort, $httpsPort); } /** * @deprecated */ private function createLegacyRedirectController($httpPort = null, $httpsPort = null) { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); if (null !== $httpPort) { $container ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.http_port')) ->will($this->returnValue(true)); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.http_port')) ->will($this->returnValue($httpPort)); } if (null !== $httpsPort) { $container ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.https_port')) ->will($this->returnValue(true)); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.https_port')) ->will($this->returnValue($httpsPort)); } $controller = new RedirectController(); $controller->setContainer($container); return $controller; } private function assertRedirectUrl(Response $returnResponse, $expectedUrl) { $this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location')); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php��������0000664�0000000�0000000�00000006347�13247321071�0032412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Controller\TemplateController; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class TemplateControllerTest extends TestCase { public function testTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $controller = new TemplateController($twig); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); } public function testTemplating() { $templating = $this->getMockBuilder(EngineInterface::class)->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $controller = new TemplateController(null, $templating); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); } /** * @group legacy */ public function testLegacyTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); $controller = new TemplateController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); } /** * @group legacy */ public function testLegacyTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); $controller = new TemplateController(); $controller->setContainer($container); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); } /** * @expectedException \LogicException * @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available. */ public function testNoTwigNorTemplating() { $controller = new TemplateController(); $controller->templateAction('mytemplate')->getContent(); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/�������������������������0000775�0000000�0000000�00000000000�13247321071�0027006�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/����������������0000775�0000000�0000000�00000000000�13247321071�0030560�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddCacheWarmerPassTest.php��������������������������������������������������������������������������0000664�0000000�0000000�00000004445�13247321071�0035502�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass; /** * @group legacy */ class AddCacheWarmerPassTest extends TestCase { public function testThatCacheWarmersAreProcessedInPriorityOrder() { $container = new ContainerBuilder(); $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument(array()); $container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', array('priority' => 100)); $container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', array('priority' => 200)); $container->register('my_cache_warmer_service3')->addTag('kernel.cache_warmer'); $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); $this->assertEquals( array( new Reference('my_cache_warmer_service2'), new Reference('my_cache_warmer_service1'), new Reference('my_cache_warmer_service3'), ), $cacheWarmerDefinition->getArgument(0) ); } public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition() { $container = new ContainerBuilder(); $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); // we just check that the pass does not break if no cache warmer is registered $this->addToAssertionCount(1); } public function testThatCacheWarmersMightBeNotDefined() { $container = new ContainerBuilder(); $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument(array()); $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); $this->assertSame(array(), $cacheWarmerDefinition->getArgument(0)); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddConsoleCommandPassTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000010637�13247321071�0036222�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass; use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * @group legacy */ class AddConsoleCommandPassTest extends TestCase { /** * @dataProvider visibilityProvider */ public function testProcess($public) { $container = new ContainerBuilder(); $container->addCompilerPass(new AddConsoleCommandPass()); $container->setParameter('my-command.class', 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand'); $definition = new Definition('%my-command.class%'); $definition->setPublic($public); $definition->addTag('console.command'); $container->setDefinition('my-command', $definition); $container->compile(); $alias = 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand'; if ($public) { $this->assertFalse($container->hasAlias($alias)); $id = 'my-command'; } else { $id = $alias; // The alias is replaced by a Definition by the ReplaceAliasByActualDefinitionPass // in case the original service is private $this->assertFalse($container->hasDefinition('my-command')); $this->assertTrue($container->hasDefinition($alias)); } $this->assertTrue($container->hasParameter('console.command.ids')); $this->assertSame(array($alias => $id), $container->getParameter('console.command.ids')); } public function visibilityProvider() { return array( array(true), array(false), ); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract. */ public function testProcessThrowAnExceptionIfTheServiceIsAbstract() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddConsoleCommandPass()); $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand'); $definition->addTag('console.command'); $definition->setAbstract(true); $container->setDefinition('my-command', $definition); $container->compile(); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command". */ public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddConsoleCommandPass()); $definition = new Definition('SplObjectStorage'); $definition->addTag('console.command'); $container->setDefinition('my-command', $definition); $container->compile(); } public function testProcessPrivateServicesWithSameCommand() { $container = new ContainerBuilder(); $className = 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand'; $definition1 = new Definition($className); $definition1->addTag('console.command')->setPublic(false); $definition2 = new Definition($className); $definition2->addTag('console.command')->setPublic(false); $container->setDefinition('my-command1', $definition1); $container->setDefinition('my-command2', $definition2); (new AddConsoleCommandPass())->process($container); $alias1 = 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand'; $alias2 = $alias1.'_my-command2'; $this->assertTrue($container->hasAlias($alias1)); $this->assertTrue($container->hasAlias($alias2)); } } class MyCommand extends Command { } class ExtensionPresentBundle extends Bundle { } �������������������������������������������������������������������������������������������������AddConstraintValidatorsPassTest.php�����������������������������������������������������������������0000664�0000000�0000000�00000006301�13247321071�0037467�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; /** * @group legacy */ class AddConstraintValidatorsPassTest extends TestCase { public function testThatConstraintValidatorServicesAreProcessed() { $container = new ContainerBuilder(); $validatorFactory = $container->register('validator.validator_factory') ->addArgument(array()); $container->register('my_constraint_validator_service1', Validator1::class) ->addTag('validator.constraint_validator', array('alias' => 'my_constraint_validator_alias1')); $container->register('my_constraint_validator_service2', Validator2::class) ->addTag('validator.constraint_validator'); $addConstraintValidatorsPass = new AddConstraintValidatorsPass(); $addConstraintValidatorsPass->process($container); $expected = (new Definition(ServiceLocator::class, array(array( Validator1::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')), 'my_constraint_validator_alias1' => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')), Validator2::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service2')), ))))->addTag('container.service_locator')->setPublic(false); $this->assertEquals($expected, $container->getDefinition((string) $validatorFactory->getArgument(0))); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract. */ public function testAbstractConstraintValidator() { $container = new ContainerBuilder(); $validatorFactory = $container->register('validator.validator_factory') ->addArgument(array()); $container->register('my_abstract_constraint_validator') ->setAbstract(true) ->addTag('validator.constraint_validator'); $addConstraintValidatorsPass = new AddConstraintValidatorsPass(); $addConstraintValidatorsPass->process($container); } public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition() { $addConstraintValidatorsPass = new AddConstraintValidatorsPass(); $addConstraintValidatorsPass->process(new ContainerBuilder()); // we just check that the pass does not fail if no constraint validator factory is registered $this->addToAssertionCount(1); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddExpressionLanguageProvidersPassTest.php����������������������������������������������������������0000664�0000000�0000000�00000010543�13247321071�0041016�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass; class AddExpressionLanguageProvidersPassTest extends TestCase { public function testProcessForRouter() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); $definition->addTag('routing.expression_language_provider'); $container->setDefinition('some_routing_provider', $definition->setPublic(true)); $container->register('router', '\stdClass')->setPublic(true); $container->compile(); $router = $container->getDefinition('router'); $calls = $router->getMethodCalls(); $this->assertCount(1, $calls); $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); $this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]); } public function testProcessForRouterAlias() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); $definition->addTag('routing.expression_language_provider'); $container->setDefinition('some_routing_provider', $definition->setPublic(true)); $container->register('my_router', '\stdClass')->setPublic(true); $container->setAlias('router', 'my_router'); $container->compile(); $router = $container->getDefinition('my_router'); $calls = $router->getMethodCalls(); $this->assertCount(1, $calls); $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); $this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]); } public function testProcessForSecurity() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); $definition->addTag('security.expression_language_provider'); $container->setDefinition('some_security_provider', $definition->setPublic(true)); $container->register('security.access.expression_voter', '\stdClass')->setPublic(true); $container->compile(); $router = $container->getDefinition('security.access.expression_voter'); $calls = $router->getMethodCalls(); $this->assertCount(1, $calls); $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); $this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]); } public function testProcessForSecurityAlias() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); $definition->addTag('security.expression_language_provider'); $container->setDefinition('some_security_provider', $definition->setPublic(true)); $container->register('my_security.access.expression_voter', '\stdClass')->setPublic(true); $container->setAlias('security.access.expression_voter', 'my_security.access.expression_voter'); $container->compile(); $router = $container->getDefinition('my_security.access.expression_voter'); $calls = $router->getMethodCalls(); $this->assertCount(1, $calls); $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); $this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]); } } class TestProvider { } �������������������������������������������������������������������������������������������������������������������������������������������������������������CacheCollectorPassTest.php��������������������������������������������������������������������������0000664�0000000�0000000�00000003641�13247321071�0035557�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; use Symfony\Component\Cache\DataCollector\CacheDataCollector; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class CacheCollectorPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $container ->register('fs', FilesystemAdapter::class) ->addTag('cache.pool'); $container ->register('tagged_fs', TagAwareAdapter::class) ->addArgument(new Reference('fs')) ->addTag('cache.pool'); $collector = $container->register('data_collector.cache', CacheDataCollector::class); (new CacheCollectorPass())->process($container); $this->assertEquals(array( array('addInstance', array('fs', new Reference('fs'))), array('addInstance', array('tagged_fs', new Reference('tagged_fs'))), ), $collector->getMethodCalls()); $this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass()); $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass()); $this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing'); } } �����������������������������������������������������������������������������������������������CachePoolClearerPassTest.php������������������������������������������������������������������������0000664�0000000�0000000�00000005017�13247321071�0036037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass; use Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass; use Symfony\Component\DependencyInjection\Compiler\RepeatedPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; class CachePoolClearerPassTest extends TestCase { public function testPoolRefsAreWeak() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); $container->setParameter('kernel.name', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $globalClearer = new Definition(Psr6CacheClearer::class); $container->setDefinition('cache.global_clearer', $globalClearer); $publicPool = new Definition(); $publicPool->addArgument('namespace'); $publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias')); $container->setDefinition('public.pool', $publicPool); $privatePool = new Definition(); $privatePool->setPublic(false); $privatePool->addArgument('namespace'); $privatePool->addTag('cache.pool', array('clearer' => 'clearer_alias')); $container->setDefinition('private.pool', $privatePool); $clearer = new Definition(); $container->setDefinition('clearer', $clearer); $container->setAlias('clearer_alias', 'clearer'); $pass = new RemoveUnusedDefinitionsPass(); $pass->setRepeatedPass(new RepeatedPass(array($pass))); foreach (array(new CachePoolPass(), $pass, new CachePoolClearerPass()) as $pass) { $pass->process($container); } $this->assertEquals(array(array('public.pool' => new Reference('public.pool'))), $clearer->getArguments()); $this->assertEquals(array(array('public.pool' => new Reference('public.pool'))), $globalClearer->getArguments()); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CachePoolPassTest.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000010702�13247321071�0034536�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; class CachePoolPassTest extends TestCase { private $cachePoolPass; protected function setUp() { $this->cachePoolPass = new CachePoolPass(); } public function testNamespaceArgumentIsReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); $container->setParameter('kernel.name', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); $adapter->setAbstract(true); $adapter->addTag('cache.pool'); $container->setDefinition('app.cache_adapter', $adapter); $container->setAlias('app.cache_adapter_alias', 'app.cache_adapter'); $cachePool = new ChildDefinition('app.cache_adapter_alias'); $cachePool->addArgument(null); $cachePool->addTag('cache.pool'); $container->setDefinition('app.cache_pool', $cachePool); $this->cachePoolPass->process($container); $this->assertSame('D07rhFx97S', $cachePool->getArgument(0)); } public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed() { $container = new ContainerBuilder(); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.name', 'app'); $container->setParameter('kernel.root_dir', 'foo'); $container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0); $cachePool = new ChildDefinition('cache.adapter.array'); $cachePool->addTag('cache.pool'); $container->setDefinition('app.cache_pool', $cachePool); $this->cachePoolPass->process($container); $this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments()); } public function testArgsAreReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); $container->setParameter('kernel.name', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); $cachePool->addTag('cache.pool', array( 'provider' => 'foobar', 'default_lifetime' => 3, )); $cachePool->addArgument(null); $cachePool->addArgument(null); $cachePool->addArgument(null); $container->setDefinition('app.cache_pool', $cachePool); $this->cachePoolPass->process($container); $this->assertInstanceOf(Reference::class, $cachePool->getArgument(0)); $this->assertSame('foobar', (string) $cachePool->getArgument(0)); $this->assertSame('itantF+pIq', $cachePool->getArgument(1)); $this->assertSame(3, $cachePool->getArgument(2)); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are */ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); $container->setParameter('kernel.name', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); $adapter->setAbstract(true); $adapter->addTag('cache.pool'); $container->setDefinition('app.cache_adapter', $adapter); $cachePool = new ChildDefinition('app.cache_adapter'); $cachePool->addTag('cache.pool', array('foobar' => 123)); $container->setDefinition('app.cache_pool', $cachePool); $this->cachePoolPass->process($container); } } ��������������������������������������������������������������CachePoolPrunerPassTest.php�������������������������������������������������������������������������0000664�0000000�0000000�00000005506�13247321071�0035740�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class CachePoolPrunerPassTest extends TestCase { public function testCompilerPassReplacesCommandArgument() { $container = new ContainerBuilder(); $container->register(CachePoolPruneCommand::class)->addArgument(array()); $container->register('pool.foo', FilesystemAdapter::class)->addTag('cache.pool'); $container->register('pool.bar', PhpFilesAdapter::class)->addTag('cache.pool'); $pass = new CachePoolPrunerPass(); $pass->process($container); $expected = array( 'pool.foo' => new Reference('pool.foo'), 'pool.bar' => new Reference('pool.bar'), ); $argument = $container->getDefinition(CachePoolPruneCommand::class)->getArgument(0); $this->assertInstanceOf(IteratorArgument::class, $argument); $this->assertEquals($expected, $argument->getValues()); } public function testCompilePassIsIgnoredIfCommandDoesNotExist() { $container = new ContainerBuilder(); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $pass = new CachePoolPrunerPass(); $pass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @expectedExceptionMessage Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found. */ public function testCompilerPassThrowsOnInvalidDefinitionClass() { $container = new ContainerBuilder(); $container->register(CachePoolPruneCommand::class)->addArgument(array()); $container->register('pool.not-found', NotFound::class)->addTag('cache.pool'); $pass = new CachePoolPrunerPass(); $pass->process($container); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ConfigCachePassTest.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000004013�13247321071�0035030�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass; /** * @group legacy */ class ConfigCachePassTest extends TestCase { public function testThatCheckersAreProcessedInPriorityOrder() { $container = new ContainerBuilder(); $definition = $container->register('config_cache_factory')->addArgument(null); $container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100)); $container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200)); $container->register('checker_3')->addTag('config_cache.resource_checker'); $pass = new ConfigCachePass(); $pass->process($container); $expected = new IteratorArgument(array( new Reference('checker_1'), new Reference('checker_2'), new Reference('checker_3'), )); $this->assertEquals($expected, $definition->getArgument(0)); } public function testThatCheckersCanBeMissing() { $container = new ContainerBuilder(); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $pass = new ConfigCachePass(); $pass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ControllerArgumentValueResolverPassTest.php���������������������������������������������������������0000664�0000000�0000000�00000004464�13247321071�0041256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Controller\ArgumentResolver; /** * @group legacy */ class ControllerArgumentValueResolverPassTest extends TestCase { public function testServicesAreOrderedAccordingToPriority() { $services = array( 'n3' => array(array()), 'n1' => array(array('priority' => 200)), 'n2' => array(array('priority' => 100)), ); $expected = array( new Reference('n1'), new Reference('n2'), new Reference('n3'), ); $definition = new Definition(ArgumentResolver::class, array(null, array())); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); foreach ($services as $id => list($tag)) { $container->register($id)->addTag('controller.argument_value_resolver', $tag); } (new ControllerArgumentValueResolverPass())->process($container); $this->assertEquals($expected, $definition->getArgument(1)->getValues()); } public function testReturningEmptyArrayWhenNoService() { $definition = new Definition(ArgumentResolver::class, array(null, array())); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); (new ControllerArgumentValueResolverPass())->process($container); $this->assertEquals(array(), $definition->getArgument(1)->getValues()); } public function testNoArgumentResolver() { $container = new ContainerBuilder(); (new ControllerArgumentValueResolverPass())->process($container); $this->assertFalse($container->hasDefinition('argument_resolver')); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������DataCollectorTranslatorPassTest.php�����������������������������������������������������������������0000664�0000000�0000000�00000010462�13247321071�0037476�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Translation\TranslatorInterface; class DataCollectorTranslatorPassTest extends TestCase { private $container; private $dataCollectorTranslatorPass; protected function setUp() { $this->container = new ContainerBuilder(); $this->dataCollectorTranslatorPass = new DataCollectorTranslatorPass(); $this->container->setParameter('translator_implementing_bag', 'Symfony\Component\Translation\Translator'); $this->container->setParameter('translator_not_implementing_bag', 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'); $this->container->register('translator.data_collector', 'Symfony\Component\Translation\DataCollectorTranslator') ->setPublic(false) ->setDecoratedService('translator') ->setArguments(array(new Reference('translator.data_collector.inner'))) ; $this->container->register('data_collector.translation', 'Symfony\Component\Translation\DataCollector\TranslationDataCollector') ->setArguments(array(new Reference('translator.data_collector'))) ; } /** * @dataProvider getImplementingTranslatorBagInterfaceTranslatorClassNames */ public function testProcessKeepsDataCollectorTranslatorIfItImplementsTranslatorBagInterface($class) { $this->container->register('translator', $class); $this->dataCollectorTranslatorPass->process($this->container); $this->assertTrue($this->container->hasDefinition('translator.data_collector')); } /** * @dataProvider getImplementingTranslatorBagInterfaceTranslatorClassNames */ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBagInterface($class) { $this->container->register('translator', $class); $this->dataCollectorTranslatorPass->process($this->container); $this->assertTrue($this->container->hasDefinition('data_collector.translation')); } public function getImplementingTranslatorBagInterfaceTranslatorClassNames() { return array( array('Symfony\Component\Translation\Translator'), array('%translator_implementing_bag%'), ); } /** * @dataProvider getNotImplementingTranslatorBagInterfaceTranslatorClassNames */ public function testProcessRemovesDataCollectorTranslatorIfItDoesNotImplementTranslatorBagInterface($class) { $this->container->register('translator', $class); $this->dataCollectorTranslatorPass->process($this->container); $this->assertFalse($this->container->hasDefinition('translator.data_collector')); } /** * @dataProvider getNotImplementingTranslatorBagInterfaceTranslatorClassNames */ public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTranslatorBagInterface($class) { $this->container->register('translator', $class); $this->dataCollectorTranslatorPass->process($this->container); $this->assertFalse($this->container->hasDefinition('data_collector.translation')); } public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() { return array( array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'), array('%translator_not_implementing_bag%'), ); } } class TranslatorWithTranslatorBag implements TranslatorInterface { public function trans($id, array $parameters = array(), $domain = null, $locale = null) { } public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) { } public function setLocale($locale) { } public function getLocale() { } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php0000664�0000000�0000000�00000017165�13247321071�0033675�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Form\AbstractType; /** * @group legacy * * @author Bernhard Schussek <bschussek@gmail.com> */ class FormPassTest extends TestCase { public function testDoNothingIfFormExtensionNotLoaded() { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $container->compile(); $this->assertFalse($container->hasDefinition('form.extension')); } public function testAddTaggedTypes() { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); $extDefinition->setPublic(true); $extDefinition->setArguments(array( new Reference('service_container'), array(), array(), array(), )); $container->setDefinition('form.extension', $extDefinition); $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true); $container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true); $container->compile(); $extDefinition = $container->getDefinition('form.extension'); $this->assertEquals(array( __CLASS__.'_Type1' => 'my.type1', __CLASS__.'_Type2' => 'my.type2', ), $extDefinition->getArgument(1)); } /** * @dataProvider addTaggedTypeExtensionsDataProvider */ public function testAddTaggedTypeExtensions(array $extensions, array $expectedRegisteredExtensions) { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', array( new Reference('service_container'), array(), array(), array(), )); $extDefinition->setPublic(true); $container->setDefinition('form.extension', $extDefinition); foreach ($extensions as $serviceId => $tag) { $container->register($serviceId, 'stdClass')->addTag('form.type_extension', $tag); } $container->compile(); $extDefinition = $container->getDefinition('form.extension'); $this->assertSame($expectedRegisteredExtensions, $extDefinition->getArgument(2)); } /** * @return array */ public function addTaggedTypeExtensionsDataProvider() { return array( array( array( 'my.type_extension1' => array('extended_type' => 'type1'), 'my.type_extension2' => array('extended_type' => 'type1'), 'my.type_extension3' => array('extended_type' => 'type2'), ), array( 'type1' => array('my.type_extension1', 'my.type_extension2'), 'type2' => array('my.type_extension3'), ), ), array( array( 'my.type_extension1' => array('extended_type' => 'type1', 'priority' => 1), 'my.type_extension2' => array('extended_type' => 'type1', 'priority' => 2), 'my.type_extension3' => array('extended_type' => 'type1', 'priority' => -1), 'my.type_extension4' => array('extended_type' => 'type2', 'priority' => 2), 'my.type_extension5' => array('extended_type' => 'type2', 'priority' => 1), 'my.type_extension6' => array('extended_type' => 'type2', 'priority' => 1), ), array( 'type1' => array('my.type_extension2', 'my.type_extension1', 'my.type_extension3'), 'type2' => array('my.type_extension4', 'my.type_extension5', 'my.type_extension6'), ), ), ); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage extended-type attribute, none was configured for the "my.type_extension" service */ public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute() { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', array( new Reference('service_container'), array(), array(), array(), )); $extDefinition->setPublic(true); $container->setDefinition('form.extension', $extDefinition); $container->register('my.type_extension', 'stdClass') ->addTag('form.type_extension'); $container->compile(); } public function testAddTaggedGuessers() { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); $extDefinition->setPublic(true); $extDefinition->setArguments(array( new Reference('service_container'), array(), array(), array(), )); $definition1 = new Definition('stdClass'); $definition1->addTag('form.type_guesser'); $definition2 = new Definition('stdClass'); $definition2->addTag('form.type_guesser'); $container->setDefinition('form.extension', $extDefinition); $container->setDefinition('my.guesser1', $definition1); $container->setDefinition('my.guesser2', $definition2); $container->compile(); $extDefinition = $container->getDefinition('form.extension'); $this->assertSame(array( 'my.guesser1', 'my.guesser2', ), $extDefinition->getArgument(3)); } /** * @dataProvider privateTaggedServicesProvider */ public function testPrivateTaggedServices($id, $tagName) { $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); $extDefinition->setArguments(array( new Reference('service_container'), array(), array(), array(), )); $container->setDefinition('form.extension', $extDefinition); $container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, array('extended_type' => 'Foo')); $container->compile(); $this->assertTrue($container->getDefinition($id)->isPublic()); } public function privateTaggedServicesProvider() { return array( array('my.type', 'form.type'), array('my.type_extension', 'form.type_extension'), array('my.guesser', 'form.type_guesser'), ); } } class FormPassTest_Type1 extends AbstractType { } class FormPassTest_Type2 extends AbstractType { } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������LoggingTranslatorPassTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000006206�13247321071�0036345�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class LoggingTranslatorPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $container->setParameter('translator.logging', true); $container->setParameter('translator.class', 'Symfony\Component\Translation\Translator'); $container->register('monolog.logger'); $container->setAlias('logger', 'monolog.logger'); $container->register('translator.default', '%translator.class%'); $container->register('translator.logging', '%translator.class%'); $container->setAlias('translator', 'translator.default'); $translationWarmerDefinition = $container->register('translation.warmer') ->addArgument(new Reference('translator')) ->addTag('container.service_subscriber', array('id' => 'translator')) ->addTag('container.service_subscriber', array('id' => 'foo')); $pass = new LoggingTranslatorPass(); $pass->process($container); $this->assertEquals( array('container.service_subscriber' => array( array('id' => 'foo'), array('key' => 'translator', 'id' => 'translator.logging.inner'), )), $translationWarmerDefinition->getTags() ); } public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition() { $container = new ContainerBuilder(); $container->register('identity_translator'); $container->setAlias('translator', 'identity_translator'); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $pass = new LoggingTranslatorPass(); $pass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition() { $container = new ContainerBuilder(); $container->register('monolog.logger'); $container->setAlias('logger', 'monolog.logger'); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $pass = new LoggingTranslatorPass(); $pass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ProfilerPassTest.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000004130�13247321071�0034461�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; class ProfilerPassTest extends TestCase { /** * Tests that collectors that specify a template but no "id" will throw * an exception (both are needed if the template is specified). * * Thus, a fully-valid tag looks something like this: * * <tag name="data_collector" template="YourBundle:Collector:templatename" id="your_collector_name" /> * * @expectedException \InvalidArgumentException */ public function testTemplateNoIdThrowsException() { $builder = new ContainerBuilder(); $builder->register('profiler', 'ProfilerClass'); $builder->register('my_collector_service') ->addTag('data_collector', array('template' => 'foo')); $profilerPass = new ProfilerPass(); $profilerPass->process($builder); } public function testValidCollector() { $container = new ContainerBuilder(); $profilerDefinition = $container->register('profiler', 'ProfilerClass'); $container->register('my_collector_service') ->addTag('data_collector', array('template' => 'foo', 'id' => 'my_collector')); $profilerPass = new ProfilerPass(); $profilerPass->process($container); $this->assertSame(array('my_collector_service' => array('my_collector', 'foo')), $container->getParameter('data_collector.templates')); // grab the method calls off of the "profiler" definition $methodCalls = $profilerDefinition->getMethodCalls(); $this->assertCount(1, $methodCalls); $this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������PropertyInfoPassTest.php����������������������������������������������������������������������������0000664�0000000�0000000�00000005104�13247321071�0035341�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * @group legacy */ class PropertyInfoPassTest extends TestCase { /** * @dataProvider provideTags */ public function testServicesAreOrderedAccordingToPriority($index, $tag) { $container = new ContainerBuilder(); $definition = $container->register('property_info')->setArguments(array(null, null, null, null)); $container->register('n2')->addTag($tag, array('priority' => 100)); $container->register('n1')->addTag($tag, array('priority' => 200)); $container->register('n3')->addTag($tag); $propertyInfoPass = new PropertyInfoPass(); $propertyInfoPass->process($container); $expected = new IteratorArgument(array( new Reference('n1'), new Reference('n2'), new Reference('n3'), )); $this->assertEquals($expected, $definition->getArgument($index)); } public function provideTags() { return array( array(0, 'property_info.list_extractor'), array(1, 'property_info.type_extractor'), array(2, 'property_info.description_extractor'), array(3, 'property_info.access_extractor'), ); } public function testReturningEmptyArrayWhenNoService() { $container = new ContainerBuilder(); $propertyInfoExtractorDefinition = $container->register('property_info') ->setArguments(array(array(), array(), array(), array())); $propertyInfoPass = new PropertyInfoPass(); $propertyInfoPass->process($container); $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(0)); $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(1)); $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(2)); $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(3)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SerializerPassTest.php������������������������������������������������������������������������������0000664�0000000�0000000�00000005227�13247321071�0035020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass; /** * Tests for the SerializerPass class. * * @group legacy * * @author Javier Lopez <f12loalf@gmail.com> */ class SerializerPassTest extends TestCase { /** * @expectedException \RuntimeException * @expectedExceptionMessage You must tag at least one service as "serializer.normalizer" to use the "serializer" service */ public function testThrowExceptionWhenNoNormalizers() { $container = new ContainerBuilder(); $container->register('serializer'); $serializerPass = new SerializerPass(); $serializerPass->process($container); } /** * @expectedException \RuntimeException * @expectedExceptionMessage You must tag at least one service as "serializer.encoder" to use the "serializer" service */ public function testThrowExceptionWhenNoEncoders() { $container = new ContainerBuilder(); $container->register('serializer') ->addArgument(array()) ->addArgument(array()); $container->register('normalizer')->addTag('serializer.normalizer'); $serializerPass = new SerializerPass(); $serializerPass->process($container); } public function testServicesAreOrderedAccordingToPriority() { $container = new ContainerBuilder(); $definition = $container->register('serializer')->setArguments(array(null, null)); $container->register('n2')->addTag('serializer.normalizer', array('priority' => 100))->addTag('serializer.encoder', array('priority' => 100)); $container->register('n1')->addTag('serializer.normalizer', array('priority' => 200))->addTag('serializer.encoder', array('priority' => 200)); $container->register('n3')->addTag('serializer.normalizer')->addTag('serializer.encoder'); $serializerPass = new SerializerPass(); $serializerPass->process($container); $expected = array( new Reference('n1'), new Reference('n2'), new Reference('n3'), ); $this->assertEquals($expected, $definition->getArgument(0)); $this->assertEquals($expected, $definition->getArgument(1)); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������TranslatorPassTest.php������������������������������������������������������������������������������0000664�0000000�0000000�00000003737�13247321071�0035044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** * @group legacy */ class TranslatorPassTest extends TestCase { public function testValidCollector() { $loader = (new Definition()) ->addTag('translation.loader', array('alias' => 'xliff', 'legacy-alias' => 'xlf')); $translator = (new Definition()) ->setArguments(array(null, null, null, null)); $container = new ContainerBuilder(); $container->setDefinition('translator.default', $translator); $container->setDefinition('translation.loader', $loader); $pass = new TranslatorPass(); $pass->process($container); $expected = (new Definition()) ->addTag('translation.loader', array('alias' => 'xliff', 'legacy-alias' => 'xlf')) ->addMethodCall('addLoader', array('xliff', new Reference('translation.loader'))) ->addMethodCall('addLoader', array('xlf', new Reference('translation.loader'))) ; $this->assertEquals($expected, $loader); $this->assertSame(array('translation.loader' => array('xliff', 'xlf')), $translator->getArgument(3)); $expected = array('translation.loader' => new ServiceClosureArgument(new Reference('translation.loader'))); $this->assertEquals($expected, $container->getDefinition((string) $translator->getArgument(0))->getArgument(0)); } } ���������������������������������UnusedTagsPassTest.php������������������������������������������������������������������������������0000664�0000000�0000000�00000002131�13247321071�0034760�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass; use Symfony\Component\DependencyInjection\ContainerBuilder; class UnusedTagsPassTest extends TestCase { public function testProcess() { $pass = new UnusedTagsPass(); $container = new ContainerBuilder(); $container->register('foo') ->addTag('kenrel.event_subscriber'); $container->register('bar') ->addTag('kenrel.event_subscriber'); $pass->process($container); $this->assertSame(array(sprintf('%s: Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?', UnusedTagsPass::class)), $container->getCompiler()->getLog()); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������WorkflowGuardListenerPassTest.php�������������������������������������������������������������������0000664�0000000�0000000�00000012162�13247321071�0037206�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Role\RoleHierarchy; use Symfony\Component\Validator\Validator\ValidatorInterface; class WorkflowGuardListenerPassTest extends TestCase { private $container; private $compilerPass; protected function setUp() { $this->container = new ContainerBuilder(); $this->compilerPass = new WorkflowGuardListenerPass(); } public function testNoExeptionIfParameterIsNotSet() { $this->compilerPass->process($this->container); $this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners')); } public function testNoExeptionIfAllDependenciesArePresent() { $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); $this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class); $this->container->register('security.role_hierarchy', RoleHierarchy::class); $this->container->register('validator', ValidatorInterface::class); $this->compilerPass->process($this->container); $this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners')); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException * @expectedExceptionMessage The "security.token_storage" service is needed to be able to use the workflow guard listener. */ public function testExceptionIfTheTokenStorageServiceIsNotPresent() { $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); $this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class); $this->container->register('security.role_hierarchy', RoleHierarchy::class); $this->compilerPass->process($this->container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException * @expectedExceptionMessage The "security.authorization_checker" service is needed to be able to use the workflow guard listener. */ public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent() { $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class); $this->container->register('security.role_hierarchy', RoleHierarchy::class); $this->compilerPass->process($this->container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException * @expectedExceptionMessage The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener. */ public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent() { $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); $this->container->register('security.role_hierarchy', RoleHierarchy::class); $this->compilerPass->process($this->container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException * @expectedExceptionMessage The "security.role_hierarchy" service is needed to be able to use the workflow guard listener. */ public function testExceptionIfTheRoleHierarchyServiceIsNotPresent() { $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); $this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class); $this->compilerPass->process($this->container); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php����0000664�0000000�0000000�00000032254�13247321071�0033174�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration; use Symfony\Bundle\FullStack; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Lock\Store\SemaphoreStore; class ConfigurationTest extends TestCase { public function testDefaultConfig() { $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(true), array(array('secret' => 's3cr3t'))); $this->assertEquals( array_merge(array('secret' => 's3cr3t', 'trusted_hosts' => array()), self::getBundleDefaultConfig()), $config ); } public function testDoNoDuplicateDefaultFormResources() { $input = array('templating' => array( 'form' => array('resources' => array('FrameworkBundle:Form')), 'engines' => array('php'), )); $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(true), array($input)); $this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']); } /** * @group legacy * @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead. */ public function testTrustedProxiesSetToNullIsDeprecated() { $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array(array('trusted_proxies' => null))); } /** * @group legacy * @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead. */ public function testTrustedProxiesSetToEmptyArrayIsDeprecated() { $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array(array('trusted_proxies' => array()))); } /** * @group legacy * @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead. */ public function testTrustedProxiesSetToNonEmptyArrayIsInvalid() { $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array(array('trusted_proxies' => array('127.0.0.1')))); } /** * @group legacy * @dataProvider getTestValidTrustedProxiesData */ public function testValidTrustedProxies($trustedProxies, $processedProxies) { $processor = new Processor(); $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, array(array( 'secret' => 's3cr3t', 'trusted_proxies' => $trustedProxies, ))); $this->assertEquals($processedProxies, $config['trusted_proxies']); } public function getTestValidTrustedProxiesData() { return array( array(array('127.0.0.1'), array('127.0.0.1')), array(array('::1'), array('::1')), array(array('127.0.0.1', '::1'), array('127.0.0.1', '::1')), array(null, array()), array(false, array()), array(array(), array()), array(array('10.0.0.0/8'), array('10.0.0.0/8')), array(array('::ffff:0:0/96'), array('::ffff:0:0/96')), array(array('0.0.0.0/0'), array('0.0.0.0/0')), ); } /** * @group legacy * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testInvalidTypeTrustedProxies() { $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array( array( 'secret' => 's3cr3t', 'trusted_proxies' => 'Not an IP address', ), )); } /** * @group legacy * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testInvalidValueTrustedProxies() { $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array( array( 'secret' => 's3cr3t', 'trusted_proxies' => array('Not an IP address'), ), )); } public function testAssetsCanBeEnabled() { $processor = new Processor(); $configuration = new Configuration(true); $config = $processor->processConfiguration($configuration, array(array('assets' => null))); $defaultConfig = array( 'enabled' => true, 'version_strategy' => null, 'version' => null, 'version_format' => '%%s?%%s', 'base_path' => '', 'base_urls' => array(), 'packages' => array(), 'json_manifest_path' => null, ); $this->assertEquals($defaultConfig, $config['assets']); } /** * @dataProvider provideInvalidAssetConfigurationTests */ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage) { if (method_exists($this, 'expectException')) { $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage($expectedMessage); } else { $this->setExpectedException(InvalidConfigurationException::class, $expectedMessage); } $processor = new Processor(); $configuration = new Configuration(true); $processor->processConfiguration($configuration, array( array( 'assets' => $assetConfig, ), )); } public function provideInvalidAssetConfigurationTests() { // helper to turn config into embedded package config $createPackageConfig = function (array $packageConfig) { return array( 'base_urls' => '//example.com', 'version' => 1, 'packages' => array( 'foo' => $packageConfig, ), ); }; $config = array( 'version' => 1, 'version_strategy' => 'foo', ); yield array($config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".'); yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.'); $config = array( 'json_manifest_path' => '/foo.json', 'version_strategy' => 'foo', ); yield array($config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".'); yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.'); $config = array( 'json_manifest_path' => '/foo.json', 'version' => '1', ); yield array($config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".'); yield array($createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'); } protected static function getBundleDefaultConfig() { return array( 'http_method_override' => true, 'trusted_proxies' => array(), 'ide' => null, 'default_locale' => 'en', 'csrf_protection' => array( 'enabled' => false, ), 'form' => array( 'enabled' => !class_exists(FullStack::class), 'csrf_protection' => array( 'enabled' => null, // defaults to csrf_protection.enabled 'field_name' => '_token', ), ), 'esi' => array('enabled' => false), 'ssi' => array('enabled' => false), 'fragments' => array( 'enabled' => false, 'path' => '/_fragment', ), 'profiler' => array( 'enabled' => false, 'only_exceptions' => false, 'only_master_requests' => false, 'dsn' => 'file:%kernel.cache_dir%/profiler', 'collect' => true, 'matcher' => array( 'enabled' => false, 'ips' => array(), ), ), 'translator' => array( 'enabled' => !class_exists(FullStack::class), 'fallbacks' => array('en'), 'logging' => true, 'formatter' => 'translator.formatter.default', 'paths' => array(), 'default_path' => '%kernel.project_dir%/translations', ), 'validation' => array( 'enabled' => !class_exists(FullStack::class), 'enable_annotations' => !class_exists(FullStack::class), 'static_method' => array('loadValidatorMetadata'), 'translation_domain' => 'validators', 'strict_email' => false, 'mapping' => array( 'paths' => array(), ), ), 'annotations' => array( 'cache' => 'php_array', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => true, 'enabled' => true, ), 'serializer' => array( 'enabled' => !class_exists(FullStack::class), 'enable_annotations' => !class_exists(FullStack::class), 'mapping' => array('paths' => array()), ), 'property_access' => array( 'magic_call' => false, 'throw_exception_on_invalid_index' => false, ), 'property_info' => array( 'enabled' => false, ), 'router' => array( 'enabled' => false, 'http_port' => 80, 'https_port' => 443, 'strict_requirements' => true, ), 'session' => array( 'enabled' => false, 'storage_id' => 'session.storage.native', 'handler_id' => 'session.handler.native_file', 'cookie_httponly' => true, 'gc_probability' => 1, 'save_path' => '%kernel.cache_dir%/sessions', 'metadata_update_threshold' => '0', 'use_strict_mode' => true, ), 'request' => array( 'enabled' => false, 'formats' => array(), ), 'templating' => array( 'enabled' => false, 'hinclude_default_template' => null, 'form' => array( 'resources' => array('FrameworkBundle:Form'), ), 'engines' => array(), 'loaders' => array(), ), 'assets' => array( 'enabled' => !class_exists(FullStack::class), 'version_strategy' => null, 'version' => null, 'version_format' => '%%s?%%s', 'base_path' => '', 'base_urls' => array(), 'packages' => array(), 'json_manifest_path' => null, ), 'cache' => array( 'pools' => array(), 'app' => 'cache.adapter.filesystem', 'system' => 'cache.adapter.system', 'directory' => '%kernel.cache_dir%/pools', 'default_redis_provider' => 'redis://localhost', 'default_memcached_provider' => 'memcached://localhost', ), 'workflows' => array( 'enabled' => false, 'workflows' => array(), ), 'php_errors' => array( 'log' => true, 'throw' => true, ), 'web_link' => array( 'enabled' => !class_exists(FullStack::class), ), 'lock' => array( 'enabled' => !class_exists(FullStack::class), 'resources' => array( 'default' => array( class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock', ), ), ), ); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/����������������0000775�0000000�0000000�00000000000�13247321071�0030617�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CustomPathBundle/�����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0033761�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures������������������������������������������������������������������������������������Resources/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035733�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle�������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0037200�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources���������������������������������������������������������validation.xml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0042042�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config��������������������������������������������������validation.yml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0042043�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config��������������������������������������������������src/������������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034550�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle�������������������������������������������������������������������CustomPathBundle.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000000702�13247321071�0040501�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src���������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests; use Symfony\Component\HttpKernel\Bundle\Bundle; class CustomPathBundle extends Bundle { public function getPath() { return __DIR__.'/..'; } } ��������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/�����0000775�0000000�0000000�00000000000�13247321071�0032670�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Resources/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034563�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle�������������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0036030�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources���������������������������������������������������������������serialization.xml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0041415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������serialization.yml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0041416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������serializer_mapping/���������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0041714�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������files/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0043016�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping�������������������������������������foo.xml���������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/files�������������������������������foo.yml���������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044312�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/files�������������������������������serialization.yaml����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0045443�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping�������������������������������������serialization.yml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0045302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping�������������������������������������validation.xml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0040672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������validation.yml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0040673�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������validation_mapping/���������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0041675�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config��������������������������������������������������������files/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0042777�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping�������������������������������������foo.xml���������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044272�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/files�������������������������������foo.yml���������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/files�������������������������������validation.yaml�������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044701�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping�������������������������������������validation.yml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0044540�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping�������������������������������������TestBundle.php��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000564�13247321071�0035400�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests; use Symfony\Component\HttpKernel\Bundle\Bundle; class TestBundle extends Bundle { } ��������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/������������0000775�0000000�0000000�00000000000�13247321071�0031406�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php��0000664�0000000�0000000�00000002120�13247321071�0033414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'assets' => array( 'version' => 'SomeVersionScheme', 'base_urls' => 'http://cdn.example.com', 'version_format' => '%%s?version=%%s', 'packages' => array( 'images_path' => array( 'base_path' => '/foo', ), 'images' => array( 'version' => '1.0.0', 'base_urls' => array('http://images1.example.com', 'http://images2.example.com'), ), 'foo' => array( 'version' => '1.0.0', 'version_format' => '%%s-%%s', ), 'bar' => array( 'base_urls' => array('https://bar2.example.com'), ), 'bar_version_strategy' => array( 'base_urls' => array('https://bar2.example.com'), 'version_strategy' => 'assets.custom_version_strategy', ), 'json_manifest_strategy' => array( 'json_manifest_path' => '/path/to/manifest.json', ), ), ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_disabled.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000167�13247321071�0035175�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'assets' => array( 'enabled' => false, ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_version_strategy_as_service.php��������������������������������������������������������������0000664�0000000�0000000�00000000314�13247321071�0041232�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'assets' => array( 'version_strategy' => 'assets.custom_version_strategy', 'base_urls' => 'http://cdn.example.com', ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php���0000664�0000000�0000000�00000001612�13247321071�0033162�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'cache' => array( 'pools' => array( 'cache.foo' => array( 'adapter' => 'cache.adapter.apcu', 'default_lifetime' => 30, ), 'cache.bar' => array( 'adapter' => 'cache.adapter.doctrine', 'default_lifetime' => 5, 'provider' => 'app.doctrine_cache_provider', ), 'cache.baz' => array( 'adapter' => 'cache.adapter.filesystem', 'default_lifetime' => 7, ), 'cache.foobar' => array( 'adapter' => 'cache.adapter.psr6', 'default_lifetime' => 10, 'provider' => 'app.cache_pool', ), 'cache.def' => array( 'default_lifetime' => 11, ), ), ), )); ����������������������������������������������������������������������������������������������������������������������cache_env_var.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000323�13247321071�0034621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->setParameter('env(REDIS_URL)', 'redis://paas.com'); $container->loadFromExtension('framework', array( 'cache' => array( 'default_redis_provider' => '%env(REDIS_URL)%', ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php����0000664�0000000�0000000�00000000255�13247321071�0033056�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'csrf_protection' => true, 'form' => true, 'session' => array( 'handler_id' => null, ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������csrf_needs_session.php������������������������������������������������������������������������������0000664�0000000�0000000�00000000177�13247321071�0035723�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'csrf_protection' => array( 'enabled' => true, ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������default_config.php����������������������������������������������������������������������������������0000664�0000000�0000000�00000000074�13247321071�0035012�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array()); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������esi_and_ssi_without_fragments.php�������������������������������������������������������������������0000664�0000000�0000000�00000000346�13247321071�0040154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'fragments' => array( 'enabled' => false, ), 'esi' => array( 'enabled' => true, ), 'ssi' => array( 'enabled' => true, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������esi_disabled.php������������������������������������������������������������������������������������0000664�0000000�0000000�00000000164�13247321071�0034450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'esi' => array( 'enabled' => false, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_no_csrf.php������������������������������������������������������������������������������������0000664�0000000�0000000�00000000250�13247321071�0034511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'form' => array( 'csrf_protection' => array( 'enabled' => false, ), ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php����0000664�0000000�0000000�00000004560�13247321071�0033066�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'secret' => 's3cr3t', 'default_locale' => 'fr', 'csrf_protection' => true, 'form' => array( 'csrf_protection' => array( 'field_name' => '_csrf', ), ), 'http_method_override' => false, 'esi' => array( 'enabled' => true, ), 'ssi' => array( 'enabled' => true, ), 'profiler' => array( 'only_exceptions' => true, 'enabled' => false, ), 'router' => array( 'resource' => '%kernel.project_dir%/config/routing.xml', 'type' => 'xml', ), 'session' => array( 'storage_id' => 'session.storage.native', 'handler_id' => 'session.handler.native_file', 'name' => '_SYMFONY', 'cookie_lifetime' => 86400, 'cookie_path' => '/', 'cookie_domain' => 'example.com', 'cookie_secure' => true, 'cookie_httponly' => false, 'use_cookies' => true, 'gc_maxlifetime' => 90000, 'gc_divisor' => 108, 'gc_probability' => 1, 'save_path' => '/path/to/sessions', ), 'templating' => array( 'cache' => '/path/to/cache', 'engines' => array('php', 'twig'), 'loader' => array('loader.foo', 'loader.bar'), 'form' => array( 'resources' => array('theme1', 'theme2'), ), 'hinclude_default_template' => 'global_hinclude_template', ), 'assets' => array( 'version' => 'v1', ), 'translator' => array( 'enabled' => true, 'fallback' => 'fr', 'paths' => array('%kernel.project_dir%/Fixtures/translations'), ), 'validation' => array( 'enabled' => true, ), 'annotations' => array( 'cache' => 'file', 'debug' => true, 'file_cache_dir' => '%kernel.cache_dir%/annotations', ), 'serializer' => array( 'enabled' => true, 'enable_annotations' => true, 'name_converter' => 'serializer.name_converter.camel_case_to_snake_case', 'circular_reference_handler' => 'my.circular.reference.handler', ), 'property_info' => true, 'ide' => 'file%%link%%format', 'request' => array( 'formats' => array( 'csv' => array( 'text/csv', 'text/plain', ), 'pdf' => 'application/pdf', ), ), )); ������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php0000664�0000000�0000000�00000000170�13247321071�0033737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'profiler' => array( 'enabled' => true, ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_accessor.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000266�13247321071�0035612�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'property_access' => array( 'magic_call' => true, 'throw_exception_on_invalid_index' => true, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_info.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000175�13247321071�0034742�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'property_info' => array( 'enabled' => true, ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php�0000664�0000000�0000000�00000000172�13247321071�0033607�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'request' => array( 'formats' => array(), ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_disabled.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000000173�13247321071�0036041�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'serializer' => array( 'enabled' => false, ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_enabled.php������������������������������������������������������������������������������0000664�0000000�0000000�00000000172�13247321071�0035663�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'serializer' => array( 'enabled' => true, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_legacy_cache.php�������������������������������������������������������������������������0000664�0000000�0000000�00000000224�13247321071�0036656�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'serializer' => array( 'enabled' => true, 'cache' => 'foo', ), )); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_mapping.php������������������������������������������������������������������������������0000664�0000000�0000000�00000001123�13247321071�0035721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'annotations' => array('enabled' => true), 'serializer' => array( 'enable_annotations' => true, 'mapping' => array( 'paths' => array( '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml', ), ), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php�0000664�0000000�0000000�00000000172�13247321071�0033602�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'session' => array( 'handler_id' => null, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ssi_disabled.php������������������������������������������������������������������������������������0000664�0000000�0000000�00000000164�13247321071�0034466�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'ssi' => array( 'enabled' => false, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_disabled.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000000130�13247321071�0036025�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'templating' => false, )); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_no_assets.php����������������������������������������������������������������������������0000664�0000000�0000000�00000000212�13247321071�0036255�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'templating' => array( 'engines' => array('php', 'twig'), ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_assets_disabled.php������������������������������������������������������������������0000664�0000000�0000000�00000000231�13247321071�0040260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'assets' => false, 'templating' => array( 'engines' => array('php'), ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_disabled.php��������������������������������������������������������������0000664�0000000�0000000�00000000235�13247321071�0041153�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'translator' => false, 'templating' => array( 'engines' => array('php'), ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_enabled.php���������������������������������������������������������������0000664�0000000�0000000�00000000234�13247321071�0040775�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'translator' => true, 'templating' => array( 'engines' => array('php'), ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������translator_fallbacks.php����������������������������������������������������������������������������0000664�0000000�0000000�00000000211�13247321071�0036225�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'translator' => array( 'fallbacks' => array('en', 'fr'), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_annotations.php��������������������������������������������������������������������������0000664�0000000�0000000�00000000272�13247321071�0036610�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'secret' => 's3cr3t', 'validation' => array( 'enabled' => true, 'enable_annotations' => true, ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_mapping.php������������������������������������������������������������������������������0000664�0000000�0000000�00000000770�13247321071�0035711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'validation' => array( 'mapping' => array( 'paths' => array( '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml', ), ), ), )); ��������validation_multiple_static_methods.php��������������������������������������������������������������0000664�0000000�0000000�00000000314�13247321071�0041175�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'secret' => 's3cr3t', 'validation' => array( 'enabled' => true, 'static_method' => array('loadFoo', 'loadBar'), ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_no_static_method.php���������������������������������������������������������������������0000664�0000000�0000000�00000000266�13247321071�0037601�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'secret' => 's3cr3t', 'validation' => array( 'enabled' => true, 'static_method' => false, ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_strict_email.php�������������������������������������������������������������������������0000664�0000000�0000000�00000000177�13247321071�0036736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'validation' => array( 'strict_email' => true, ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_translation_domain.php�������������������������������������������������������������������0000664�0000000�0000000�00000000213�13247321071�0040133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'validation' => array( 'translation_domain' => 'messages', ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php0000664�0000000�0000000�00000000151�13247321071�0033706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'web_link' => array('enabled' => true), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_arguments_and_service.php�������������������������������������������������������������0000664�0000000�0000000�00000001517�13247321071�0041400�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'my_workflow' => array( 'marking_store' => array( 'arguments' => array('a', 'b'), 'service' => 'workflow_service', ), 'supports' => array( FrameworkExtensionTest::class, ), 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => array( 'first', ), 'to' => array( 'last', ), ), ), ), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_multiple_transitions_with_same_name.php�����������������������������������������������0000664�0000000�0000000�00000003267�13247321071�0044365�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'article' => array( 'type' => 'workflow', 'marking_store' => array( 'type' => 'multiple_state', ), 'supports' => array( FrameworkExtensionTest::class, ), 'initial_place' => 'draft', 'places' => array( 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', ), 'transitions' => array( 'request_review' => array( 'from' => 'draft', 'to' => array('wait_for_journalist', 'wait_for_spellchecker'), ), 'journalist_approval' => array( 'from' => 'wait_for_journalist', 'to' => 'approved_by_journalist', ), 'spellchecker_approval' => array( 'from' => 'wait_for_spellchecker', 'to' => 'approved_by_spellchecker', ), 'publish' => array( 'from' => array('approved_by_journalist', 'approved_by_spellchecker'), 'to' => 'published', ), 'publish_editor_in_chief' => array( 'name' => 'publish', 'from' => 'draft', 'to' => 'published', ), ), ), ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_support_and_support_strategy.php������������������������������������������������������0000664�0000000�0000000�00000001506�13247321071�0043103�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'my_workflow' => array( 'marking_store' => array( 'type' => 'multiple_state', ), 'supports' => array( FrameworkExtensionTest::class, ), 'support_strategy' => 'foobar', 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => array( 'first', ), 'to' => array( 'last', ), ), ), ), ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_type_and_service.php������������������������������������������������������������������0000664�0000000�0000000�00000001513�13247321071�0040350�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'my_workflow' => array( 'marking_store' => array( 'type' => 'multiple_state', 'service' => 'workflow_service', ), 'supports' => array( FrameworkExtensionTest::class, ), 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => array( 'first', ), 'to' => array( 'last', ), ), ), ), ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_without_support_and_support_strategy.php���������������������������������������������������0000664�0000000�0000000�00000001273�13247321071�0043634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'my_workflow' => array( 'marking_store' => array( 'type' => 'multiple_state', ), 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => array( 'first', ), 'to' => array( 'last', ), ), ), ), ), )); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows.php���������������������������������������������������������������������������������������0000664�0000000�0000000�00000007047�13247321071�0034105�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'article' => array( 'type' => 'workflow', 'marking_store' => array( 'type' => 'multiple_state', ), 'supports' => array( FrameworkExtensionTest::class, ), 'initial_place' => 'draft', 'places' => array( 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', ), 'transitions' => array( 'request_review' => array( 'from' => 'draft', 'to' => array('wait_for_journalist', 'wait_for_spellchecker'), ), 'journalist_approval' => array( 'from' => 'wait_for_journalist', 'to' => 'approved_by_journalist', ), 'spellchecker_approval' => array( 'from' => 'wait_for_spellchecker', 'to' => 'approved_by_spellchecker', ), 'publish' => array( 'from' => array('approved_by_journalist', 'approved_by_spellchecker'), 'to' => 'published', ), ), ), 'pull_request' => array( 'type' => 'state_machine', 'marking_store' => array( 'type' => 'single_state', ), 'supports' => array( FrameworkExtensionTest::class, ), 'initial_place' => 'start', 'places' => array( 'start', 'coding', 'travis', 'review', 'merged', 'closed', ), 'transitions' => array( 'submit' => array( 'from' => 'start', 'to' => 'travis', ), 'update' => array( 'from' => array('coding', 'travis', 'review'), 'to' => 'travis', ), 'wait_for_review' => array( 'from' => 'travis', 'to' => 'review', ), 'request_change' => array( 'from' => 'review', 'to' => 'coding', ), 'accept' => array( 'from' => 'review', 'to' => 'merged', ), 'reject' => array( 'from' => 'review', 'to' => 'closed', ), 'reopen' => array( 'from' => 'closed', 'to' => 'review', ), ), ), 'service_marking_store_workflow' => array( 'type' => 'workflow', 'marking_store' => array( 'service' => 'workflow_service', ), 'supports' => array( FrameworkExtensionTest::class, ), 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => 'first', 'to' => 'last', ), ), ), ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows_enabled.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000126�13247321071�0035546�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php $container->loadFromExtension('framework', array( 'workflows' => null, )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows_without_type.php��������������������������������������������������������������������������0000664�0000000�0000000�00000001247�13247321071�0036725�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php��������������������������������������������������������������������������������<?php use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; $container->loadFromExtension('framework', array( 'workflows' => array( 'missing_type' => array( 'marking_store' => array( 'service' => 'workflow_service', ), 'supports' => array( \stdClass::class, ), 'places' => array( 'first', 'last', ), 'transitions' => array( 'go' => array( 'from' => 'first', 'to' => 'last', ), ), ), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/translations/���0000775�0000000�0000000�00000000000�13247321071�0033340�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������test_paths.en.yml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000030�13247321071�0036554�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/translations�����������������������������������������������������������������������custom: paths: test ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/������������0000775�0000000�0000000�00000000000�13247321071�0031417�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml��0000664�0000000�0000000�00000003151�13247321071�0033443�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:assets version="SomeVersionScheme" version-format="%%s?version=%%s"> <framework:base-url>http://cdn.example.com</framework:base-url> <framework:package name="images_path" base-path="/foo" version-format="%%s-%%s" /> <framework:package name="images" version="1.0.0"> <framework:base-url>http://images1.example.com</framework:base-url> <framework:base-url>http://images2.example.com</framework:base-url> </framework:package> <framework:package name="foo" version="1.0.0" version-format="%%s-%%s" /> <framework:package name="bar"> <framework:base-url>https://bar2.example.com</framework:base-url> </framework:package> <framework:package name="bar_version_strategy" version-strategy="assets.custom_version_strategy"> <framework:base-url>https://bar_version_strategy.example.com</framework:base-url> </framework:package> <framework:package name="json_manifest_strategy" json-manifest-path="/path/to/manifest.json" /> </framework:assets> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_disabled.xml���������������������������������������������������������������������������������0000664�0000000�0000000�00000001037�13247321071�0035214�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:assets enabled="false" /> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_version_strategy_as_service.xml��������������������������������������������������������������0000664�0000000�0000000�00000001247�13247321071�0041262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:assets version-strategy="assets.custom_version_strategy"> <framework:base-url>http://cdn.example.com</framework:base-url> </framework:assets> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml���0000664�0000000�0000000�00000002064�13247321071�0033206�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:cache> <framework:pool name="cache.foo" adapter="cache.adapter.apcu" default-lifetime="30" /> <framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" /> <framework:pool name="cache.baz" adapter="cache.adapter.filesystem" default-lifetime="7" /> <framework:pool name="cache.foobar" adapter="cache.adapter.psr6" default-lifetime="10" provider="app.cache_pool" /> <framework:pool name="cache.def" default-lifetime="11" /> </framework:cache> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cache_env_var.xml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001366�13247321071�0034653�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <parameters> <parameter key="env(REDIS_URL)">redis://paas.com</parameter> </parameters> <framework:config> <framework:cache> <framework:default-redis-provider>%env(REDIS_URL)%</framework:default-redis-provider> </framework:cache> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml����0000664�0000000�0000000�00000001121�13247321071�0033071�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:csrf-protection /> <framework:form /> <framework:session /> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������csrf_disabled.xml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001050�13247321071�0034642�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:csrf-protection enabled="false" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������csrf_needs_session.xml������������������������������������������������������������������������������0000664�0000000�0000000�00000001030�13247321071�0035732�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:csrf-protection /> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������default_config.xml����������������������������������������������������������������������������������0000664�0000000�0000000�00000000734�13247321071�0035037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config /> </container> ������������������������������������esi_and_ssi_without_fragments.xml�������������������������������������������������������������������0000664�0000000�0000000�00000001143�13247321071�0040172�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:fragments enabled="false" /> <framework:esi enabled="true" /> <framework:ssi enabled="true" /> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������esi_disabled.xml������������������������������������������������������������������������������������0000664�0000000�0000000�00000001013�13247321071�0034464�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:esi enabled="false" /> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_csrf_sets_field_name.xml�����������������������������������������������������������������������0000664�0000000�0000000�00000001146�13247321071�0037245�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:csrf-protection field-name="_custom" /> <framework:session /> <framework:form /> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_csrf_under_form_sets_field_name.xml������������������������������������������������������������0000664�0000000�0000000�00000001153�13247321071�0041463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:csrf-protection field-name="_custom_form" /> <framework:form /> <framework:session /> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_no_csrf.xml������������������������������������������������������������������������������������0000664�0000000�0000000�00000001156�13247321071�0034541�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:form enabled="true"> <framework:csrf-protection enabled="false" /> </framework:form> </framework:config> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml����0000664�0000000�0000000�00000005557�13247321071�0033117�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" http-method-override="false"> <framework:csrf-protection /> <framework:form> <framework:csrf-protection field-name="_csrf"/> </framework:form> <framework:esi enabled="true" /> <framework:ssi enabled="true" /> <framework:profiler only-exceptions="true" enabled="false" /> <framework:router resource="%kernel.project_dir%/config/routing.xml" type="xml" /> <framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="false" use-cookies="true" save-path="/path/to/sessions" /> <framework:request> <framework:format name="csv"> <framework:mime-type>text/csv</framework:mime-type> <framework:mime-type>text/plain</framework:mime-type> </framework:format> <framework:format name="pdf"> <framework:mime-type>application/pdf</framework:mime-type> </framework:format> </framework:request> <framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template"> <framework:loader>loader.foo</framework:loader> <framework:loader>loader.bar</framework:loader> <framework:engine>php</framework:engine> <framework:engine>twig</framework:engine> <framework:form> <framework:resource>theme1</framework:resource> <framework:resource>theme2</framework:resource> </framework:form> </framework:templating> <framework:assets version="v1" /> <framework:translator enabled="true" fallback="fr" logging="true"> <framework:path>%kernel.project_dir%/Fixtures/translations</framework:path> </framework:translator> <framework:validation enabled="true" /> <framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" /> <framework:serializer enabled="true" enable-annotations="true" name-converter="serializer.name_converter.camel_case_to_snake_case" circular-reference-handler="my.circular.reference.handler" /> <framework:property-info /> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock.xml����0000664�0000000�0000000�00000000773�13247321071�0033100�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:lock/> </framework:config> </container> �����lock_named.xml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000001757�13247321071�0034170�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <parameters> <parameter key="env(REDIS_URL)">redis://paas.com</parameter> </parameters> <framework:config> <framework:lock> <framework:resource name="foo">semaphore</framework:resource> <framework:resource name="bar">flock</framework:resource> <framework:resource name="baz">semaphore</framework:resource> <framework:resource name="baz">flock</framework:resource> <framework:resource name="qux">%env(REDIS_URL)%</framework:resource> </framework:lock> </framework:config> </container> �����������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml0000664�0000000�0000000�00000001040�13247321071�0033756�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:profiler enabled="true" /> </framework:config> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_accessor.xml�������������������������������������������������������������������������������0000664�0000000�0000000�00000001122�13247321071�0035624�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:property-access magic-call="true" throw-exception-on-invalid-index="true" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_info.xml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001072�13247321071�0034761�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" encoding="utf-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:property-info enabled="true" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml�0000664�0000000�0000000�00000001017�13247321071�0033630�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:request /> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_disabled.xml�����������������������������������������������������������������������������0000664�0000000�0000000�00000001043�13247321071�0036060�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" encoding="utf-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:serializer enabled="false" /> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_enabled.xml������������������������������������������������������������������������������0000664�0000000�0000000�00000001042�13247321071�0035702�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" encoding="utf-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:serializer enabled="true" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_legacy_cache.xml�������������������������������������������������������������������������0000664�0000000�0000000�00000001055�13247321071�0036703�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" encoding="utf-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:serializer enabled="true" cache="foo"/> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_mapping.xml������������������������������������������������������������������������������0000664�0000000�0000000�00000001566�13247321071�0035756�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony"> <framework:config> <framework:annotations enabled="true" /> <framework:serializer enable-annotations="true"> <framework:mapping> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files</framework:path> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml</framework:path> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml</framework:path> </framework:mapping> </framework:serializer> </framework:config> </container> ������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/session.xml�0000664�0000000�0000000�00000001041�13247321071�0033620�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:session handler-id="null"/> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ssi_disabled.xml������������������������������������������������������������������������������������0000664�0000000�0000000�00000001013�13247321071�0034502�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:ssi enabled="false" /> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_disabled.xml�����������������������������������������������������������������������������0000664�0000000�0000000�00000001022�13247321071�0036050�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:templating enabled="false" /> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_no_assets.xml����������������������������������������������������������������������������0000664�0000000�0000000�00000001213�13247321071�0036301�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:templating> <framework:engine>php</framework:engine> <framework:engine>twig</framework:engine> </framework:templating> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_disabled.xml��������������������������������������������������������������0000664�0000000�0000000�00000001206�13247321071�0041174�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:translator enabled="false" /> <framework:templating> <framework:engine>php</framework:engine> </framework:templating> </framework:config> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_enabled.xml���������������������������������������������������������������0000664�0000000�0000000�00000001205�13247321071�0041016�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:translator enabled="true" /> <framework:templating> <framework:engine>php</framework:engine> </framework:templating> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������translator_fallbacks.xml����������������������������������������������������������������������������0000664�0000000�0000000�00000001300�13247321071�0036247�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config secret="s3cr3t"> <framework:translator enabled="true"> <framework:fallback>en</framework:fallback> <framework:fallback>fr</framework:fallback> </framework:translator> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_annotations.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000001114�13247321071�0036626�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config secret="s3cr3t"> <framework:validation enabled="true" enable-annotations="true" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_mapping.xml������������������������������������������������������������������������������0000664�0000000�0000000�00000001445�13247321071�0035733�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony"> <framework:config> <framework:validation> <framework:mapping> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files</framework:path> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml</framework:path> <framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml</framework:path> </framework:mapping> </framework:validation> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_multiple_static_methods.xml��������������������������������������������������������������0000664�0000000�0000000�00000001336�13247321071�0041224�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config secret="s3cr3t"> <framework:validation enabled="true"> <framework:static-method>loadFoo</framework:static-method> <framework:static-method>loadBar</framework:static-method> </framework:validation> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_no_static_method.xml���������������������������������������������������������������������0000664�0000000�0000000�00000001110�13247321071�0037610�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config secret="s3cr3t"> <framework:validation enabled="true" static-method="false" /> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_strict_email.xml�������������������������������������������������������������������������0000664�0000000�0000000�00000001026�13247321071�0036752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:validation strict-email="true" /> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_translation_domain.xml�������������������������������������������������������������������0000664�0000000�0000000�00000001040�13247321071�0040154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:validation translation-domain="messages" /> </framework:config> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/web_link.xml0000664�0000000�0000000�00000001065�13247321071�0033735�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:web-link enabled="true" /> </framework:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_arguments_and_service.xml�������������������������������������������������������������0000664�0000000�0000000�00000002301�13247321071�0041412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="my_workflow"> <framework:marking-store service="workflow_service"> <framework:argument>a</framework:argument> <framework:argument>a</framework:argument> </framework:marking-store> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="foobar"> <framework:from>a</framework:from> <framework:to>a</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_multiple_transitions_with_same_name.xml�����������������������������������������������0000664�0000000�0000000�00000005031�13247321071�0044376�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="article" type="workflow" initial-place="draft"> <framework:marking-store type="multiple_state"> <framework:argument>a</framework:argument> <framework:argument>a</framework:argument> </framework:marking-store> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>draft</framework:place> <framework:place>wait_for_journalist</framework:place> <framework:place>approved_by_journalist</framework:place> <framework:place>wait_for_spellchecker</framework:place> <framework:place>approved_by_spellchecker</framework:place> <framework:place>published</framework:place> <framework:transition name="request_review"> <framework:from>draft</framework:from> <framework:to>wait_for_journalist</framework:to> <framework:to>wait_for_spellchecker</framework:to> </framework:transition> <framework:transition name="journalist_approval"> <framework:from>wait_for_journalist</framework:from> <framework:to>approved_by_journalist</framework:to> </framework:transition> <framework:transition name="spellchecker_approval"> <framework:from>wait_for_spellchecker</framework:from> <framework:to>approved_by_spellchecker</framework:to> </framework:transition> <framework:transition name="publish"> <framework:from>approved_by_journalist</framework:from> <framework:from>approved_by_spellchecker</framework:from> <framework:to>published</framework:to> </framework:transition> <framework:transition name="publish"> <framework:from>draft</framework:from> <framework:to>published</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_support_and_support_strategy.xml������������������������������������������������������0000664�0000000�0000000�00000002072�13247321071�0043124�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="my_workflow" support-strategy="foobar"> <framework:marking-store type="multiple_state"/> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="foobar"> <framework:from>a</framework:from> <framework:to>a</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_type_and_service.xml������������������������������������������������������������������0000664�0000000�0000000�00000002074�13247321071�0040375�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="my_workflow"> <framework:marking-store type="multiple_state" service="workflow_service" /> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="foobar"> <framework:from>a</framework:from> <framework:to>a</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_without_support_and_support_strategy.xml���������������������������������������������������0000664�0000000�0000000�00000001635�13247321071�0043660�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="my_workflow"> <framework:marking-store type="multiple_state"/> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="foobar"> <framework:from>a</framework:from> <framework:to>a</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> ���������������������������������������������������������������������������������������������������workflows.xml���������������������������������������������������������������������������������������0000664�0000000�0000000�00000011755�13247321071�0034130�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="article" type="workflow" initial-place="draft"> <framework:marking-store type="multiple_state"> <framework:argument>a</framework:argument> <framework:argument>a</framework:argument> </framework:marking-store> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>draft</framework:place> <framework:place>wait_for_journalist</framework:place> <framework:place>approved_by_journalist</framework:place> <framework:place>wait_for_spellchecker</framework:place> <framework:place>approved_by_spellchecker</framework:place> <framework:place>published</framework:place> <framework:transition name="request_review"> <framework:from>draft</framework:from> <framework:to>wait_for_journalist</framework:to> <framework:to>wait_for_spellchecker</framework:to> </framework:transition> <framework:transition name="journalist_approval"> <framework:from>wait_for_journalist</framework:from> <framework:to>approved_by_journalist</framework:to> </framework:transition> <framework:transition name="spellchecker_approval"> <framework:from>wait_for_spellcheker</framework:from> <framework:to>approved_by_spellchker</framework:to> </framework:transition> <framework:transition name="publish"> <framework:from>approved_by_journalist</framework:from> <framework:from>approved_by_spellchker</framework:from> <framework:to>published</framework:to> </framework:transition> </framework:workflow> <framework:workflow name="pull_request" type="state_machine" initial-place="start"> <framework:marking-store type="single_state"/> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>start</framework:place> <framework:place>coding</framework:place> <framework:place>travis</framework:place> <framework:place>review</framework:place> <framework:place>merged</framework:place> <framework:place>closed</framework:place> <framework:transition name="submit"> <framework:from>start</framework:from> <framework:to>travis</framework:to> </framework:transition> <framework:transition name="update"> <framework:from>coding</framework:from> <framework:from>travis</framework:from> <framework:from>review</framework:from> <framework:to>travis</framework:to> </framework:transition> <framework:transition name="wait_for_review"> <framework:from>travis</framework:from> <framework:to>review</framework:to> </framework:transition> <framework:transition name="request_change"> <framework:from>review</framework:from> <framework:to>coding</framework:to> </framework:transition> <framework:transition name="accept"> <framework:from>review</framework:from> <framework:to>merged</framework:to> </framework:transition> <framework:transition name="reject"> <framework:from>review</framework:from> <framework:to>closed</framework:to> </framework:transition> <framework:transition name="reopen"> <framework:from>closed</framework:from> <framework:to>review</framework:to> </framework:transition> </framework:workflow> <framework:workflow name="service_marking_store_workflow" type="workflow"> <framework:marking-store service="workflow_service"/> <framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="go"> <framework:from>first</framework:from> <framework:to>last</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> �������������������workflows_enabled.xml�������������������������������������������������������������������������������0000664�0000000�0000000�00000001017�13247321071�0035570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow enabled="true" /> </framework:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows_without_type.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000001746�13247321071�0036753�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml��������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:workflow name="missing_type"> <framework:marking-store service="workflow_service"/> <framework:support>stdClass</framework:support> <framework:place>first</framework:place> <framework:place>last</framework:place> <framework:transition name="go"> <framework:from>first</framework:from> <framework:to>last</framework:to> </framework:transition> </framework:workflow> </framework:config> </container> ��������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/������������0000775�0000000�0000000�00000000000�13247321071�0031420�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml��0000664�0000000�0000000�00000001425�13247321071�0033447�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: assets: version: SomeVersionScheme version_format: '%%s?version=%%s' base_urls: http://cdn.example.com packages: images_path: base_path: '/foo' images: version: 1.0.0 base_urls: ["http://images1.example.com", "http://images2.example.com"] foo: version: 1.0.0 version_format: '%%s-%%s' bar: base_urls: ["https://bar2.example.com"] bar_version_strategy: base_urls: ["https://bar_version_strategy.example.com"] version_strategy: assets.custom_version_strategy json_manifest_strategy: json_manifest_path: '/path/to/manifest.json' �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_disabled.yml���������������������������������������������������������������������������������0000664�0000000�0000000�00000000056�13247321071�0035216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: assets: enabled: false ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������assets_version_strategy_as_service.yml��������������������������������������������������������������0000664�0000000�0000000�00000000172�13247321071�0041260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: assets: version_strategy: assets.custom_version_strategy base_urls: http://cdn.example.com ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml���0000664�0000000�0000000�00000001153�13247321071�0033206�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: cache: pools: cache.foo: adapter: cache.adapter.apcu default_lifetime: 30 cache.bar: adapter: cache.adapter.doctrine default_lifetime: 5 provider: app.doctrine_cache_provider cache.baz: adapter: cache.adapter.filesystem default_lifetime: 7 cache.foobar: adapter: cache.adapter.psr6 default_lifetime: 10 provider: app.cache_pool cache.def: default_lifetime: 11 ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cache_env_var.yml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000173�13247321071�0034650�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������parameters: env(REDIS_URL): redis://paas.com framework: cache: default_redis_provider: "%env(REDIS_URL)%" �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml����0000664�0000000�0000000�00000000120�13247321071�0033071�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: secret: s3cr3t csrf_protection: ~ form: ~ session: ~ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������csrf_needs_session.yml������������������������������������������������������������������������������0000664�0000000�0000000�00000000042�13247321071�0035736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: csrf_protection: ~ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������default_config.yml����������������������������������������������������������������������������������0000664�0000000�0000000�00000000015�13247321071�0035031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: ~ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������esi_and_ssi_without_fragments.yml�������������������������������������������������������������������0000664�0000000�0000000�00000000157�13247321071�0040200�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: fragments: enabled: false esi: enabled: true ssi: enabled: true �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������esi_disabled.yml������������������������������������������������������������������������������������0000664�0000000�0000000�00000000053�13247321071�0034471�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: esi: enabled: false �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_no_csrf.yml������������������������������������������������������������������������������������0000664�0000000�0000000�00000000111�13247321071�0034531�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: form: csrf_protection: enabled: false �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml����0000664�0000000�0000000�00000003601�13247321071�0033105�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: secret: s3cr3t default_locale: fr csrf_protection: true form: csrf_protection: field_name: _csrf http_method_override: false esi: enabled: true ssi: enabled: true profiler: only_exceptions: true enabled: false router: resource: '%kernel.project_dir%/config/routing.xml' type: xml session: storage_id: session.storage.native handler_id: session.handler.native_file name: _SYMFONY cookie_lifetime: 86400 cookie_path: / cookie_domain: example.com cookie_secure: true cookie_httponly: false use_cookies: true gc_probability: 1 gc_divisor: 108 gc_maxlifetime: 90000 save_path: /path/to/sessions templating: engines: [php, twig] loader: [loader.foo, loader.bar] cache: /path/to/cache form: resources: [theme1, theme2] hinclude_default_template: global_hinclude_template assets: version: v1 translator: enabled: true fallback: fr default_path: '%kernel.project_dir%/translations' paths: ['%kernel.project_dir%/Fixtures/translations'] validation: enabled: true annotations: cache: file debug: true file_cache_dir: '%kernel.cache_dir%/annotations' serializer: enabled: true enable_annotations: true name_converter: serializer.name_converter.camel_case_to_snake_case circular_reference_handler: my.circular.reference.handler property_info: ~ ide: file%%link%%format request: formats: csv: ['text/csv', 'text/plain'] pdf: 'application/pdf' �������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock.yml����0000664�0000000�0000000�00000000027�13247321071�0033072�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: lock: ~ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������lock_named.yml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000000261�13247321071�0034157�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������parameters: env(REDIS_DSN): redis://paas.com framework: lock: foo: semaphore bar: flock baz: [semaphore, flock] qux: "%env(REDIS_DSN)%" �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml0000664�0000000�0000000�00000000057�13247321071�0033767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: profiler: enabled: true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_accessor.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000000150�13247321071�0035626�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: property_access: magic_call: true throw_exception_on_invalid_index: true ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������property_info.yml�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000064�13247321071�0034763�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: property_info: enabled: true ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml�0000664�0000000�0000000�00000000053�13247321071�0033631�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: request: formats: ~ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_disabled.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000000062�13247321071�0036062�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: serializer: enabled: false ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_enabled.yml������������������������������������������������������������������������������0000664�0000000�0000000�00000000061�13247321071�0035704�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: serializer: enabled: true �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_legacy_cache.yml�������������������������������������������������������������������������0000664�0000000�0000000�00000000104�13247321071�0036677�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: serializer: enabled: true cache: foo ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������serializer_mapping.yml������������������������������������������������������������������������������0000664�0000000�0000000�00000000725�13247321071�0035754�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: annotations: enabled: true serializer: enable_annotations: true mapping: paths: - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files" - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml" - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml" �������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/session.yml�0000664�0000000�0000000�00000000061�13247321071�0033623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: session: handler_id: null �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ssi_disabled.yml������������������������������������������������������������������������������������0000664�0000000�0000000�00000000053�13247321071�0034507�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: ssi: enabled: false �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_disabled.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000000041�13247321071�0036052�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: templating: false �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_no_assets.yml����������������������������������������������������������������������������0000664�0000000�0000000�00000000070�13247321071�0036303�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: templating: engines: [php, twig] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_assets_disabled.yml������������������������������������������������������������������0000664�0000000�0000000�00000000104�13247321071�0040303�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: assets: false templating: engines: [php] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_disabled.yml��������������������������������������������������������������0000664�0000000�0000000�00000000110�13247321071�0041167�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: translator: false templating: engines: [php] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������templating_php_translator_enabled.yml���������������������������������������������������������������0000664�0000000�0000000�00000000107�13247321071�0041020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: translator: true templating: engines: [php] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������translator_fallbacks.yml����������������������������������������������������������������������������0000664�0000000�0000000�00000000067�13247321071�0036262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: translator: fallbacks: [en, fr] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_annotations.yml��������������������������������������������������������������������������0000664�0000000�0000000�00000000151�13247321071�0036630�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: secret: s3cr3t validation: enabled: true enable_annotations: true �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_mapping.yml������������������������������������������������������������������������������0000664�0000000�0000000�00000000543�13247321071�0035733�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: validation: mapping: paths: - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files" - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml" - "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml" �������������������������������������������������������������������������������������������������������������������������������������������������������������validation_multiple_static_methods.yml��������������������������������������������������������������0000664�0000000�0000000�00000000164�13247321071�0041224�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: secret: s3cr3t validation: enabled: true static_method: [loadFoo, loadBar] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_no_static_method.yml���������������������������������������������������������������������0000664�0000000�0000000�00000000147�13247321071�0037623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: secret: s3cr3t validation: enabled: true static_method: false �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_strict_email.yml�������������������������������������������������������������������������0000664�0000000�0000000�00000000066�13247321071�0036757�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: validation: strict_email: true ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������validation_translation_domain.yml�������������������������������������������������������������������0000664�0000000�0000000�00000000100�13247321071�0040152�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: validation: translation_domain: messages ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml0000664�0000000�0000000�00000000057�13247321071�0033737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: web_link: enabled: true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_arguments_and_service.yml�������������������������������������������������������������0000664�0000000�0000000�00000001030�13247321071�0041412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: my_workflow: marking_store: arguments: - a - b service: workflow_service supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest places: - first - last transitions: go: from: - first to: - last ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_multiple_transitions_with_same_name.yml�����������������������������������������������0000664�0000000�0000000�00000002326�13247321071�0044404�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: article: type: workflow marking_store: type: multiple_state supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest initial_place: draft places: - draft - wait_for_journalist - approved_by_journalist - wait_for_spellchecker - approved_by_spellchecker - published transitions: request_review: from: [draft] to: [wait_for_journalist, wait_for_spellchecker] journalist_approval: from: [wait_for_journalist] to: [approved_by_journalist] spellchecker_approval: from: [wait_for_spellchecker] to: [approved_by_spellchecker] publish: from: [approved_by_journalist, approved_by_spellchecker] to: [published] publish_editor_in_chief: name: publish from: [draft] to: [published] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflow_with_support_and_support_strategy.yml������������������������������������������������������0000664�0000000�0000000�00000000755�13247321071�0043134�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: my_workflow: marking_store: type: multiple_state supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest support_strategy: foobar places: - first - last transitions: go: from: - first to: - last �������������������workflow_with_type_and_service.yml������������������������������������������������������������������0000664�0000000�0000000�00000000762�13247321071�0040401�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: my_workflow: marking_store: type: multiple_state service: workflow_service supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest places: - first - last transitions: go: from: - first to: - last ��������������workflow_without_support_and_support_strategy.yml���������������������������������������������������0000664�0000000�0000000�00000000520�13247321071�0043652�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: my_workflow: marking_store: type: multiple_state places: - first - last transitions: go: from: - first to: - last ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows.yml���������������������������������������������������������������������������������������0000664�0000000�0000000�00000005177�13247321071�0034133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: article: type: workflow marking_store: type: multiple_state supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest initial_place: draft places: - draft - wait_for_journalist - approved_by_journalist - wait_for_spellchecker - approved_by_spellchecker - published transitions: request_review: from: [draft] to: [wait_for_journalist, wait_for_spellchecker] journalist_approval: from: [wait_for_journalist] to: [approved_by_journalist] spellchecker_approval: from: [wait_for_spellchecker] to: [approved_by_spellchecker] publish: from: [approved_by_journalist, approved_by_spellchecker] to: [published] pull_request: type: state_machine marking_store: type: single_state supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest initial_place: start places: - start - coding - travis - review - merged - closed transitions: submit: from: start to: travis update: from: [coding, travis, review] to: travis wait_for_review: from: travis to: review request_change: from: review to: coding accept: from: review to: merged reject: from: review to: closed reopen: from: closed to: review service_marking_store_workflow: type: workflow marking_store: service: workflow_service supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest places: - first - last transitions: go: from: - first to: - last �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows_enabled.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000000034�13247321071�0035570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: ~ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������workflows_without_type.yml��������������������������������������������������������������������������0000664�0000000�0000000�00000000273�13247321071�0036747�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml��������������������������������������������������������������������������������framework: workflows: missing_type: supports: stdClass places: [ first, second ] transitions: go: {from: first, to: last } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������FrameworkExtensionTest.php��������������������������������������������������������������������������0000664�0000000�0000000�00000154056�13247321071�0034145�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection���������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use Doctrine\Common\Annotations\Annotation; use Symfony\Bundle\FullStack; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ApcuAdapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ChainAdapter; use Symfony\Component\Cache\Adapter\DoctrineAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; use Symfony\Component\Serializer\Normalizer\DataUriNormalizer; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer; use Symfony\Component\Translation\DependencyInjection\TranslatorPass; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; use Symfony\Component\Workflow\Registry; abstract class FrameworkExtensionTest extends TestCase { private static $containerCache = array(); abstract protected function loadFromFile(ContainerBuilder $container, $file); public function testFormCsrfProtection() { $container = $this->createContainerFromFile('full'); $def = $container->getDefinition('form.type_extension.csrf'); $this->assertTrue($container->getParameter('form.type_extension.csrf.enabled')); $this->assertEquals('%form.type_extension.csrf.enabled%', $def->getArgument(1)); $this->assertEquals('_csrf', $container->getParameter('form.type_extension.csrf.field_name')); $this->assertEquals('%form.type_extension.csrf.field_name%', $def->getArgument(2)); } public function testPropertyAccessWithDefaultValue() { $container = $this->createContainerFromFile('full'); $def = $container->getDefinition('property_accessor'); $this->assertFalse($def->getArgument(0)); $this->assertFalse($def->getArgument(1)); } public function testPropertyAccessWithOverriddenValues() { $container = $this->createContainerFromFile('property_accessor'); $def = $container->getDefinition('property_accessor'); $this->assertTrue($def->getArgument(0)); $this->assertTrue($def->getArgument(1)); } public function testPropertyAccessCache() { $container = $this->createContainerFromFile('property_accessor'); if (!method_exists(PropertyAccessor::class, 'createCache')) { return $this->assertFalse($container->hasDefinition('cache.property_access')); } $cache = $container->getDefinition('cache.property_access'); $this->assertSame(array(PropertyAccessor::class, 'createCache'), $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode'); $this->assertSame(AdapterInterface::class, $cache->getClass()); } public function testPropertyAccessCacheWithDebug() { $container = $this->createContainerFromFile('property_accessor', array('kernel.debug' => true)); if (!method_exists(PropertyAccessor::class, 'createCache')) { return $this->assertFalse($container->hasDefinition('cache.property_access')); } $cache = $container->getDefinition('cache.property_access'); $this->assertNull($cache->getFactory()); $this->assertSame(ArrayAdapter::class, $cache->getClass(), 'ArrayAdapter should be used in debug mode'); } /** * @expectedException \LogicException * @expectedExceptionMessage CSRF protection needs sessions to be enabled. */ public function testCsrfProtectionNeedsSessionToBeEnabled() { $this->createContainerFromFile('csrf_needs_session'); } public function testCsrfProtectionForFormsEnablesCsrfProtectionAutomatically() { $container = $this->createContainerFromFile('csrf'); $this->assertTrue($container->hasDefinition('security.csrf.token_manager')); } public function testHttpMethodOverride() { $container = $this->createContainerFromFile('full'); $this->assertFalse($container->getParameter('kernel.http_method_override')); } public function testEsi() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('esi'), '->registerEsiConfiguration() loads esi.xml'); $this->assertTrue($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is registered'); } public function testEsiDisabled() { $container = $this->createContainerFromFile('esi_disabled'); $this->assertFalse($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is not registered'); $this->assertFalse($container->hasDefinition('esi')); } public function testSsi() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('ssi'), '->registerSsiConfiguration() loads ssi.xml'); $this->assertTrue($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is registered'); } public function testSsiDisabled() { $container = $this->createContainerFromFile('ssi_disabled'); $this->assertFalse($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is not registered'); $this->assertFalse($container->hasDefinition('ssi')); } public function testEsiAndSsiWithoutFragments() { $container = $this->createContainerFromFile('esi_and_ssi_without_fragments'); $this->assertFalse($container->hasDefinition('fragment.renderer.hinclude'), 'The HInclude fragment renderer is not registered'); $this->assertTrue($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is registered'); $this->assertTrue($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is registered'); } public function testEnabledProfiler() { $container = $this->createContainerFromFile('profiler'); $this->assertTrue($container->hasDefinition('profiler'), '->registerProfilerConfiguration() loads profiling.xml'); $this->assertTrue($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() loads collectors.xml'); } public function testDisabledProfiler() { $container = $this->createContainerFromFile('full'); $this->assertFalse($container->hasDefinition('profiler'), '->registerProfilerConfiguration() does not load profiling.xml'); $this->assertFalse($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() does not load collectors.xml'); } public function testWorkflows() { $container = $this->createContainerFromFile('workflows'); $this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service')); $this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service')); $workflowDefinition = $container->getDefinition('workflow.article.definition'); $this->assertSame( array( 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', ), $workflowDefinition->getArgument(0), 'Places are passed to the workflow definition' ); $this->assertSame(array('workflow.definition' => array(array('name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state'))), $workflowDefinition->getTags()); $this->assertTrue($container->hasDefinition('state_machine.pull_request', 'State machine is registered as a service')); $this->assertTrue($container->hasDefinition('state_machine.pull_request.definition', 'State machine definition is registered as a service')); $this->assertCount(4, $workflowDefinition->getArgument(1)); $this->assertSame('draft', $workflowDefinition->getArgument(2)); $stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition'); $this->assertSame( array( 'start', 'coding', 'travis', 'review', 'merged', 'closed', ), $stateMachineDefinition->getArgument(0), 'Places are passed to the state machine definition' ); $this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags()); $this->assertCount(9, $stateMachineDefinition->getArgument(1)); $this->assertSame('start', $stateMachineDefinition->getArgument(2)); $serviceMarkingStoreWorkflowDefinition = $container->getDefinition('workflow.service_marking_store_workflow'); /** @var Reference $markingStoreRef */ $markingStoreRef = $serviceMarkingStoreWorkflowDefinition->getArgument(1); $this->assertInstanceOf(Reference::class, $markingStoreRef); $this->assertEquals('workflow_service', (string) $markingStoreRef); $this->assertTrue($container->hasDefinition('workflow.registry', 'Workflow registry is registered as a service')); $registryDefinition = $container->getDefinition('workflow.registry'); $this->assertGreaterThan(0, count($registryDefinition->getMethodCalls())); } /** * @group legacy * @expectedDeprecation The "type" option of the "framework.workflows.missing_type" configuration entry must be defined since Symfony 3.3. The default value will be "state_machine" in Symfony 4.0. */ public function testDeprecatedWorkflowMissingType() { $container = $this->createContainerFromFile('workflows_without_type'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage "type" and "service" cannot be used together. */ public function testWorkflowCannotHaveBothTypeAndService() { $this->createContainerFromFile('workflow_with_type_and_service'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage "supports" and "support_strategy" cannot be used together. */ public function testWorkflowCannotHaveBothSupportsAndSupportStrategy() { $this->createContainerFromFile('workflow_with_support_and_support_strategy'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage "supports" or "support_strategy" should be configured. */ public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy() { $this->createContainerFromFile('workflow_without_support_and_support_strategy'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage "arguments" and "service" cannot be used together. */ public function testWorkflowCannotHaveBothArgumentsAndService() { $this->createContainerFromFile('workflow_with_arguments_and_service'); } public function testWorkflowMultipleTransitionsWithSameName() { $container = $this->createContainerFromFile('workflow_with_multiple_transitions_with_same_name'); $this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service')); $this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service')); $workflowDefinition = $container->getDefinition('workflow.article.definition'); $transitions = $workflowDefinition->getArgument(1); $this->assertCount(5, $transitions); $this->assertSame('request_review', $transitions[0]->getArgument(0)); $this->assertSame('journalist_approval', $transitions[1]->getArgument(0)); $this->assertSame('spellchecker_approval', $transitions[2]->getArgument(0)); $this->assertSame('publish', $transitions[3]->getArgument(0)); $this->assertSame('publish', $transitions[4]->getArgument(0)); $this->assertSame(array('approved_by_journalist', 'approved_by_spellchecker'), $transitions[3]->getArgument(1)); $this->assertSame(array('draft'), $transitions[4]->getArgument(1)); } public function testWorkflowServicesCanBeEnabled() { $container = $this->createContainerFromFile('workflows_enabled'); $this->assertTrue($container->has(Registry::class)); $this->assertTrue($container->hasDefinition('console.command.workflow_dump')); } public function testRouter() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->has('router'), '->registerRouterConfiguration() loads routing.xml'); $arguments = $container->findDefinition('router')->getArguments(); $this->assertEquals($container->getParameter('kernel.project_dir').'/config/routing.xml', $container->getParameter('router.resource'), '->registerRouterConfiguration() sets routing resource'); $this->assertEquals('%router.resource%', $arguments[1], '->registerRouterConfiguration() sets routing resource'); $this->assertEquals('xml', $arguments[2]['resource_type'], '->registerRouterConfiguration() sets routing resource type'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testRouterRequiresResourceOption() { $container = $this->createContainer(); $loader = new FrameworkExtension(); $loader->load(array(array('router' => true)), $container); } public function testSession() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml'); $this->assertEquals('fr', $container->getParameter('kernel.default_locale')); $this->assertEquals('session.storage.native', (string) $container->getAlias('session.storage')); $this->assertEquals('session.handler.native_file', (string) $container->getAlias('session.handler')); $options = $container->getParameter('session.storage.options'); $this->assertEquals('_SYMFONY', $options['name']); $this->assertEquals(86400, $options['cookie_lifetime']); $this->assertEquals('/', $options['cookie_path']); $this->assertEquals('example.com', $options['cookie_domain']); $this->assertTrue($options['cookie_secure']); $this->assertFalse($options['cookie_httponly']); $this->assertTrue($options['use_cookies']); $this->assertEquals(108, $options['gc_divisor']); $this->assertEquals(1, $options['gc_probability']); $this->assertEquals(90000, $options['gc_maxlifetime']); $this->assertEquals('/path/to/sessions', $container->getParameter('session.save_path')); } public function testNullSessionHandler() { $container = $this->createContainerFromFile('session'); $this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml'); $this->assertNull($container->getDefinition('session.storage.native')->getArgument(1)); $this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0)); } public function testRequest() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() loads request.xml'); $listenerDef = $container->getDefinition('request.add_request_formats_listener'); $this->assertEquals(array('csv' => array('text/csv', 'text/plain'), 'pdf' => array('application/pdf')), $listenerDef->getArgument(0)); } public function testEmptyRequestFormats() { $container = $this->createContainerFromFile('request'); $this->assertFalse($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() does not load request.xml when no request formats are defined'); } public function testTemplating() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('templating.name_parser'), '->registerTemplatingConfiguration() loads templating.xml'); $this->assertEquals('templating.engine.delegating', (string) $container->getAlias('templating'), '->registerTemplatingConfiguration() configures delegating loader if multiple engines are provided'); $this->assertEquals($container->getDefinition('templating.loader.chain'), $container->getDefinition('templating.loader.wrapped'), '->registerTemplatingConfiguration() configures loader chain if multiple loaders are provided'); $this->assertEquals($container->getDefinition('templating.loader'), $container->getDefinition('templating.loader.cache'), '->registerTemplatingConfiguration() configures the loader to use cache'); $this->assertEquals('%templating.loader.cache.path%', $container->getDefinition('templating.loader.cache')->getArgument(1)); $this->assertEquals('/path/to/cache', $container->getParameter('templating.loader.cache.path')); $this->assertEquals(array('php', 'twig'), $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter'); $this->assertEquals(array('FrameworkBundle:Form', 'theme1', 'theme2'), $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme'); $this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template'); } public function testTemplatingCanBeDisabled() { $container = $this->createContainerFromFile('templating_disabled'); $this->assertFalse($container->hasParameter('templating.engines'), '"templating.engines" container parameter is not registered when templating is disabled.'); } public function testAssets() { $container = $this->createContainerFromFile('assets'); $packages = $container->getDefinition('assets.packages'); // default package $defaultPackage = $container->getDefinition((string) $packages->getArgument(0)); $this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); // packages $packages = $packages->getArgument(1); $this->assertCount(6, $packages); $package = $container->getDefinition((string) $packages['images_path']); $this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['images']); $this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['foo']); $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s'); $package = $container->getDefinition((string) $packages['bar']); $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['bar_version_strategy']); $this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1)); $package = $container->getDefinition((string) $packages['json_manifest_strategy']); $versionStrategy = $container->getDefinition((string) $package->getArgument(1)); $this->assertEquals('assets.json_manifest_version_strategy', $versionStrategy->getParent()); $this->assertEquals('/path/to/manifest.json', $versionStrategy->getArgument(0)); } public function testAssetsDefaultVersionStrategyAsService() { $container = $this->createContainerFromFile('assets_version_strategy_as_service'); $packages = $container->getDefinition('assets.packages'); // default package $defaultPackage = $container->getDefinition((string) $packages->getArgument(0)); $this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1)); } public function testAssetsCanBeDisabled() { $container = $this->createContainerFromFile('assets_disabled'); $this->assertFalse($container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); } public function testWebLink() { $container = $this->createContainerFromFile('web_link'); $this->assertTrue($container->hasDefinition('web_link.add_link_header_listener')); } public function testTranslator() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->hasDefinition('translator.default'), '->registerTranslatorConfiguration() loads translation.xml'); $this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator'); $options = $container->getDefinition('translator.default')->getArgument(4); $files = array_map('realpath', $options['resource_files']['en']); $ref = new \ReflectionClass('Symfony\Component\Validator\Validation'); $this->assertContains( strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Validator translation resources' ); $ref = new \ReflectionClass('Symfony\Component\Form\Form'); $this->assertContains( strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Form translation resources' ); $ref = new \ReflectionClass('Symfony\Component\Security\Core\Security'); $this->assertContains( strtr(dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Security translation resources' ); $this->assertContains( strtr(__DIR__.'/Fixtures/translations/test_paths.en.yml', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds translation resources in custom paths' ); $this->assertContains( strtr(__DIR__.'/translations/test_default.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds translation resources in default path' ); $calls = $container->getDefinition('translator.default')->getMethodCalls(); $this->assertEquals(array('fr'), $calls[1][1][0]); } public function testTranslatorMultipleFallbacks() { $container = $this->createContainerFromFile('translator_fallbacks'); $calls = $container->getDefinition('translator.default')->getMethodCalls(); $this->assertEquals(array('en', 'fr'), $calls[1][1][0]); } public function testTranslatorHelperIsRegisteredWhenTranslatorIsEnabled() { $container = $this->createContainerFromFile('templating_php_translator_enabled'); $this->assertTrue($container->has('templating.helper.translator')); } public function testTranslatorHelperIsNotRegisteredWhenTranslatorIsDisabled() { $container = $this->createContainerFromFile('templating_php_translator_disabled'); $this->assertFalse($container->has('templating.helper.translator')); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testTemplatingRequiresAtLeastOneEngine() { $container = $this->createContainer(); $loader = new FrameworkExtension(); $loader->load(array(array('templating' => null)), $container); } public function testValidation() { $container = $this->createContainerFromFile('full'); $projectDir = $container->getParameter('kernel.project_dir'); $ref = new \ReflectionClass('Symfony\Component\Form\Form'); $xmlMappings = array( dirname($ref->getFileName()).'/Resources/config/validation.xml', strtr($projectDir.'/config/validator/foo.xml', '/', DIRECTORY_SEPARATOR), ); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $annotations = !class_exists(FullStack::class) && class_exists(Annotation::class); $this->assertCount($annotations ? 7 : 6, $calls); $this->assertSame('setConstraintValidatorFactory', $calls[0][0]); $this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]); $this->assertSame('setTranslator', $calls[1][0]); $this->assertEquals(array(new Reference('translator')), $calls[1][1]); $this->assertSame('setTranslationDomain', $calls[2][0]); $this->assertSame(array('%validator.translation_domain%'), $calls[2][1]); $this->assertSame('addXmlMappings', $calls[3][0]); $this->assertSame(array($xmlMappings), $calls[3][1]); $i = 3; if ($annotations) { $this->assertSame('enableAnnotationMapping', $calls[++$i][0]); } $this->assertSame('addMethodMapping', $calls[++$i][0]); $this->assertSame(array('loadValidatorMetadata'), $calls[$i][1]); $this->assertSame('setMetadataCache', $calls[++$i][0]); $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]); } public function testValidationService() { $container = $this->createContainerFromFile('validation_annotations', array('kernel.charset' => 'UTF-8'), false); $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); } public function testAnnotations() { $container = $this->createContainerFromFile('full', array(), true, false); $container->addCompilerPass(new TestAnnotationsPass()); $container->compile(); $this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.filesystem_cache')->getArgument(0)); $this->assertSame('annotations.filesystem_cache', (string) $container->getDefinition('annotation_reader')->getArgument(1)); } public function testFileLinkFormat() { if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { $this->markTestSkipped('A custom file_link_format is defined.'); } $container = $this->createContainerFromFile('full'); $this->assertEquals('file%link%format', $container->getParameter('debug.file_link_format')); } public function testValidationAnnotations() { $container = $this->createContainerFromFile('validation_annotations'); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $this->assertCount(7, $calls); $this->assertSame('enableAnnotationMapping', $calls[4][0]); $this->assertEquals(array(new Reference('annotation_reader')), $calls[4][1]); $this->assertSame('addMethodMapping', $calls[5][0]); $this->assertSame(array('loadValidatorMetadata'), $calls[5][1]); $this->assertSame('setMetadataCache', $calls[6][0]); $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[6][1]); // no cache this time } public function testValidationPaths() { require_once __DIR__.'/Fixtures/TestBundle/TestBundle.php'; $container = $this->createContainerFromFile('validation_annotations', array( 'kernel.bundles' => array('TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'), 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/TestBundle')), )); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $this->assertCount(8, $calls); $this->assertSame('addXmlMappings', $calls[3][0]); $this->assertSame('addYamlMappings', $calls[4][0]); $this->assertSame('enableAnnotationMapping', $calls[5][0]); $this->assertSame('addMethodMapping', $calls[6][0]); $this->assertSame(array('loadValidatorMetadata'), $calls[6][1]); $this->assertSame('setMetadataCache', $calls[7][0]); $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[7][1]); $xmlMappings = $calls[3][1][0]; $this->assertCount(3, $xmlMappings); try { // Testing symfony/symfony $this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]); } catch (\Exception $e) { // Testing symfony/framework-bundle with deps=high $this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]); } $this->assertStringEndsWith('TestBundle/Resources/config/validation.xml', $xmlMappings[1]); $yamlMappings = $calls[4][1][0]; $this->assertCount(1, $yamlMappings); $this->assertStringEndsWith('TestBundle/Resources/config/validation.yml', $yamlMappings[0]); } public function testValidationPathsUsingCustomBundlePath() { require_once __DIR__.'/Fixtures/CustomPathBundle/src/CustomPathBundle.php'; $container = $this->createContainerFromFile('validation_annotations', array( 'kernel.bundles' => array('CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'), 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/CustomPathBundle')), )); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $xmlMappings = $calls[3][1][0]; $this->assertCount(3, $xmlMappings); try { // Testing symfony/symfony $this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]); } catch (\Exception $e) { // Testing symfony/framework-bundle with deps=high $this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]); } $this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.xml', $xmlMappings[1]); $yamlMappings = $calls[4][1][0]; $this->assertCount(1, $yamlMappings); $this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.yml', $yamlMappings[0]); } public function testValidationNoStaticMethod() { $container = $this->createContainerFromFile('validation_no_static_method'); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $annotations = !class_exists(FullStack::class) && class_exists(Annotation::class); $this->assertCount($annotations ? 6 : 5, $calls); $this->assertSame('addXmlMappings', $calls[3][0]); $i = 3; if ($annotations) { $this->assertSame('enableAnnotationMapping', $calls[++$i][0]); } $this->assertSame('setMetadataCache', $calls[++$i][0]); $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]); // no cache, no annotations, no static methods } public function testValidationTranslationDomain() { $container = $this->createContainerFromFile('validation_translation_domain'); $this->assertSame('messages', $container->getParameter('validator.translation_domain')); } public function testValidationStrictEmail() { $container = $this->createContainerFromFile('validation_strict_email'); $this->assertTrue($container->getDefinition('validator.email')->getArgument(0)); } public function testValidationMapping() { $container = $this->createContainerFromFile('validation_mapping'); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $this->assertSame('addXmlMappings', $calls[3][0]); $this->assertCount(3, $calls[3][1][0]); $this->assertSame('addYamlMappings', $calls[4][0]); $this->assertCount(3, $calls[4][1][0]); $this->assertContains('foo.yml', $calls[4][1][0][0]); $this->assertContains('validation.yml', $calls[4][1][0][1]); $this->assertContains('validation.yaml', $calls[4][1][0][2]); } public function testFormsCanBeEnabledWithoutCsrfProtection() { $container = $this->createContainerFromFile('form_no_csrf'); $this->assertFalse($container->getParameter('form.type_extension.csrf.enabled')); } public function testStopwatchEnabledWithDebugModeEnabled() { $container = $this->createContainerFromFile('default_config', array( 'kernel.container_class' => 'foo', 'kernel.debug' => true, )); $this->assertTrue($container->has('debug.stopwatch')); } public function testStopwatchEnabledWithDebugModeDisabled() { $container = $this->createContainerFromFile('default_config', array( 'kernel.container_class' => 'foo', )); $this->assertTrue($container->has('debug.stopwatch')); } public function testSerializerDisabled() { $container = $this->createContainerFromFile('default_config'); $this->assertSame(!class_exists(FullStack::class) && class_exists(Serializer::class), $container->has('serializer')); } public function testSerializerEnabled() { $container = $this->createContainerFromFile('full'); $this->assertTrue($container->has('serializer')); $argument = $container->getDefinition('serializer.mapping.chain_loader')->getArgument(0); $this->assertCount(2, $argument); $this->assertEquals('Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', $argument[0]->getClass()); $this->assertNull($container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1)); $this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1)); $this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3)); $this->assertEquals(array('setCircularReferenceHandler', array(new Reference('my.circular.reference.handler'))), $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]); } public function testRegisterSerializerExtractor() { $container = $this->createContainerFromFile('full'); $serializerExtractorDefinition = $container->getDefinition('property_info.serializer_extractor'); $this->assertEquals('serializer.mapping.class_metadata_factory', $serializerExtractorDefinition->getArgument(0)->__toString()); $this->assertFalse($serializerExtractorDefinition->isPublic()); $tag = $serializerExtractorDefinition->getTag('property_info.list_extractor'); $this->assertEquals(array('priority' => -999), $tag[0]); } public function testDataUriNormalizerRegistered() { $container = $this->createContainerFromFile('full'); $definition = $container->getDefinition('serializer.normalizer.data_uri'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals(DataUriNormalizer::class, $definition->getClass()); $this->assertEquals(-920, $tag[0]['priority']); } public function testDateIntervalNormalizerRegistered() { if (!class_exists(DateIntervalNormalizer::class)) { $this->markTestSkipped('The DateIntervalNormalizer has been introduced in the Serializer Component version 3.4.'); } $container = $this->createContainerFromFile('full'); $definition = $container->getDefinition('serializer.normalizer.dateinterval'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals(DateIntervalNormalizer::class, $definition->getClass()); $this->assertEquals(-915, $tag[0]['priority']); } public function testDateTimeNormalizerRegistered() { $container = $this->createContainerFromFile('full'); $definition = $container->getDefinition('serializer.normalizer.datetime'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals(DateTimeNormalizer::class, $definition->getClass()); $this->assertEquals(-910, $tag[0]['priority']); } public function testJsonSerializableNormalizerRegistered() { $container = $this->createContainerFromFile('full'); $definition = $container->getDefinition('serializer.normalizer.json_serializable'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals(JsonSerializableNormalizer::class, $definition->getClass()); $this->assertEquals(-900, $tag[0]['priority']); } public function testObjectNormalizerRegistered() { $container = $this->createContainerFromFile('full'); $definition = $container->getDefinition('serializer.normalizer.object'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals('Symfony\Component\Serializer\Normalizer\ObjectNormalizer', $definition->getClass()); $this->assertEquals(-1000, $tag[0]['priority']); } public function testSerializerCacheActivated() { $container = $this->createContainerFromFile('serializer_enabled'); $this->assertTrue($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); $cache = $container->getDefinition('serializer.mapping.cache_class_metadata_factory')->getArgument(1); $this->assertEquals(new Reference('serializer.mapping.cache.symfony'), $cache); } public function testSerializerCacheDisabled() { $container = $this->createContainerFromFile('serializer_enabled', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); } /** * @group legacy * @expectedDeprecation The "framework.serializer.cache" option is deprecated %s. */ public function testDeprecatedSerializerCacheOption() { $container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); $this->assertTrue($container->hasDefinition('serializer.mapping.class_metadata_factory')); $cache = $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1); $this->assertEquals(new Reference('foo'), $cache); } public function testSerializerMapping() { $container = $this->createContainerFromFile('serializer_mapping', array('kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle', 'parent' => null)))); $projectDir = $container->getParameter('kernel.project_dir'); $configDir = __DIR__.'/Fixtures/TestBundle/Resources/config'; $expectedLoaders = array( new Definition(AnnotationLoader::class, array(new Reference('annotation_reader'))), new Definition(XmlFileLoader::class, array($configDir.'/serialization.xml')), new Definition(YamlFileLoader::class, array($configDir.'/serialization.yml')), new Definition(YamlFileLoader::class, array($projectDir.'/config/serializer/foo.yml')), new Definition(XmlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.xml')), new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.yml')), new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yml')), new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yaml')), ); foreach ($expectedLoaders as $definition) { if (is_file($arg = $definition->getArgument(0))) { $definition->replaceArgument(0, strtr($arg, '/', DIRECTORY_SEPARATOR)); } $definition->setPublic(false); } $loaders = $container->getDefinition('serializer.mapping.chain_loader')->getArgument(0); foreach ($loaders as $loader) { if (is_file($arg = $loader->getArgument(0))) { $loader->replaceArgument(0, strtr($arg, '/', DIRECTORY_SEPARATOR)); } } $this->assertEquals($expectedLoaders, $loaders); } public function testAssetHelperWhenAssetsAreEnabled() { $container = $this->createContainerFromFile('full'); $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); $this->assertSame('assets.packages', (string) $packages); } public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() { $container = $this->createContainerFromFile('templating_no_assets'); $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); $this->assertSame('assets.packages', (string) $packages); } public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() { $container = $this->createContainerFromFile('templating_php_assets_disabled'); $this->assertTrue(!$container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); } public function testAssetHelperWhenAssetsAndTemplatesAreDisabled() { $container = $this->createContainerFromFile('default_config'); $this->assertFalse($container->hasDefinition('templating.helper.assets')); } public function testSerializerServiceIsRegisteredWhenEnabled() { $container = $this->createContainerFromFile('serializer_enabled'); $this->assertTrue($container->hasDefinition('serializer')); } public function testSerializerServiceIsNotRegisteredWhenDisabled() { $container = $this->createContainerFromFile('serializer_disabled'); $this->assertFalse($container->hasDefinition('serializer')); } public function testPropertyInfoDisabled() { $container = $this->createContainerFromFile('default_config'); $this->assertFalse($container->has('property_info')); } public function testPropertyInfoEnabled() { $container = $this->createContainerFromFile('property_info'); $this->assertTrue($container->has('property_info')); } public function testEventDispatcherService() { $container = $this->createContainer(array('kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret')); $container->registerExtension(new FrameworkExtension()); $this->loadFromFile($container, 'default_config'); $container ->register('foo', \stdClass::class) ->setPublic(true) ->setProperty('dispatcher', new Reference('event_dispatcher')); $container->compile(); $this->assertInstanceOf(EventDispatcherInterface::class, $container->get('foo')->dispatcher); } public function testCacheDefaultRedisProvider() { $container = $this->createContainerFromFile('cache'); $redisUrl = 'redis://localhost'; $providerId = 'cache_connection.'.ContainerBuilder::hash($redisUrl); $this->assertTrue($container->hasDefinition($providerId)); $url = $container->getDefinition($providerId)->getArgument(0); $this->assertSame($redisUrl, $url); } public function testCacheDefaultRedisProviderWithEnvVar() { $container = $this->createContainerFromFile('cache_env_var'); $redisUrl = 'redis://paas.com'; $providerId = 'cache_connection.'.ContainerBuilder::hash($redisUrl); $this->assertTrue($container->hasDefinition($providerId)); $url = $container->getDefinition($providerId)->getArgument(0); $this->assertSame($redisUrl, $url); } public function testCachePoolServices() { $container = $this->createContainerFromFile('cache'); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.app', 11); } public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug() { $container = $this->createContainer(array('kernel.debug' => true)); (new FrameworkExtension())->load(array(), $container); $this->assertCount(1, $container->getDefinition('config_cache_factory')->getArguments()); $container = $this->createContainer(array('kernel.debug' => false)); (new FrameworkExtension())->load(array(), $container); $this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments()); } protected function createContainer(array $data = array()) { return new ContainerBuilder(new ParameterBag(array_merge(array( 'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'), 'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)), 'kernel.cache_dir' => __DIR__, 'kernel.project_dir' => __DIR__, 'kernel.debug' => false, 'kernel.environment' => 'test', 'kernel.name' => 'kernel', 'kernel.root_dir' => __DIR__, 'kernel.container_class' => 'testContainer', 'container.build_hash' => 'Abc1234', 'container.build_id' => hash('crc32', 'Abc123423456789'), 'container.build_time' => 23456789, ), $data))); } protected function createContainerFromFile($file, $data = array(), $resetCompilerPasses = true, $compile = true) { $cacheKey = md5(get_class($this).$file.serialize($data)); if ($compile && isset(self::$containerCache[$cacheKey])) { return self::$containerCache[$cacheKey]; } $container = $this->createContainer($data); $container->registerExtension(new FrameworkExtension()); $this->loadFromFile($container, $file); if ($resetCompilerPasses) { $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); } $container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader'))); $container->getCompilerPassConfig()->setAfterRemovingPasses(array(new AddAnnotationsCachedReaderPass())); if (!$compile) { return $container; } $container->compile(); return self::$containerCache[$cacheKey] = $container; } protected function createContainerFromClosure($closure, $data = array()) { $container = $this->createContainer($data); $container->registerExtension(new FrameworkExtension()); $loader = new ClosureLoader($container); $loader->load($closure); $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); return $container; } private function assertPathPackage(ContainerBuilder $container, ChildDefinition $package, $basePath, $version, $format) { $this->assertEquals('assets.path_package', $package->getParent()); $this->assertEquals($basePath, $package->getArgument(0)); $this->assertVersionStrategy($container, $package->getArgument(1), $version, $format); } private function assertUrlPackage(ContainerBuilder $container, ChildDefinition $package, $baseUrls, $version, $format) { $this->assertEquals('assets.url_package', $package->getParent()); $this->assertEquals($baseUrls, $package->getArgument(0)); $this->assertVersionStrategy($container, $package->getArgument(1), $version, $format); } private function assertVersionStrategy(ContainerBuilder $container, Reference $reference, $version, $format) { $versionStrategy = $container->getDefinition((string) $reference); if (null === $version) { $this->assertEquals('assets.empty_version_strategy', (string) $reference); } else { $this->assertEquals('assets.static_version_strategy', $versionStrategy->getParent()); $this->assertEquals($version, $versionStrategy->getArgument(0)); $this->assertEquals($format, $versionStrategy->getArgument(1)); } } private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $container, $id, $adapter, $defaultLifetime) { $this->assertTrue($container->has($id), sprintf('Service definition "%s" for cache pool of type "%s" is registered', $id, $adapter)); $poolDefinition = $container->getDefinition($id); $this->assertInstanceOf(ChildDefinition::class, $poolDefinition, sprintf('Cache pool "%s" is based on an abstract cache pool.', $id)); $this->assertTrue($poolDefinition->hasTag('cache.pool'), sprintf('Service definition "%s" is tagged with the "cache.pool" tag.', $id)); $this->assertFalse($poolDefinition->isAbstract(), sprintf('Service definition "%s" is not abstract.', $id)); $tag = $poolDefinition->getTag('cache.pool'); $this->assertArrayHasKey('default_lifetime', $tag[0], 'The default lifetime is stored as an attribute of the "cache.pool" tag.'); $this->assertSame($defaultLifetime, $tag[0]['default_lifetime'], 'The default lifetime is stored as an attribute of the "cache.pool" tag.'); $parentDefinition = $poolDefinition; do { $parentId = $parentDefinition->getParent(); $parentDefinition = $container->findDefinition($parentId); } while ($parentDefinition instanceof ChildDefinition); switch ($adapter) { case 'cache.adapter.apcu': $this->assertSame(ApcuAdapter::class, $parentDefinition->getClass()); break; case 'cache.adapter.doctrine': $this->assertSame(DoctrineAdapter::class, $parentDefinition->getClass()); break; case 'cache.app': if (ChainAdapter::class === $parentDefinition->getClass()) { break; } // no break case 'cache.adapter.filesystem': $this->assertSame(FilesystemAdapter::class, $parentDefinition->getClass()); break; case 'cache.adapter.psr6': $this->assertSame(ProxyAdapter::class, $parentDefinition->getClass()); break; case 'cache.adapter.redis': $this->assertSame(RedisAdapter::class, $parentDefinition->getClass()); break; default: $this->fail('Unresolved adapter: '.$adapter); } } } /** * Simulates ReplaceAliasByActualDefinitionPass. */ class TestAnnotationsPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $container->setDefinition('annotation_reader', $container->getDefinition('annotations.cached_reader')); $container->removeDefinition('annotations.cached_reader'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������PhpFrameworkExtensionTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000003375�13247321071�0034612�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection���������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\Config\FileLocator; class PhpFrameworkExtensionTest extends FrameworkExtensionTest { protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php')); $loader->load($file.'.php'); } /** * @expectedException \LogicException */ public function testAssetsCannotHavePathAndUrl() { $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', array( 'assets' => array( 'base_urls' => 'http://cdn.example.com', 'base_path' => '/foo', ), )); }); } /** * @expectedException \LogicException */ public function testAssetPackageCannotHavePathAndUrl() { $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', array( 'assets' => array( 'packages' => array( 'impossible' => array( 'base_urls' => 'http://cdn.example.com', 'base_path' => '/foo', ), ), ), )); }); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������XmlFrameworkExtensionTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000001717�13247321071�0034621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection���������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; class XmlFrameworkExtensionTest extends FrameworkExtensionTest { protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')); $loader->load($file.'.xml'); } public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() { $this->markTestSkipped('The assets key cannot be set to false using the XML configuration format.'); } } �������������������������������������������������YamlFrameworkExtensionTest.php����������������������������������������������������������������������0000664�0000000�0000000�00000001364�13247321071�0034761�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection���������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator; class YamlFrameworkExtensionTest extends FrameworkExtensionTest { protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml')); $loader->load($file.'.yml'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/������������������0000775�0000000�0000000�00000000000�13247321071�0030253�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/serializer/�������0000775�0000000�0000000�00000000000�13247321071�0032424�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/serializer/foo.yml0000664�0000000�0000000�00000000000�13247321071�0033720�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/validator/��������0000775�0000000�0000000�00000000000�13247321071�0032240�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/validator/foo.xml�0000664�0000000�0000000�00000000000�13247321071�0033533�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/translations/������������0000775�0000000�0000000�00000000000�13247321071�0031527�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������test_default.en.xlf���������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0035235�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/translations��������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025654�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ResolveControllerNameSubscriberTest.php�������������������������������������������������������������0000664�0000000�0000000�00000004663�13247321071�0035467�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener���������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\EventListener; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Bundle\FrameworkBundle\EventListener\ResolveControllerNameSubscriber; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; class ResolveControllerNameSubscriberTest extends TestCase { public function testReplacesControllerAttribute() { $parser = $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock(); $parser->expects($this->any()) ->method('parse') ->with('AppBundle:Starting:format') ->willReturn('App\\Final\\Format::methodName'); $httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = new Request(); $request->attributes->set('_controller', 'AppBundle:Starting:format'); $subscriber = new ResolveControllerNameSubscriber($parser); $subscriber->onKernelRequest(new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST)); $this->assertEquals('App\\Final\\Format::methodName', $request->attributes->get('_controller')); } /** * @dataProvider provideSkippedControllers */ public function testSkipsOtherControllerFormats($controller) { $parser = $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock(); $parser->expects($this->never()) ->method('parse'); $httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = new Request(); $request->attributes->set('_controller', $controller); $subscriber = new ResolveControllerNameSubscriber($parser); $subscriber->onKernelRequest(new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST)); $this->assertEquals($controller, $request->attributes->get('_controller')); } public function provideSkippedControllers() { yield array('Other:format'); yield array(function () {}); } } �����������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024676�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/�������������������������0000775�0000000�0000000�00000000000�13247321071�0026702�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/BaseBundle.php�����������0000664�0000000�0000000�00000000610�13247321071�0031414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class BaseBundle extends Bundle { } ������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/���������������0000775�0000000�0000000�00000000000�13247321071�0030654�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/views/���������0000775�0000000�0000000�00000000000�13247321071�0032011�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������base.format.engine����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0035310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/views�����������������������������������������������������������������������������controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034115�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/views�����������������������������������������������������������������������������base.format.engine����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0037473�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/views/controller������������������������������������������������������������������this.is.a.template.format.engine��������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0040010�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/BaseBundle/Resources/views�����������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/DeclaredClass.php�������������������0000664�0000000�0000000�00000000131�13247321071�0030073�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; class DeclaredClass { } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/�������������������������0000775�0000000�0000000�00000000000�13247321071�0027014�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.json�������������0000664�0000000�0000000�00000000063�13247321071�0031217�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "service": "service_1", "public": true } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md���������������0000664�0000000�0000000�00000000044�13247321071�0030645�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Service: `service_1` - Public: yes��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.txt��������������0000664�0000000�0000000�00000000225�13247321071�0031065�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������  // This service is an alias for the service service_1 ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.xml��������������0000664�0000000�0000000�00000000122�13247321071�0031042�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <alias service="service_1" public="true"/> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.json�������������0000664�0000000�0000000�00000000064�13247321071�0031221�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "service": "service_2", "public": false } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md���������������0000664�0000000�0000000�00000000043�13247321071�0030645�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Service: `service_2` - Public: no���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.txt��������������0000664�0000000�0000000�00000000225�13247321071�0031066�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������  // This service is an alias for the service service_2 ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.xml��������������0000664�0000000�0000000�00000000123�13247321071�0031044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <alias service="service_2" public="false"/> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������alias_with_definition_1.json������������������������������������������������������������������������0000664�0000000�0000000�00000000673�13247321071�0034412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������[ { "service": "service_1", "public": true }, { "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] } ] ���������������������������������������������������������������������alias_with_definition_1.md��������������������������������������������������������������������������0000664�0000000�0000000�00000000427�13247321071�0034036�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������### alias_1 - Service: `service_1` - Public: yes ### service_1 - Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get` �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������alias_with_definition_1.txt�������������������������������������������������������������������������0000664�0000000�0000000�00000002050�13247321071�0034247�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� // This service is an alias for the service service_1 Information for Service "service_1" =================================== ---------------- -----------------------------  Option   Value  ---------------- ----------------------------- Service ID service_1 Class Full\Qualified\Class1 Tags - Public yes Synthetic no Lazy yes Shared yes Abstract yes Autowired no Autoconfigured no Factory Class Full\Qualified\FactoryClass Factory Method get ---------------- ----------------------------- ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������alias_with_definition_1.xml�������������������������������������������������������������������������0000664�0000000�0000000�00000000540�13247321071�0034232�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <alias id="alias_1" service="service_1" public="true"/> <definition id="service_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> </definition> ����������������������������������������������������������������������������������������������������������������������������������������������������������������alias_with_definition_2.json������������������������������������������������������������������������0000664�0000000�0000000�00000001647�13247321071�0034415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������[ { "service": "service_2", "public": false }, { "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ], "tags": [ { "name": "tag1", "parameters": { "attr1": "val1", "attr2": "val2" } }, { "name": "tag1", "parameters": { "attr3": "val3" } }, { "name": "tag2", "parameters": [] } ] } ] �����������������������������������������������������������������������������������������alias_with_definition_2.md��������������������������������������������������������������������������0000664�0000000�0000000�00000000626�13247321071�0034040�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������### alias_2 - Service: `service_2` - Public: no ### service_2 - Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` - Tag: `tag1` - Attr1: val1 - Attr2: val2 - Tag: `tag1` - Attr3: val3 - Tag: `tag2` ����������������������������������������������������������������������������������������������������������alias_with_definition_2.txt�������������������������������������������������������������������������0000664�0000000�0000000�00000002776�13247321071�0034267�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� // This service is an alias for the service service_2 Information for Service "service_2" =================================== ----------------- ---------------------------------  Option   Value  ----------------- --------------------------------- Service ID service_2 Class Full\Qualified\Class2  Tags tag1 (attr1: val1, attr2: val2)   tag1 (attr3: val3)   tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autoconfigured no Required File /path/to/file Factory Service factory.service Factory Method get ----------------- --------------------------------- ��alias_with_definition_2.xml�������������������������������������������������������������������������0000664�0000000�0000000�00000001223�13247321071�0034232�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <alias id="alias_2" service="service_2" public="false"/> <definition id="service_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> <tags> <tag name="tag1"> <parameter name="attr1">val1</parameter> <parameter name="attr2">val2</parameter> </tag> <tag name="tag1"> <parameter name="attr3">val3</parameter> </tag> <tag name="tag2"/> </tags> </definition> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/array_parameter.json�����0000664�0000000�0000000�00000000245�13247321071�0033066�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "twig.form.resources": ["bootstrap_3_horizontal_layout.html.twig", "bootstrap_3_layout.html.twig", "form_div_layout.html.twig", "form_table_layout.html.twig"] } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/array_parameter.md�������0000664�0000000�0000000�00000000151�13247321071�0032511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������twig.form.resources =================== ["bootstrap_3_horizontal_layout.html.twig","bootstrap_3_layo... �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/array_parameter.txt������0000664�0000000�0000000�00000000725�13247321071�0032737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ --------------------- -----------------------------------------------------------------  Parameter   Value  --------------------- ----------------------------------------------------------------- twig.form.resources ["bootstrap_3_horizontal_layout.html.twig","bootstrap_3_layo... --------------------- ----------------------------------------------------------------- �������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/array_parameter.xml������0000664�0000000�0000000�00000000230�13247321071�0032707�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <parameter key="twig.form.resources">["bootstrap_3_horizontal_layout.html.twig","bootstrap_3_layo...</parameter> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json�0000664�0000000�0000000�00000004607�13247321071�0033651�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "definitions": { "definition_1": { "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "arguments": [ { "type": "service", "id": "definition2" }, "%parameter%", { "class": "inline_service", "public": false, "synthetic": false, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "arguments": [ "arg1", "arg2" ], "file": null, "tags": [] }, [ "foo", { "type": "service", "id": "definition2" }, { "class": "inline_service", "public": false, "synthetic": false, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "arguments": [], "file": null, "tags": [] } ], [ { "type": "service", "id": "definition_1" }, { "type": "service", "id": "definition_2" } ] ], "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] } }, "aliases": { "alias_1": { "service": "service_1", "public": true } }, "services": { "service_container": "Symfony\\Component\\DependencyInjection\\ContainerBuilder" } } �������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.md���0000664�0000000�0000000�00000000734�13247321071�0033275�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Public services =============== Definitions ----------- ### definition_1 - Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Arguments: yes - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get` Aliases ------- ### alias_1 - Service: `service_1` - Public: yes Services -------- - `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` ������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt��0000664�0000000�0000000�00000001230�13247321071�0033504�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Public Services ================================= ------------------- --------------------------------------------------------  Service ID   Class name  ------------------- -------------------------------------------------------- alias_1 alias for "service_1" definition_1 Full\Qualified\Class1 service_container Symfony\Component\DependencyInjection\ContainerBuilder ------------------- -------------------------------------------------------- ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml��0000664�0000000�0000000�00000002500�13247321071�0033466�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container> <alias id="alias_1" service="service_1" public="true"/> <definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> <argument type="service" id="definition2"/> <argument>%parameter%</argument> <argument> <definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""> <argument>arg1</argument> <argument>arg2</argument> </definition> </argument> <argument type="collection"> <argument>foo</argument> <argument type="service" id="definition2"/> <argument> <definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/> </argument> </argument> <argument type="iterator"> <argument type="service" id="definition_1"/> <argument type="service" id="definition_2"/> </argument> </definition> <service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json����0000664�0000000�0000000�00000001302�13247321071�0033107�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "definitions": { "definition_1": { "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] } }, "aliases": { "alias_1": { "service": "service_1", "public": true } }, "services": { "service_container": "Symfony\\Component\\DependencyInjection\\ContainerBuilder" } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md������0000664�0000000�0000000�00000000713�13247321071�0032543�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Public services =============== Definitions ----------- ### definition_1 - Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get` Aliases ------- ### alias_1 - Service: `service_1` - Public: yes Services -------- - `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` �����������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt�����0000664�0000000�0000000�00000001230�13247321071�0032755�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Public Services ================================= ------------------- --------------------------------------------------------  Service ID   Class name  ------------------- -------------------------------------------------------- alias_1 alias for "service_1" definition_1 Full\Qualified\Class1 service_container Symfony\Component\DependencyInjection\ContainerBuilder ------------------- -------------------------------------------------------- ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml�����0000664�0000000�0000000�00000000747�13247321071�0032752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container> <alias id="alias_1" service="service_1" public="true"/> <definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> </definition> <service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/> </container> �������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json��0000664�0000000�0000000�00000003435�13247321071�0033465�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "definitions": { "definition_1": { "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] }, "definition_2": { "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ], "tags": [ { "name": "tag1", "parameters": { "attr1": "val1", "attr2": "val2" } }, { "name": "tag1", "parameters": { "attr3": "val3" } }, { "name": "tag2", "parameters": [] } ] } }, "aliases": { "alias_1": { "service": "service_1", "public": true }, "alias_2": { "service": "service_2", "public": false } }, "services": { "service_container": "Symfony\\Component\\DependencyInjection\\ContainerBuilder" } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md����0000664�0000000�0000000�00000001575�13247321071�0033117�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Public and private services =========================== Definitions ----------- ### definition_1 - Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get` ### definition_2 - Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` - Tag: `tag1` - Attr1: val1 - Attr2: val2 - Tag: `tag1` - Attr3: val3 - Tag: `tag2` Aliases ------- ### alias_1 - Service: `service_1` - Public: yes ### alias_2 - Service: `service_2` - Public: no Services -------- - `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` �����������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt���0000664�0000000�0000000�00000001516�13247321071�0033331�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Public and Private Services ============================================= ------------------- --------------------------------------------------------  Service ID   Class name  ------------------- -------------------------------------------------------- alias_1 alias for "service_1" alias_2 alias for "service_2" definition_1 Full\Qualified\Class1 definition_2 Full\Qualified\Class2 service_container Symfony\Component\DependencyInjection\ContainerBuilder ------------------- -------------------------------------------------------- ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml���0000664�0000000�0000000�00000002170�13247321071�0033307�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container> <alias id="alias_1" service="service_1" public="true"/> <alias id="alias_2" service="service_2" public="false"/> <definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> </definition> <definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> <tags> <tag name="tag1"> <parameter name="attr1">val1</parameter> <parameter name="attr2">val2</parameter> </tag> <tag name="tag1"> <parameter name="attr3">val3</parameter> </tag> <tag name="tag2"/> </tags> </definition> <service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json������0000664�0000000�0000000�00000002100�13247321071�0032462�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "definitions": { "definition_2": { "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ], "tags": [ { "name": "tag1", "parameters": { "attr1": "val1", "attr2": "val2" } }, { "name": "tag1", "parameters": { "attr3": "val3" } }, { "name": "tag2", "parameters": [] } ] } }, "aliases": [], "services": [] } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md��������0000664�0000000�0000000�00000000731�13247321071�0032121�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Public and private services with tag `tag1` =========================================== Definitions ----------- ### definition_2 - Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` - Tag: `tag1` - Attr1: val1 - Attr2: val2 - Tag: `tag1` - Attr3: val3 - Tag: `tag2` ���������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt�������0000664�0000000�0000000�00000001131�13247321071�0032333�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Public and Private Services Tagged with "tag1" Tag ==================================================================== -------------- ------- ------- ------- -----------------------  Service ID   attr1   attr2   attr3   Class name  -------------- ------- ------- ------- ----------------------- definition_2 val1 val2 Full\Qualified\Class2 " val3 -------------- ------- ------- ------- ----------------------- ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml�������0000664�0000000�0000000�00000001226�13247321071�0032321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container> <definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> <tags> <tag name="tag1"> <parameter name="attr1">val1</parameter> <parameter name="attr2">val2</parameter> </tag> <tag name="tag1"> <parameter name="attr3">val3</parameter> </tag> <tag name="tag2"/> </tags> </definition> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json������0000664�0000000�0000000�00000001737�13247321071�0032603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "tag1": [ { "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ] } ], "tag2": [ { "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ] } ] } ���������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md��������0000664�0000000�0000000�00000001105�13247321071�0032217�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Container tags ============== tag1 ---- ### definition_2 - Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` tag2 ---- ### definition_2 - Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.txt�������0000664�0000000�0000000�00000000342�13247321071�0032440�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Public and Private Tags ========================================= "tag1" tag ---------- * definition_2 "tag2" tag ---------- * definition_2 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml�������0000664�0000000�0000000�00000001444�13247321071�0032425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container> <tag name="tag1"> <definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> </definition> </tag> <tag name="tag2"> <definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> </definition> </tag> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.json����������0000664�0000000�0000000�00000000073�13247321071�0031666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "function", "name": "array_key_exists" } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md������������0000664�0000000�0000000�00000000057�13247321071�0031317�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `function` - Name: `array_key_exists` ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt�����������0000664�0000000�0000000�00000000022�13247321071�0031526�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������array_key_exists()��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.xml�����������0000664�0000000�0000000�00000000133�13247321071�0031512�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="function" name="array_key_exists"/> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.json����������0000664�0000000�0000000�00000000247�13247321071�0031672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "function", "name": "staticMethod", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass", "static": true } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md������������0000664�0000000�0000000�00000000212�13247321071�0031311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` - Static: yes ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt�����������0000664�0000000�0000000�00000000125�13247321071�0031533�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.xml�����������0000664�0000000�0000000�00000000263�13247321071�0031517�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="function" name="staticMethod" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass" static="true"/> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.json����������0000664�0000000�0000000�00000000215�13247321071�0031666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "function", "name": "method", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass" } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md������������0000664�0000000�0000000�00000000166�13247321071�0031322�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `function` - Name: `method` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt�����������0000664�0000000�0000000�00000000117�13247321071�0031535�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::method()�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.xml�����������0000664�0000000�0000000�00000000237�13247321071�0031521�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="function" name="method" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass"/> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.json����������0000664�0000000�0000000�00000000247�13247321071�0031674�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "function", "name": "staticMethod", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass", "static": true } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md������������0000664�0000000�0000000�00000000212�13247321071�0031313�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` - Static: yes ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt�����������0000664�0000000�0000000�00000000125�13247321071�0031535�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.xml�����������0000664�0000000�0000000�00000000263�13247321071�0031521�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="function" name="staticMethod" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass" static="true"/> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.json����������0000664�0000000�0000000�00000000303�13247321071�0031666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "function", "name": "staticMethod", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass", "static": true, "parent": true } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md������������0000664�0000000�0000000�00000000240�13247321071�0031315�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass` - Static: yes - Parent: yes ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt�����������0000664�0000000�0000000�00000000145�13247321071�0031540�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass::parent::staticMethod()���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.xml�����������0000664�0000000�0000000�00000000311�13247321071�0031514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="function" name="staticMethod" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass" static="true" parent="true"/> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.json����������0000664�0000000�0000000�00000000032�13247321071�0031666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "closure" } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md������������0000664�0000000�0000000�00000000023�13247321071�0031315�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `closure` �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt�����������0000664�0000000�0000000�00000000012�13247321071�0031532�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������\Closure()����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.xml�����������0000664�0000000�0000000�00000000102�13247321071�0031513�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="closure"/> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.json����������0000664�0000000�0000000�00000000164�13247321071�0031675�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "type": "object", "name": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass" } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md������������0000664�0000000�0000000�00000000142�13247321071�0031320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ - Type: `object` - Name: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt�����������0000664�0000000�0000000�00000000121�13247321071�0031534�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke()�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.xml�����������0000664�0000000�0000000�00000000216�13247321071�0031522�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <callable type="object" name="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass"/> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json��������0000664�0000000�0000000�00000000473�13247321071�0032263�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md����������0000664�0000000�0000000�00000000325�13247321071�0031706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get` �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt���������0000664�0000000�0000000�00000001445�13247321071�0032131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ---------------- -----------------------------  Option   Value  ---------------- ----------------------------- Service ID - Class Full\Qualified\Class1 Tags - Public yes Synthetic no Lazy yes Shared yes Abstract yes Autowired no Autoconfigured no Factory Class Full\Qualified\FactoryClass Factory Method get ---------------- ----------------------------- ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml���������0000664�0000000�0000000�00000000431�13247321071�0032104�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> </definition> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json��������0000664�0000000�0000000�00000001322�13247321071�0032256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ], "tags": [ { "name": "tag1", "parameters": { "attr1": "val1", "attr2": "val2" } }, { "name": "tag1", "parameters": { "attr3": "val3" } }, { "name": "tag2", "parameters": [] } ] } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md����������0000664�0000000�0000000�00000000525�13247321071�0031711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` - Tag: `tag1` - Attr1: val1 - Attr2: val2 - Tag: `tag1` - Attr3: val3 - Tag: `tag2` ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt���������0000664�0000000�0000000�00000002373�13247321071�0032133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ----------------- ---------------------------------  Option   Value  ----------------- --------------------------------- Service ID - Class Full\Qualified\Class2  Tags tag1 (attr1: val1, attr2: val2)   tag1 (attr3: val3)   tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autoconfigured no Required File /path/to/file Factory Service factory.service Factory Method get ----------------- --------------------------------- ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml���������0000664�0000000�0000000�00000001113�13247321071�0032103�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <definition class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> <tags> <tag name="tag1"> <parameter name="attr1">val1</parameter> <parameter name="attr2">val2</parameter> </tag> <tag name="tag1"> <parameter name="attr3">val3</parameter> </tag> <tag name="tag2"/> </tags> </definition> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_1.json�������������������������������������������������������������������������0000664�0000000�0000000�00000003130�13247321071�0034262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������{ "class": "Full\\Qualified\\Class1", "public": true, "synthetic": false, "lazy": true, "shared": true, "abstract": true, "autowire": false, "autoconfigure": false, "arguments": [ { "type": "service", "id": "definition2" }, "%parameter%", { "class": "inline_service", "public": false, "synthetic": false, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "arguments": [ "arg1", "arg2" ], "file": null, "tags": [] }, [ "foo", { "type": "service", "id": "definition2" }, { "class": "inline_service", "public": false, "synthetic": false, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "arguments": [], "file": null, "tags": [] } ], [ { "type": "service", "id": "definition_1" }, { "type": "service", "id": "definition_2" } ] ], "file": null, "factory_class": "Full\\Qualified\\FactoryClass", "factory_method": "get", "tags": [] } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.md0000664�0000000�0000000�00000000345�13247321071�0033775�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Class: `Full\Qualified\Class1` - Public: yes - Synthetic: no - Lazy: yes - Shared: yes - Abstract: yes - Autowired: no - Autoconfigured: no - Arguments: yes - Factory Class: `Full\Qualified\FactoryClass` - Factory Method: `get`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_1.txt��������������������������������������������������������������������������0000664�0000000�0000000�00000002332�13247321071�0034133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� ---------------- -----------------------------  Option   Value  ---------------- ----------------------------- Service ID - Class Full\Qualified\Class1 Tags - Public yes Synthetic no Lazy yes Shared yes Abstract yes Autowired no Autoconfigured no Factory Class Full\Qualified\FactoryClass Factory Method get  Arguments Service(definition2)   %parameter%   Inlined Service   Array (3 element(s))   Iterator (2 element(s)) ---------------- ----------------------------- ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_1.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000002114�13247321071�0034112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> <factory class="Full\Qualified\FactoryClass" method="get"/> <argument type="service" id="definition2"/> <argument>%parameter%</argument> <argument> <definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""> <argument>arg1</argument> <argument>arg2</argument> </definition> </argument> <argument type="collection"> <argument>foo</argument> <argument type="service" id="definition2"/> <argument> <definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/> </argument> </argument> <argument type="iterator"> <argument type="service" id="definition_1"/> <argument type="service" id="definition_2"/> </argument> </definition> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_2.json�������������������������������������������������������������������������0000664�0000000�0000000�00000001347�13247321071�0034273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������{ "class": "Full\\Qualified\\Class2", "public": false, "synthetic": true, "lazy": false, "shared": true, "abstract": false, "autowire": false, "autoconfigure": false, "arguments": [], "file": "\/path\/to\/file", "factory_service": "factory.service", "factory_method": "get", "calls": [ "setMailer" ], "tags": [ { "name": "tag1", "parameters": { "attr1": "val1", "attr2": "val2" } }, { "name": "tag1", "parameters": { "attr3": "val3" } }, { "name": "tag2", "parameters": [] } ] } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.md0000664�0000000�0000000�00000000544�13247321071�0033777�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Class: `Full\Qualified\Class2` - Public: no - Synthetic: yes - Lazy: no - Shared: yes - Abstract: no - Autowired: no - Autoconfigured: no - Arguments: no - File: `/path/to/file` - Factory Service: `factory.service` - Factory Method: `get` - Call: `setMailer` - Tag: `tag1` - Attr1: val1 - Attr2: val2 - Tag: `tag1` - Attr3: val3 - Tag: `tag2`������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_2.txt��������������������������������������������������������������������������0000664�0000000�0000000�00000002373�13247321071�0034141�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� ----------------- ---------------------------------  Option   Value  ----------------- --------------------------------- Service ID - Class Full\Qualified\Class2  Tags tag1 (attr1: val1, attr2: val2)   tag1 (attr3: val3)   tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autoconfigured no Required File /path/to/file Factory Service factory.service Factory Method get ----------------- --------------------------------- ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������definition_arguments_2.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000001113�13247321071�0034111�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <definition class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file"> <factory service="factory.service" method="get"/> <calls> <call method="setMailer"/> </calls> <tags> <tag name="tag1"> <parameter name="attr1">val1</parameter> <parameter name="attr2">val2</parameter> </tag> <tag name="tag1"> <parameter name="attr3">val3</parameter> </tag> <tag name="tag2"/> </tags> </definition> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_event1.json����������������������������������������������������������������������0000664�0000000�0000000�00000000246�13247321071�0034663�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������[ { "type": "function", "name": "global_function", "priority": 255 }, { "type": "closure", "priority": -1 } ] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_event1.md������������������������������������������������������������������������0000664�0000000�0000000�00000000313�13247321071�0034305�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������# Registered listeners for event `event1` ordered by descending priority ## Listener 1 - Type: `function` - Name: `global_function` - Priority: `255` ## Listener 2 - Type: `closure` - Priority: `-1` ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_event1.txt�����������������������������������������������������������������������0000664�0000000�0000000�00000000573�13247321071�0034534�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� Registered Listeners for "event1" Event ======================================= ------- ------------------- ----------  Order   Callable   Priority  ------- ------------------- ---------- #1 global_function() 255 #2 \Closure() -1 ------- ------------------- ---------- �������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_event1.xml�����������������������������������������������������������������������0000664�0000000�0000000�00000000275�13247321071�0034514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <event-dispatcher> <callable type="function" name="global_function" priority="255"/> <callable type="closure" priority="-1"/> </event-dispatcher> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_events.json����������������������������������������������������������������������0000664�0000000�0000000�00000000646�13247321071�0034771�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������{ "event1": [ { "type": "function", "name": "global_function", "priority": 255 }, { "type": "closure", "priority": -1 } ], "event2": [ { "type": "object", "name": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass", "priority": 0 } ] } ������������������������������������������������������������������������������������������event_dispatcher_1_events.md������������������������������������������������������������������������0000664�0000000�0000000�00000000463�13247321071�0034415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������# Registered listeners ## event1 ### Listener 1 - Type: `function` - Name: `global_function` - Priority: `255` ### Listener 2 - Type: `closure` - Priority: `-1` ## event2 ### Listener 1 - Type: `object` - Name: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` - Priority: `0` �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_events.txt�����������������������������������������������������������������������0000664�0000000�0000000�00000002011�13247321071�0034623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor��������������������������������������������������������������������������������������������� Registered Listeners Grouped by Event ===================================== "event1" event -------------- ------- ------------------- ----------  Order   Callable   Priority  ------- ------------------- ---------- #1 global_function() 255 #2 \Closure() -1 ------- ------------------- ---------- "event2" event -------------- ------- ----------------------------------------------------------------------------------- ----------  Order   Callable   Priority  ------- ----------------------------------------------------------------------------------- ---------- #1 Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() 0 ------- ----------------------------------------------------------------------------------- ---------- �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������event_dispatcher_1_events.xml�����������������������������������������������������������������������0000664�0000000�0000000�00000000577�13247321071�0034623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor���������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <event-dispatcher> <event name="event1"> <callable type="function" name="global_function" priority="255"/> <callable type="closure" priority="-1"/> </event> <event name="event2"> <callable type="object" name="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass" priority="0"/> </event> </event-dispatcher> ���������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.json�����������0000664�0000000�0000000�00000000043�13247321071�0031664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "database_name": "symfony" } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md�������������0000664�0000000�0000000�00000000044�13247321071�0031314�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������database_name ============= symfony��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt������������0000664�0000000�0000000�00000000241�13247321071�0031532�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ --------------- ---------  Parameter   Value  --------------- --------- database_name symfony --------------- --------- ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.xml������������0000664�0000000�0000000�00000000132�13247321071�0031512�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <parameter key="database_name">symfony</parameter> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.json��������0000664�0000000�0000000�00000000220�13247321071�0032264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "array": [ 12, "Hello world!", true ], "boolean": true, "integer": 12, "string": "Hello world!" } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md����������0000664�0000000�0000000�00000000221�13247321071�0031714�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Container parameters ==================== - `array`: `[12,"Hello world!",true]` - `boolean`: `true` - `integer`: `12` - `string`: `Hello world!`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt���������0000664�0000000�0000000�00000000655�13247321071�0032146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Container Parameters ============================ ----------- --------------------------  Parameter   Value  ----------- -------------------------- array [12,"Hello world!",true] boolean true integer 12 string Hello world! ----------- -------------------------- �����������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.xml���������0000664�0000000�0000000�00000000411�13247321071�0032115�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <parameters> <parameter key="array">[12,"Hello world!",true]</parameter> <parameter key="boolean">true</parameter> <parameter key="integer">12</parameter> <parameter key="string">Hello world!</parameter> </parameters> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json�������������0000664�0000000�0000000�00000001002�13247321071�0031256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "path": "\/hello\/{name}", "pathRegex": "#PATH_REGEX#", "host": "localhost", "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "GET|HEAD", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": { "name": "Joseph" }, "requirements": { "name": "[a-z]+" }, "options": { "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", "opt1": "val1", "opt2": "val2" } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md���������������0000664�0000000�0000000�00000000613�13247321071�0030714�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Path: /hello/{name} - Path Regex: #PATH_REGEX# - Host: localhost - Host Regex: #HOST_REGEX# - Scheme: http|https - Method: GET|HEAD - Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: - `name`: Joseph - Requirements: - `name`: [a-z]+ - Options: - `compiler_class`: Symfony\Component\Routing\RouteCompiler - `opt1`: val1 - `opt2`: val2 ���������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt��������������0000664�0000000�0000000�00000003031�13247321071�0031130�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������+--------------+-------------------------------------------------------------------+ | Property | Value | +--------------+-------------------------------------------------------------------+ | Route Name | | | Path | /hello/{name} | | Path Regex | #PATH_REGEX# | | Host | localhost | | Host Regex | #HOST_REGEX# | | Scheme | http|https | | Method | GET|HEAD | | Requirements | name: [a-z]+ | | Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | | Defaults | name: Joseph | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | opt1: val1 | | | opt2: val2 | +--------------+-------------------------------------------------------------------+ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml��������������0000664�0000000�0000000�00000001217�13247321071�0031115�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub"> <path regex="#PATH_REGEX#">/hello/{name}</path> <host regex="#HOST_REGEX#">localhost</host> <scheme>http</scheme> <scheme>https</scheme> <method>GET</method> <method>HEAD</method> <defaults> <default key="name">Joseph</default> </defaults> <requirements> <requirement key="name">[a-z]+</requirement> </requirements> <options> <option key="compiler_class">Symfony\Component\Routing\RouteCompiler</option> <option key="opt1">val1</option> <option key="opt2">val2</option> </options> </route> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json�������������0000664�0000000�0000000�00000000713�13247321071�0031267�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "path": "\/name\/add", "pathRegex": "#PATH_REGEX#", "host": "localhost", "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "PUT|POST", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": [], "requirements": "NO CUSTOM", "options": { "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", "opt1": "val1", "opt2": "val2" } } �����������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md���������������0000664�0000000�0000000�00000000552�13247321071�0030717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������- Path: /name/add - Path Regex: #PATH_REGEX# - Host: localhost - Host Regex: #HOST_REGEX# - Scheme: http|https - Method: PUT|POST - Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: NONE - Requirements: NO CUSTOM - Options: - `compiler_class`: Symfony\Component\Routing\RouteCompiler - `opt1`: val1 - `opt2`: val2 ������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt��������������0000664�0000000�0000000�00000003031�13247321071�0031131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������+--------------+-------------------------------------------------------------------+ | Property | Value | +--------------+-------------------------------------------------------------------+ | Route Name | | | Path | /name/add | | Path Regex | #PATH_REGEX# | | Host | localhost | | Host Regex | #HOST_REGEX# | | Scheme | http|https | | Method | PUT|POST | | Requirements | NO CUSTOM | | Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | | Defaults | NONE | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | opt1: val1 | | | opt2: val2 | +--------------+-------------------------------------------------------------------+ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml��������������0000664�0000000�0000000�00000000763�13247321071�0031123�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub"> <path regex="#PATH_REGEX#">/name/add</path> <host regex="#HOST_REGEX#">localhost</host> <scheme>http</scheme> <scheme>https</scheme> <method>PUT</method> <method>POST</method> <options> <option key="compiler_class">Symfony\Component\Routing\RouteCompiler</option> <option key="opt1">val1</option> <option key="opt2">val2</option> </options> </route> �������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json��0000664�0000000�0000000�00000002170�13247321071�0033500�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "route_1": { "path": "\/hello\/{name}", "pathRegex": "#PATH_REGEX#", "host": "localhost", "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "GET|HEAD", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": { "name": "Joseph" }, "requirements": { "name": "[a-z]+" }, "options": { "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", "opt1": "val1", "opt2": "val2" } }, "route_2": { "path": "\/name\/add", "pathRegex": "#PATH_REGEX#", "host": "localhost", "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "PUT|POST", "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": [], "requirements": "NO CUSTOM", "options": { "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", "opt1": "val1", "opt2": "val2" } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md����0000664�0000000�0000000�00000001432�13247321071�0033127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������route_1 ------- - Path: /hello/{name} - Path Regex: #PATH_REGEX# - Host: localhost - Host Regex: #HOST_REGEX# - Scheme: http|https - Method: GET|HEAD - Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: - `name`: Joseph - Requirements: - `name`: [a-z]+ - Options: - `compiler_class`: Symfony\Component\Routing\RouteCompiler - `opt1`: val1 - `opt2`: val2 route_2 ------- - Path: /name/add - Path Regex: #PATH_REGEX# - Host: localhost - Host Regex: #HOST_REGEX# - Scheme: http|https - Method: PUT|POST - Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: NONE - Requirements: NO CUSTOM - Options: - `compiler_class`: Symfony\Component\Routing\RouteCompiler - `opt1`: val1 - `opt2`: val2 ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt���0000664�0000000�0000000�00000000663�13247321071�0033353�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ --------- ---------- ------------ ----------- ---------------  Name   Method   Scheme   Host   Path  --------- ---------- ------------ ----------- --------------- route_1 GET|HEAD http|https localhost /hello/{name} route_2 PUT|POST http|https localhost /name/add --------- ---------- ------------ ----------- --------------- �����������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml���0000664�0000000�0000000�00000002314�13247321071�0033327�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <routes> <route name="route_1" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub"> <path regex="#PATH_REGEX#">/hello/{name}</path> <host regex="#HOST_REGEX#">localhost</host> <scheme>http</scheme> <scheme>https</scheme> <method>GET</method> <method>HEAD</method> <defaults> <default key="name">Joseph</default> </defaults> <requirements> <requirement key="name">[a-z]+</requirement> </requirements> <options> <option key="compiler_class">Symfony\Component\Routing\RouteCompiler</option> <option key="opt1">val1</option> <option key="opt2">val2</option> </options> </route> <route name="route_2" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub"> <path regex="#PATH_REGEX#">/name/add</path> <host regex="#HOST_REGEX#">localhost</host> <scheme>http</scheme> <scheme>https</scheme> <method>PUT</method> <method>POST</method> <options> <option key="compiler_class">Symfony\Component\Routing\RouteCompiler</option> <option key="opt1">val1</option> <option key="opt2">val2</option> </options> </route> </routes> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/��������������������������0000775�0000000�0000000�00000000000�13247321071�0026650�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/���������������0000775�0000000�0000000�00000000000�13247321071�0030654�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views/���������0000775�0000000�0000000�00000000000�13247321071�0032011�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������base.format.engine����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0035310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views�����������������������������������������������������������������������������controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034115�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views�����������������������������������������������������������������������������custom.format.engine��������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0040073�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views/controller������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/translations/�������������0000775�0000000�0000000�00000000000�13247321071�0031371�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������messages.fr.yml�������������������������������������������������������������������������������������0000664�0000000�0000000�00000000024�13247321071�0034246�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/translations���������������������������������������������������������������������������������folder: répertoire ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/��������������������0000775�0000000�0000000�00000000000�13247321071�0030005�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������resource.format.engine������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0034221�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views����������������������������������������������������������������������������������������this.is.a.template.format.engine��������������������������������������������������������������������0000664�0000000�0000000�00000000000�13247321071�0036004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views����������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php0000664�0000000�0000000�00000004031�13247321071�0034015�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������This template is used for translation message extraction tests <?php echo $view['translator']->trans('single-quoted key') ?> <?php echo $view['translator']->trans('double-quoted key') ?> <?php echo $view['translator']->trans(<<<'EOF' heredoc key EOF ) ?> <?php echo $view['translator']->trans(<<<'EOF' nowdoc key EOF ) ?> <?php echo $view['translator']->trans( "double-quoted key with whitespace and escaped \$\n\" sequences" ) ?> <?php echo $view['translator']->trans( 'single-quoted key with whitespace and nonescaped \$\n\' sequences' ) ?> <?php echo $view['translator']->trans(<<<EOF heredoc key with whitespace and escaped \$\n sequences EOF ) ?> <?php echo $view['translator']->trans(<<<'EOF' nowdoc key with whitespace and nonescaped \$\n sequences EOF ) ?> <?php echo $view['translator']->trans('single-quoted key with "quote mark at the end"') ?> <?php echo $view['translator']->transChoice( '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', 10, array('%count%' => 10) ) ?> <?php echo $view['translator']->trans('other-domain-test-no-params-short-array', array(), 'not_messages'); ?> <?php echo $view['translator']->trans('other-domain-test-no-params-long-array', array(), 'not_messages'); ?> <?php echo $view['translator']->trans('other-domain-test-params-short-array', array('foo' => 'bar'), 'not_messages'); ?> <?php echo $view['translator']->trans('other-domain-test-params-long-array', array('foo' => 'bar'), 'not_messages'); ?> <?php echo $view['translator']->transChoice('other-domain-test-trans-choice-short-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?> <?php echo $view['translator']->transChoice('other-domain-test-trans-choice-long-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?> <?php echo $view['translator']->trans('typecast', array('a' => (int) '123'), 'not_messages'); ?> <?php echo $view['translator']->transChoice('msg1', 10 + 1, array(), 'not_messages'); ?> <?php echo $view['translator']->transChoice('msg2', ceil(4.5), array(), 'not_messages'); ?> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/����������������������0000775�0000000�0000000�00000000000�13247321071�0027513�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/Author.php������������0000664�0000000�0000000�00000000164�13247321071�0031467�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization; class Author { public $gender; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/Person.php������������0000664�0000000�0000000�00000000164�13247321071�0031473�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization; class Person { public $gender; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/Resources/������������0000775�0000000�0000000�00000000000�13247321071�0031465�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/Resources/author.yml��0000664�0000000�0000000�00000000215�13247321071�0033510�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author: attributes: gender: groups: ['group1', 'group2'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Serialization/Resources/person.xml��0000664�0000000�0000000�00000001062�13247321071�0033514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <serializer xmlns="http://symfony.com/schema/dic/serializer-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd" > <class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Person"> <attribute name="gender"> <group>group1</group> <group>group2</group> </attribute> </class> </serializer> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache/�����������������0000775�0000000�0000000�00000000000�13247321071�0030375�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������templates-empty.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000030�13247321071�0034152�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache�������������������������������������������������������������������������������������<?php return array ( ); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache/templates.php����0000664�0000000�0000000�00000000156�13247321071�0033106�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php return array ( 'bundle:controller:name.format.engine' => __DIR__.'/../path/to/template.html.twig', ); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/�������������������������0000775�0000000�0000000�00000000000�13247321071�0026747�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Fabpot/������������������0000775�0000000�0000000�00000000000�13247321071�0030162�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle/��������0000775�0000000�0000000�00000000000�13247321071�0032037�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034103�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle����������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000617�13247321071�0040250�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle/Controller�����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Fabpot\FooBundle\Controller; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } �����������������������������������������������������������������������������������������������������������������FabpotFooBundle.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000001052�13247321071�0035500�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle����������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Fabpot\FooBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class FabpotFooBundle extends Bundle { /** * {@inheritdoc} */ public function getParent() { return 'SensioFooBundle'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/���������������0000775�0000000�0000000�00000000000�13247321071�0030624�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller/����0000775�0000000�0000000�00000000000�13247321071�0032747�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000610�13247321071�0037026�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\FooBundle\Controller; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } ������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller/Sub/0000775�0000000�0000000�00000000000�13247321071�0033500�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000614�13247321071�0037563�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller/Sub��������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\FooBundle\Controller\Sub; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } ��������������������������������������������������������������������������������������������������������������������Test/�����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0033607�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000615�13247321071�0037752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/Controller/Test�������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\FooBundle\Controller\Test; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } �������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/FooBundle/FooBundle.php��0000664�0000000�0000000�00000000652�13247321071�0033215�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\FooBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class FooBundle extends Bundle { } ��������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/������������������0000775�0000000�0000000�00000000000�13247321071�0030207�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/��������������0000775�0000000�0000000�00000000000�13247321071�0030731�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/����0000775�0000000�0000000�00000000000�13247321071�0032606�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034652�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000623�13247321071�0041014�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/Controller�������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Sensio\Cms\FooBundle\Controller; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } �������������������������������������������������������������������������������������������������������������SensioCmsFooBundle.php������������������������������������������������������������������������������0000664�0000000�0000000�00000000676�13247321071�0036752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Sensio\Cms\FooBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class SensioCmsFooBundle extends Bundle { } ������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/FooBundle/��������0000775�0000000�0000000�00000000000�13247321071�0032064�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034130�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/FooBundle����������������������������������������������������������������������������DefaultController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000617�13247321071�0040275�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/FooBundle/Controller�����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Sensio\FooBundle\Controller; /** * DefaultController. * * @author Fabien Potencier <fabien@symfony.com> */ class DefaultController { } �����������������������������������������������������������������������������������������������������������������SensioFooBundle.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000667�13247321071�0035565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/FooBundle����������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace TestBundle\Sensio\FooBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class SensioFooBundle extends Bundle { } �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/�������������������������0000775�0000000�0000000�00000000000�13247321071�0026770�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php��������������0000664�0000000�0000000�00000000224�13247321071�0031062�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation; class Article implements NotExistingInterface { public $category; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Author.php���������������0000664�0000000�0000000�00000000161�13247321071�0030741�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation; class Author { public $gender; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Category.php�������������0000664�0000000�0000000�00000000413�13247321071�0031254�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation; use Symfony\Component\Validator\Constraints as Assert; class Category { const NAME_PATTERN = '/\w+/'; public $id; /** * @Assert\Type("string") */ public $name; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Person.php���������������0000664�0000000�0000000�00000000161�13247321071�0030745�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation; class Person { public $gender; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Resources/���������������0000775�0000000�0000000�00000000000�13247321071�0030742�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Resources/author.yml�����0000664�0000000�0000000�00000000273�13247321071�0032771�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Author: properties: gender: - Choice: { choices: [male, female, other], message: Choose a valid gender. } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Resources/categories.yml�0000664�0000000�0000000�00000000362�13247321071�0033613�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Category: properties: id: - Type: int Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\SubCategory: properties: id: - Type: int ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Resources/person.xml�����0000664�0000000�0000000�00000002344�13247321071�0032775�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8" ?> <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> <class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Person"> <property name="gender"> <constraint name="Choice"> <option name="choices"> <value>male</value> <value>female</value> <value>other</value> </option> <option name="message">Choose a valid gender.</option> </constraint> </property> </class> <class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Article"> <property name="category"> <constraint name="Choice"> <option name="choices"> <value>other</value> </option> <option name="message">This should be ignored.</option> </constraint> </property> </class> </constraint-mapping> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/SubCategory.php����������0000664�0000000�0000000�00000000343�13247321071�0031730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation; // Missing "use" for Assert\Type is on purpose class SubCategory extends Category { /** * @Assert\Type("string") */ public $main; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/WarmedClass.php���������������������0000664�0000000�0000000�00000000155�13247321071�0027615�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; class WarmedClass extends DeclaredClass { } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php�����������������������0000664�0000000�0000000�00000000217�13247321071�0027405�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php return array( 'bundle:controller:name.format.engine' => __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine', ); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025167�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php�������0000664�0000000�0000000�00000002373�13247321071�0032526�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; class AnnotatedControllerTest extends WebTestCase { /** * @dataProvider getRoutes */ public function testAnnotatedController($path, $expectedValue) { $client = $this->createClient(array('test_case' => 'AnnotatedController', 'root_config' => 'config.yml')); $client->request('GET', '/annotated'.$path); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertSame($expectedValue, $client->getResponse()->getContent()); } public function getRoutes() { return array( array('/null_request', 'Symfony\Component\HttpFoundation\Request'), array('/null_argument', ''), array('/null_argument_with_route_param', ''), array('/null_argument_with_route_param/value', 'value'), array('/argument_with_route_param_and_default', 'value'), array('/argument_with_route_param_and_default/custom', 'custom'), ); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php�����������0000664�0000000�0000000�00000007155�13247321071�0031725�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\CachedReader; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; class AutowiringTypesTest extends WebTestCase { public function testAnnotationReaderAutowiring() { static::bootKernel(array('root_config' => 'no_annotations_cache.yml', 'environment' => 'no_annotations_cache')); $container = static::$kernel->getContainer(); $annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader(); $this->assertInstanceOf(AnnotationReader::class, $annotationReader); } public function testCachedAnnotationReaderAutowiring() { static::bootKernel(); $container = static::$kernel->getContainer(); $annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader(); $this->assertInstanceOf(CachedReader::class, $annotationReader); } public function testTemplatingAutowiring() { static::bootKernel(); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine()); $this->assertInstanceOf(ComponentEngineInterface::class, $autowiredServices->getEngine()); } public function testEventDispatcherAutowiring() { static::bootKernel(array('debug' => false)); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); if (class_exists(ContainerAwareEventDispatcher::class)) { $this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled'); } else { $this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled'); } static::bootKernel(array('debug' => true)); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled'); } public function testCacheAutowiring() { static::bootKernel(); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool()); } protected static function createKernel(array $options = array()) { return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026400�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/����������������0000775�0000000�0000000�00000000000�13247321071�0030451�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/0000775�0000000�0000000�00000000000�13247321071�0033626�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AutowiredServices.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000003226�13247321071�0037732�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes��������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes; use Doctrine\Common\Annotations\Reader; use Psr\Cache\CacheItemPoolInterface; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; use Symfony\Component\Templating\EngineInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; class AutowiredServices { private $annotationReader; private $frameworkBundleEngine; private $engine; private $dispatcher; private $cachePool; public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) { $this->annotationReader = $annotationReader; $this->frameworkBundleEngine = $frameworkBundleEngine; $this->engine = $engine; $this->dispatcher = $dispatcher; $this->cachePool = $cachePool; } public function getAnnotationReader() { return $this->annotationReader; } public function getFrameworkBundleEngine() { return $this->frameworkBundleEngine; } public function getEngine() { return $this->engine; } public function getDispatcher() { return $this->dispatcher; } public function getCachePool() { return $this->cachePool; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/�����0000775�0000000�0000000�00000000000�13247321071�0032574�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AnnotatedController.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000002636�13247321071�0037216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class AnnotatedController { /** * @Route("/null_request", name="null_request") */ public function requestDefaultNullAction(Request $request = null) { return new Response($request ? get_class($request) : null); } /** * @Route("/null_argument", name="null_argument") */ public function argumentDefaultNullWithoutRouteParamAction($value = null) { return new Response($value); } /** * @Route("/null_argument_with_route_param/{value}", name="null_argument_with_route_param") */ public function argumentDefaultNullWithRouteParamAction($value = null) { return new Response($value); } /** * @Route("/argument_with_route_param_and_default/{value}", defaults={"value": "value"}, name="argument_with_route_param_and_default") */ public function argumentWithoutDefaultWithRouteParamAndDefaultAction($value) { return new Response($value); } } ��������������������������������������������������������������������������������������������������FragmentController.php������������������������������������������������������������������������������0000664�0000000�0000000�00000002607�13247321071�0037042�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class FragmentController implements ContainerAwareInterface { use ContainerAwareTrait; public function indexAction(Request $request) { return $this->container->get('templating')->renderResponse('fragment.html.php', array('bar' => new Bar())); } public function inlinedAction($options, $_format) { return new Response($options['bar']->getBar().' '.$_format); } public function customFormatAction($_format) { return new Response($_format); } public function customLocaleAction(Request $request) { return new Response($request->getLocale()); } public function forwardLocaleAction(Request $request) { return new Response($request->getLocale()); } } class Bar { private $bar = 'bar'; public function getBar() { return $this->bar; } } �������������������������������������������������������������������������������������������������������������������������ProfilerController.php������������������������������������������������������������������������������0000664�0000000�0000000�00000001253�13247321071�0037055�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; class ProfilerController implements ContainerAwareInterface { use ContainerAwareTrait; public function indexAction() { return new Response('Hello'); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SessionController.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000004062�13247321071�0036717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; class SessionController implements ContainerAwareInterface { use ContainerAwareTrait; public function welcomeAction(Request $request, $name = null) { $session = $request->getSession(); // new session case if (!$session->has('name')) { if (!$name) { return new Response('You are new here and gave no name.'); } // remember name $session->set('name', $name); return new Response(sprintf('Hello %s, nice to meet you.', $name)); } // existing session $name = $session->get('name'); return new Response(sprintf('Welcome back %s, nice to meet you.', $name)); } public function logoutAction(Request $request) { $request->getSession()->invalidate(); return new Response('Session cleared.'); } public function setFlashAction(Request $request, $message) { $session = $request->getSession(); $session->getFlashBag()->set('notice', $message); return new RedirectResponse($this->container->get('router')->generate('session_showflash')); } public function showFlashAction(Request $request) { $session = $request->getSession(); if ($session->getFlashBag()->has('notice')) { list($output) = $session->getFlashBag()->get('notice'); } else { $output = 'No flash was set.'; } return new Response($output); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SubRequestController.php����������������������������������������������������������������������������0000664�0000000�0000000�00000004620�13247321071�0037376�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; class SubRequestController implements ContainerAwareInterface { use ContainerAwareTrait; public function indexAction($handler) { $errorUrl = $this->generateUrl('subrequest_fragment_error', array('_locale' => 'fr', '_format' => 'json')); $altUrl = $this->generateUrl('subrequest_fragment', array('_locale' => 'fr', '_format' => 'json')); // simulates a failure during the rendering of a fragment... // should render fr/json $content = $handler->render($errorUrl, 'inline', array('alt' => $altUrl)); // ...to check that the FragmentListener still references the right Request // when rendering another fragment after the error occurred // should render en/html instead of fr/json $content .= $handler->render(new ControllerReference('TestBundle:SubRequest:fragment')); // forces the LocaleListener to set fr for the locale... // should render fr/json $content .= $handler->render($altUrl); // ...and check that after the rendering, the original Request is back // and en is used as a locale // should use en/html instead of fr/json $content .= '--'.$this->generateUrl('subrequest_fragment'); // The RouterListener is also tested as if it does not keep the right // Request in the context, a 301 would be generated return new Response($content); } public function fragmentAction(Request $request) { return new Response('--'.$request->getLocale().'/'.$request->getRequestFormat()); } public function fragmentErrorAction() { throw new \RuntimeException('error'); } protected function generateUrl($name, $arguments = array()) { return $this->container->get('router')->generate($name, $arguments); } } ����������������������������������������������������������������������������������������������������������������SubRequestServiceResolutionController.php�����������������������������������������������������������0000664�0000000�0000000�00000002334�13247321071�0043003�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller�������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; class SubRequestServiceResolutionController implements ContainerAwareInterface { use ContainerAwareTrait; public function indexAction() { $request = $this->container->get('request_stack')->getCurrentRequest(); $path['_forwarded'] = $request->attributes; $path['_controller'] = 'TestBundle:SubRequestServiceResolution:fragment'; $subRequest = $request->duplicate(array(), null, $path); return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } public function fragmentAction(LoggerInterface $logger) { return new Response('---'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������DependencyInjection/��������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034313�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle������������������������������������������������������������������������������������AnnotationReaderPass.php����������������������������������������������������������������������������0000664�0000000�0000000�00000001320�13247321071�0041104�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; class AnnotationReaderPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { // simulate using "annotation_reader" in a compiler pass $container->get('test.annotation_reader'); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035520�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection����������������������������������������������������������������CustomConfig.php������������������������������������������������������������������������������������0000664�0000000�0000000�00000001447�13247321071�0040637�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Config���������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config; class CustomConfig { public function addConfiguration($rootNode) { $rootNode ->children() ->scalarNode('custom')->end() ->arrayNode('array') ->children() ->scalarNode('child1')->end() ->scalarNode('child2')->end() ->end() ->end() ->end() ->end() ; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Configuration.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001657�13247321071�0037644�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; class Configuration implements ConfigurationInterface { private $customConfig; public function __construct($customConfig = null) { $this->customConfig = $customConfig; } public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('test'); if ($this->customConfig) { $this->customConfig->addConfiguration($rootNode); } return $treeBuilder; } } ���������������������������������������������������������������������������������TestExtension.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000002776�13247321071�0037654�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; class TestExtension extends Extension implements PrependExtensionInterface { private $customConfig; /** * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $container->setAlias('test.annotation_reader', new Alias('annotation_reader', true)); } /** * {@inheritdoc} */ public function prepend(ContainerBuilder $container) { $container->prependExtensionConfig('test', array('custom' => 'foo')); } /** * {@inheritdoc} */ public function getConfiguration(array $config, ContainerBuilder $container) { return new Configuration($this->customConfig); } public function setCustomConfig($customConfig) { $this->customConfig = $customConfig; } } ��symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/������0000775�0000000�0000000�00000000000�13247321071�0032423�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0033611�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources��������������������������������������������������������������������������routing.yml�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000002743�13247321071�0036031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config�������������������������������������������������������������������session_welcome: path: /session defaults: { _controller: TestBundle:Session:welcome } session_welcome_name: path: /session/{name} defaults: { _controller: TestBundle:Session:welcome } session_logout: path: /session_logout defaults: { _controller: TestBundle:Session:logout} session_setflash: path: /session_setflash/{message} defaults: { _controller: TestBundle:Session:setFlash} session_showflash: path: /session_showflash defaults: { _controller: TestBundle:Session:showFlash} profiler: path: /profiler defaults: { _controller: TestBundle:Profiler:index } subrequest_index: path: /subrequest/{_locale}.{_format} defaults: { _controller: TestBundle:SubRequest:index, _format: "html" } schemes: [https] subrequest_fragment_error: path: /subrequest/fragment/error/{_locale}.{_format} defaults: { _controller: TestBundle:SubRequest:fragmentError, _format: "html" } schemes: [http] subrequest_fragment: path: /subrequest/fragment/{_locale}.{_format} defaults: { _controller: TestBundle:SubRequest:fragment, _format: "html" } schemes: [http] fragment_home: path: /fragment_home defaults: { _controller: TestBundle:Fragment:index, _format: txt } fragment_inlined: path: /fragment_inlined defaults: { _controller: TestBundle:Fragment:inlined } array_controller: path: /array_controller defaults: { _controller: [ArrayController, someAction] } �����������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php��0000664�0000000�0000000�00000002147�13247321071�0033237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig; class TestBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); /** @var $extension DependencyInjection\TestExtension */ $extension = $container->getExtension('test'); $extension->setCustomConfig(new CustomConfig()); $container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php�����0000664�0000000�0000000�00000010141�13247321071�0032640�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; /** * @group functional */ class CachePoolClearCommandTest extends WebTestCase { protected function setUp() { static::bootKernel(array('test_case' => 'CachePoolClear', 'root_config' => 'config.yml')); } public function testClearPrivatePool() { $tester = $this->createCommandTester(); $tester->execute(array('pools' => array('cache.private_pool')), array('decorated' => false)); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.private_pool', $tester->getDisplay()); $this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay()); } public function testClearPublicPool() { $tester = $this->createCommandTester(); $tester->execute(array('pools' => array('cache.public_pool')), array('decorated' => false)); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.public_pool', $tester->getDisplay()); $this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay()); } public function testClearPoolWithCustomClearer() { $tester = $this->createCommandTester(); $tester->execute(array('pools' => array('cache.pool_with_clearer')), array('decorated' => false)); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay()); $this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay()); } public function testCallClearer() { $tester = $this->createCommandTester(); $tester->execute(array('pools' => array('cache.app_clearer')), array('decorated' => false)); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Calling cache clearer: cache.app_clearer', $tester->getDisplay()); $this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay()); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException * @expectedExceptionMessage You have requested a non-existent service "unknown_pool" */ public function testClearUnexistingPool() { $this->createCommandTester() ->execute(array('pools' => array('unknown_pool')), array('decorated' => false)); } /** * @group legacy * @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand::__construct() expects an instance of "Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0. */ public function testLegacyClearCommand() { $application = new Application(static::$kernel); $application->add(new CachePoolClearCommand()); $tester = new CommandTester($application->find('cache:pool:clear')); $tester->execute(array('pools' => array())); $this->assertContains('Cache was successfully cleared', $tester->getDisplay()); } private function createCommandTester() { $container = static::$kernel->getContainer(); $application = new Application(static::$kernel); $application->add(new CachePoolClearCommand($container->get('cache.global_clearer'))); return new CommandTester($application->find('cache:pool:clear')); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php����������������0000664�0000000�0000000�00000006426�13247321071�0030570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; class CachePoolsTest extends WebTestCase { public function testCachePools() { $this->doTestCachePools(array(), AdapterInterface::class); } /** * @requires extension redis */ public function testRedisCachePools() { try { $this->doTestCachePools(array('root_config' => 'redis_config.yml', 'environment' => 'redis_cache'), RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); } catch (\PHPUnit_Framework_Error_Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); } catch (InvalidArgumentException $e) { if (0 !== strpos($e->getMessage(), 'Redis connection failed')) { throw $e; } $this->markTestSkipped($e->getMessage()); } } /** * @requires extension redis */ public function testRedisCustomCachePools() { try { $this->doTestCachePools(array('root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'), RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); } catch (\PHPUnit_Framework_Error_Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); } } private function doTestCachePools($options, $adapterClass) { static::bootKernel($options); $container = static::$kernel->getContainer(); $pool1 = $container->get('cache.pool1'); $this->assertInstanceOf($adapterClass, $pool1); $key = 'foobar'; $pool1->deleteItem($key); $item = $pool1->getItem($key); $this->assertFalse($item->isHit()); $item->set('baz'); $pool1->save($item); $item = $pool1->getItem($key); $this->assertTrue($item->isHit()); $pool2 = $container->get('cache.pool2'); $pool2->save($item); $container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir')); $item = $pool1->getItem($key); $this->assertFalse($item->isHit()); $item = $pool2->getItem($key); $this->assertTrue($item->isHit()); } protected static function createKernel(array $options = array()) { return parent::createKernel(array('test_case' => 'CachePools') + $options); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php��������0000664�0000000�0000000�00000004554�13247321071�0032223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Tester\CommandTester; /** * @group functional */ class ConfigDebugCommandTest extends WebTestCase { private $application; protected function setUp() { $kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml')); $this->application = new Application($kernel); $this->application->doRun(new ArrayInput(array()), new NullOutput()); } public function testDumpBundleName() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => 'TestBundle')); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('custom: foo', $tester->getDisplay()); } public function testDumpBundleOption() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => 'TestBundle', 'path' => 'custom')); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('foo', $tester->getDisplay()); } public function testParametersValuesAreResolved() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => 'framework')); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains("locale: '%env(LOCALE)%'", $tester->getDisplay()); $this->assertContains('secret: test', $tester->getDisplay()); } public function testDumpUndefinedBundleOption() { $tester = $this->createCommandTester(); $tester->execute(array('name' => 'TestBundle', 'path' => 'foo')); $this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay()); } /** * @return CommandTester */ private function createCommandTester() { $command = $this->application->find('debug:config'); return new CommandTester($command); } } ����������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php0000664�0000000�0000000�00000004530�13247321071�0033713�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Tester\CommandTester; /** * @group functional */ class ConfigDumpReferenceCommandTest extends WebTestCase { private $application; protected function setUp() { $kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml')); $this->application = new Application($kernel); $this->application->doRun(new ArrayInput(array()), new NullOutput()); } public function testDumpBundleName() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('name' => 'TestBundle')); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('test:', $tester->getDisplay()); $this->assertContains(' custom:', $tester->getDisplay()); } public function testDumpAtPath() { $tester = $this->createCommandTester(); $ret = $tester->execute(array( 'name' => 'test', 'path' => 'array', )); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(<<<'EOL' # Default configuration for extension with alias: "test" at path "array" array: child1: ~ child2: ~ EOL , $tester->getDisplay(true)); } public function testDumpAtPathXml() { $tester = $this->createCommandTester(); $ret = $tester->execute(array( 'name' => 'test', 'path' => 'array', '--format' => 'xml', )); $this->assertSame(1, $ret); $this->assertContains('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay()); } /** * @return CommandTester */ private function createCommandTester() { $command = $this->application->find('config:dump-reference'); return new CommandTester($command); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php�����0000664�0000000�0000000�00000004304�13247321071�0032731�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\ApplicationTester; /** * @group functional */ class ContainerDebugCommandTest extends WebTestCase { public function testDumpContainerIfNotExists() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); $application = new Application(static::$kernel); $application->setAutoExit(false); @unlink(static::$kernel->getContainer()->getParameter('debug.container.dump')); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:container')); $this->assertFileExists(static::$kernel->getContainer()->getParameter('debug.container.dump')); } public function testNoDebug() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => false)); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:container')); $this->assertContains('public', $tester->getDisplay()); } public function testPrivateAlias() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:container', '--show-private' => true)); $this->assertContains('public', $tester->getDisplay()); $this->assertContains('private_alias', $tester->getDisplay()); $tester->run(array('command' => 'debug:container')); $this->assertContains('public', $tester->getDisplay()); $this->assertNotContains('private_alias', $tester->getDisplay()); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php�������������0000664�0000000�0000000�00000001666�13247321071�0031321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; /** * Checks that the container compiles correctly when all the bundle features are enabled. */ class ContainerDumpTest extends WebTestCase { public function testContainerCompilationInDebug() { $client = $this->createClient(array('test_case' => 'ContainerDump', 'root_config' => 'config.yml')); $this->assertTrue($client->getContainer()->has('serializer')); } public function testContainerCompilation() { $client = $this->createClient(array('test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false)); $this->assertTrue($client->getContainer()->has('serializer')); } } ��������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php����0000664�0000000�0000000�00000004347�13247321071�0033146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\ApplicationTester; /** * @group functional */ class DebugAutowiringCommandTest extends WebTestCase { public function testBasicFunctionality() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:autowiring')); $this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay()); $this->assertContains('alias to http_kernel', $tester->getDisplay()); } public function testSearchArgument() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:autowiring', 'search' => 'kern')); $this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay()); $this->assertNotContains('Symfony\Component\Routing\RouterInterface', $tester->getDisplay()); } public function testSearchNoResults() { static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'debug:autowiring', 'search' => 'foo_fake'), array('capture_stderr_separately' => true)); $this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput()); $this->assertEquals(1, $tester->getStatusCode()); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php������������������0000664�0000000�0000000�00000001574�13247321071�0030312�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; class FragmentTest extends WebTestCase { /** * @dataProvider getConfigs */ public function testFragment($insulate) { $client = $this->createClient(array('test_case' => 'Fragment', 'root_config' => 'config.yml')); if ($insulate) { $client->insulate(); } $client->request('GET', '/fragment_home'); $this->assertEquals('bar txt--html--es--fr', $client->getResponse()->getContent()); } public function getConfigs() { return array( array(false), array(true), ); } } ������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php������������������0000664�0000000�0000000�00000002253�13247321071�0030324�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; class ProfilerTest extends WebTestCase { /** * @dataProvider getConfigs */ public function testProfilerIsDisabled($insulate) { $client = $this->createClient(array('test_case' => 'Profiler', 'root_config' => 'config.yml')); if ($insulate) { $client->insulate(); } $client->request('GET', '/profiler'); $this->assertFalse($client->getProfile()); // enable the profiler for the next request $client->enableProfiler(); $crawler = $client->request('GET', '/profiler'); $profile = $client->getProfile(); $this->assertInternalType('object', $profile); $client->request('GET', '/profiler'); $this->assertFalse($client->getProfile()); } public function getConfigs() { return array( array(false), array(true), ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php��������������0000664�0000000�0000000�00000001664�13247321071�0031207�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Component\PropertyInfo\Type; class PropertyInfoTest extends WebTestCase { public function testPhpDocPriority() { static::bootKernel(array('test_case' => 'Serializer')); $container = static::$kernel->getContainer(); $this->assertEquals(array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))), $container->get('test.property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes')); } } class Dummy { /** * @param int[] $codes */ public function setCodes(array $codes) { } } ����������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php����������������0000664�0000000�0000000�00000002041�13247321071�0030646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class SerializerTest extends WebTestCase { public function testDeserializeArrayOfObject() { static::bootKernel(array('test_case' => 'Serializer')); $container = static::$kernel->getContainer(); $result = $container->get('serializer')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json'); $bar1 = new Bar(); $bar1->id = 1; $bar2 = new Bar(); $bar2->id = 2; $expected = new Foo(); $expected->bars = array($bar1, $bar2); $this->assertEquals($expected, $result); } } class Foo { /** * @var Bar[] */ public $bars; } class Bar { /** * @var int */ public $id; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php�������������������0000664�0000000�0000000�00000011223�13247321071�0030162�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; class SessionTest extends WebTestCase { /** * Tests session attributes persist. * * @dataProvider getConfigs */ public function testWelcome($config, $insulate) { $client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); if ($insulate) { $client->insulate(); } // no session $crawler = $client->request('GET', '/session'); $this->assertContains('You are new here and gave no name.', $crawler->text()); // remember name $crawler = $client->request('GET', '/session/drak'); $this->assertContains('Hello drak, nice to meet you.', $crawler->text()); // prove remembered name $crawler = $client->request('GET', '/session'); $this->assertContains('Welcome back drak, nice to meet you.', $crawler->text()); // clear session $crawler = $client->request('GET', '/session_logout'); $this->assertContains('Session cleared.', $crawler->text()); // prove cleared session $crawler = $client->request('GET', '/session'); $this->assertContains('You are new here and gave no name.', $crawler->text()); } /** * Tests flash messages work in practice. * * @dataProvider getConfigs */ public function testFlash($config, $insulate) { $client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); if ($insulate) { $client->insulate(); } // set flash $crawler = $client->request('GET', '/session_setflash/Hello%20world.'); // check flash displays on redirect $this->assertContains('Hello world.', $client->followRedirect()->text()); // check flash is gone $crawler = $client->request('GET', '/session_showflash'); $this->assertContains('No flash was set.', $crawler->text()); } /** * See if two separate insulated clients can run without * polluting eachother's session data. * * @dataProvider getConfigs */ public function testTwoClients($config, $insulate) { // start first client $client1 = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); if ($insulate) { $client1->insulate(); } // start second client $client2 = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); if ($insulate) { $client2->insulate(); } // new session, so no name set. $crawler1 = $client1->request('GET', '/session'); $this->assertContains('You are new here and gave no name.', $crawler1->text()); // set name of client1 $crawler1 = $client1->request('GET', '/session/client1'); $this->assertContains('Hello client1, nice to meet you.', $crawler1->text()); // no session for client2 $crawler2 = $client2->request('GET', '/session'); $this->assertContains('You are new here and gave no name.', $crawler2->text()); // remember name client2 $crawler2 = $client2->request('GET', '/session/client2'); $this->assertContains('Hello client2, nice to meet you.', $crawler2->text()); // prove remembered name of client1 $crawler1 = $client1->request('GET', '/session'); $this->assertContains('Welcome back client1, nice to meet you.', $crawler1->text()); // prove remembered name of client2 $crawler2 = $client2->request('GET', '/session'); $this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text()); // clear client1 $crawler1 = $client1->request('GET', '/session_logout'); $this->assertContains('Session cleared.', $crawler1->text()); // prove client1 data is cleared $crawler1 = $client1->request('GET', '/session'); $this->assertContains('You are new here and gave no name.', $crawler1->text()); // prove remembered name of client2 remains untouched. $crawler2 = $client2->request('GET', '/session'); $this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text()); } public function getConfigs() { return array( // configfile, insulate array('config.yml', true), array('config.yml', false), ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php���������������0000664�0000000�0000000�00000002040�13247321071�0031021�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; class SubRequestsTest extends WebTestCase { public function testStateAfterSubRequest() { $client = $this->createClient(array('test_case' => 'Session', 'root_config' => 'config.yml')); $client->request('GET', 'https://localhost/subrequest/en'); $this->assertEquals('--fr/json--en/html--fr/json--http://localhost/subrequest/fragment/en', $client->getResponse()->getContent()); } public function testSubRequestControllerServicesAreResolved() { $client = $this->createClient(array('test_case' => 'ControllerServiceResolution', 'root_config' => 'config.yml')); $client->request('GET', 'https://localhost/subrequest'); $this->assertEquals('---', $client->getResponse()->getContent()); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php�������������������0000664�0000000�0000000�00000004125�13247321071�0030053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase; use Symfony\Component\Filesystem\Filesystem; class WebTestCase extends BaseWebTestCase { public static function assertRedirect($response, $location) { self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode()); self::assertEquals('http://localhost'.$location, $response->headers->get('Location')); } public static function setUpBeforeClass() { static::deleteTmpDir(); } public static function tearDownAfterClass() { static::deleteTmpDir(); } protected static function deleteTmpDir() { if (!file_exists($dir = sys_get_temp_dir().'/'.static::getVarDir())) { return; } $fs = new Filesystem(); $fs->remove($dir); } protected static function getKernelClass() { require_once __DIR__.'/app/AppKernel.php'; return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel'; } protected static function createKernel(array $options = array()) { $class = self::getKernelClass(); if (!isset($options['test_case'])) { throw new \InvalidArgumentException('The option "test_case" must be set.'); } return new $class( static::getVarDir(), $options['test_case'], isset($options['root_config']) ? $options['root_config'] : 'config.yml', isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']), isset($options['debug']) ? $options['debug'] : true ); } protected static function getVarDir() { return 'FB'.substr(strrchr(get_called_class(), '\\'), 1); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/������������������������������0000775�0000000�0000000�00000000000�13247321071�0025747�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/����������0000775�0000000�0000000�00000000000�13247321071�0031730�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������bundles.php�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000667�13247321071�0034027�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/config.yml0000664�0000000�0000000�00000000063�13247321071�0033717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������routing.yml�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000207�13247321071�0034062�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController������������������������������������������������������������������������������annotated_controller: prefix: /annotated resource: "@TestBundle/Controller/AnnotatedController.php" type: annotation �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php�����������������0000664�0000000�0000000�00000005443�13247321071�0030347�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app; use Psr\Log\NullLogger; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; /** * App Test Kernel for functional tests. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class AppKernel extends Kernel { private $varDir; private $testCase; private $rootConfig; public function __construct($varDir, $testCase, $rootConfig, $environment, $debug) { if (!is_dir(__DIR__.'/'.$testCase)) { throw new \InvalidArgumentException(sprintf('The test case "%s" does not exist.', $testCase)); } $this->varDir = $varDir; $this->testCase = $testCase; $fs = new Filesystem(); if (!$fs->isAbsolutePath($rootConfig) && !file_exists($rootConfig = __DIR__.'/'.$testCase.'/'.$rootConfig)) { throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig)); } $this->rootConfig = $rootConfig; parent::__construct($environment, $debug); } public function registerBundles() { if (!file_exists($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) { throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename)); } return include $filename; } public function getRootDir() { return __DIR__; } public function getCacheDir() { return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/cache/'.$this->environment; } public function getLogDir() { return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/logs'; } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load($this->rootConfig); } protected function build(ContainerBuilder $container) { $container->register('logger', NullLogger::class); } public function serialize() { return serialize(array($this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug())); } public function unserialize($str) { $a = unserialize($str); $this->__construct($a[0], $a[1], $a[2], $a[3], $a[4]); } protected function getKernelParameters() { $parameters = parent::getKernelParameters(); $parameters['kernel.test_case'] = $this->testCase; return $parameters; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/��������������0000775�0000000�0000000�00000000000�13247321071�0031124�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php���0000664�0000000�0000000�00000000667�13247321071�0033302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml����0000664�0000000�0000000�00000000512�13247321071�0033112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } services: _defaults: { public: true } test.autowiring_types.autowired_services: class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices autowire: true framework: templating: engines: ['php'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������no_annotations_cache.yml����������������������������������������������������������������������������0000664�0000000�0000000�00000000131�13247321071�0035737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes����������������������������������������������������������������������������������imports: - { resource: config.yml } framework: annotations: cache: none ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/���������������0000775�0000000�0000000�00000000000�13247321071�0030553�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/bundles.php����0000664�0000000�0000000�00000000667�13247321071�0032731�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/config.yml�����0000664�0000000�0000000�00000001063�13247321071�0032543�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } services: dummy: class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass arguments: ['@cache.private_pool'] public: true custom_clearer: parent: cache.default_clearer tags: - name: kernel.cache_clearer framework: cache: pools: cache.private_pool: ~ cache.public_pool: public: true cache.pool_with_clearer: public: true clearer: custom_clearer �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/�������������������0000775�0000000�0000000�00000000000�13247321071�0027767�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php��������0000664�0000000�0000000�00000000667�13247321071�0032145�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml���������0000664�0000000�0000000�00000000504�13247321071�0031756�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } framework: cache: pools: cache.pool1: public: true adapter: cache.system cache.pool2: public: true adapter: cache.pool3 cache.pool3: clearer: ~ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml���0000664�0000000�0000000�00000000631�13247321071�0033145�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } parameters: env(REDIS_HOST): 'localhost' framework: cache: app: cache.adapter.redis default_redis_provider: "redis://%env(REDIS_HOST)%" pools: cache.pool1: public: true clearer: cache.system_clearer cache.pool2: public: true clearer: ~ �������������������������������������������������������������������������������������������������������redis_custom_config.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000001146�13247321071�0034462�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools���������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } parameters: env(REDIS_HOST): 'localhost' services: cache.test_redis_connection: public: false class: Redis calls: - [connect, ['%env(REDIS_HOST)%']] cache.app: parent: cache.adapter.redis tags: - name: cache.pool provider: cache.test_redis_connection framework: cache: pools: cache.pool1: public: true clearer: cache.system_clearer cache.pool2: public: true clearer: ~ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/�������������������0000775�0000000�0000000�00000000000�13247321071�0030002�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/bundles.php��������0000664�0000000�0000000�00000000667�13247321071�0032160�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml���������0000664�0000000�0000000�00000000254�13247321071�0031773�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } framework: secret: '%secret%' default_locale: '%env(LOCALE)%' parameters: env(LOCALE): en secret: test ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/���������������0000775�0000000�0000000�00000000000�13247321071�0030640�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/bundles.php����0000664�0000000�0000000�00000000667�13247321071�0033016�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/config.yml�����0000664�0000000�0000000�00000000364�13247321071�0032633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } services: _defaults: { public: true } public: class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass private_alias: alias: public public: false ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/����������������0000775�0000000�0000000�00000000000�13247321071�0030517�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/bundles.php�����0000664�0000000�0000000�00000000667�13247321071�0032675�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml������0000664�0000000�0000000�00000000607�13247321071�0032512�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } framework: esi: true ssi: true fragments: true profiler: true router: true session: true request: true templating: enabled: true engines: ['php'] assets: true translator: true validation: true serializer: true property_info: true csrf_protection: true form: true �������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution/��0000775�0000000�0000000�00000000000�13247321071�0033477�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������bundles.php�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000667�13247321071�0035576�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution����������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������config.yml������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000512�13247321071�0035406�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution����������������������������������������������������������������������imports: - { resource: ../config/default.yml } services: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SubRequestServiceResolutionController: public: true tags: [controller.service_arguments] logger: { class: Psr\Log\NullLogger } Psr\Log\LoggerInterface: '@logger' ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������routing.yml�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000174�13247321071�0035634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution����������������������������������������������������������������������sub_request_page: path: /subrequest defaults: _controller: 'TestBundle:SubRequestServiceResolution:index' ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/���������������������0000775�0000000�0000000�00000000000�13247321071�0027512�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php����������0000664�0000000�0000000�00000000667�13247321071�0031670�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml�����������0000664�0000000�0000000�00000000171�13247321071�0031501�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } framework: fragments: ~ templating: engines: ['php'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/routing.yml����������0000664�0000000�0000000�00000000117�13247321071�0031723�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������_fragmenttest_bundle: resource: '@TestBundle/Resources/config/routing.yml' �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/���������������������0000775�0000000�0000000�00000000000�13247321071�0027531�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/bundles.php����������0000664�0000000�0000000�00000000667�13247321071�0031707�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/config.yml�����������0000664�0000000�0000000�00000000172�13247321071�0031521�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } framework: profiler: enabled: true collect: false ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/routing.yml����������0000664�0000000�0000000�00000000116�13247321071�0031741�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������_sessiontest_bundle: resource: '@TestBundle/Resources/config/routing.yml' ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/��������������������0000775�0000000�0000000�00000000000�13247321071�0027721�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/��������������0000775�0000000�0000000�00000000000�13247321071�0031056�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������fragment.html.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001312�13247321071�0034253�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views����������������������������������������������������������������������������������<?php echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:inlined', array( 'options' => array( 'bar' => $bar, 'eleven' => 11, ), ))); ?>--<?php echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customformat', array('_format' => 'html'))); ?>--<?php echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); ?>--<?php $app->getRequest()->setLocale('fr'); echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:forwardlocale')); ?> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/�������������������0000775�0000000�0000000�00000000000�13247321071�0030060�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/bundles.php��������0000664�0000000�0000000�00000000517�13247321071�0032230�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), ); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml���������0000664�0000000�0000000�00000000332�13247321071�0032046�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/default.yml } services: _defaults: { public: true } test.property_info: '@property_info' framework: serializer: { enabled: true } property_info: { enabled: true } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/����������������������0000775�0000000�0000000�00000000000�13247321071�0027372�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/bundles.php�����������0000664�0000000�0000000�00000000667�13247321071�0031550�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new TestBundle(), ); �������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/config.yml������������0000664�0000000�0000000�00000000450�13247321071�0031361�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/default.yml } services: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SubRequestController: tags: - { name: controller.service_arguments, action: indexAction, argument: handler, id: fragment.handler } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/routing.yml�����������0000664�0000000�0000000�00000000116�13247321071�0031602�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������_sessiontest_bundle: resource: '@TestBundle/Resources/config/routing.yml' ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/�����������������������0000775�0000000�0000000�00000000000�13247321071�0027214�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/default.yml������������0000664�0000000�0000000�00000000053�13247321071�0031361�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: framework.yml } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml����������0000664�0000000�0000000�00000000566�13247321071�0031743�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: secret: test router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } csrf_protection: true form: true test: ~ default_locale: en session: storage_id: session.storage.mock_file services: logger: { class: Psr\Log\NullLogger } ������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/��������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024305�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php���������������0000664�0000000�0000000�00000005215�13247321071�0030716�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel; use Psr\Log\NullLogger; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\RouteCollectionBuilder; class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface { use MicroKernelTrait; private $cacheDir; public function onKernelException(GetResponseForExceptionEvent $event) { if ($event->getException() instanceof Danger) { $event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔')); } } public function halloweenAction() { return new Response('halloween'); } public function dangerousAction() { throw new Danger(); } public function registerBundles() { return array( new FrameworkBundle(), ); } public function getCacheDir() { return $this->cacheDir = sys_get_temp_dir().'/sf_micro_kernel'; } public function getLogDir() { return $this->cacheDir; } public function __destruct() { $fs = new Filesystem(); $fs->remove($this->cacheDir); } protected function configureRoutes(RouteCollectionBuilder $routes) { $routes->add('/', 'kernel:halloweenAction'); $routes->add('/danger', 'kernel:dangerousAction'); } protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) { $c->register('logger', NullLogger::class); $c->loadFromExtension('framework', array( 'secret' => '$ecret', )); $c->setParameter('halloween', 'Have a great day!'); $c->register('halloween', 'stdClass')->setPublic(true); } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array( KernelEvents::EXCEPTION => 'onKernelException', ); } } class Danger extends \RuntimeException { } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php��������������0000664�0000000�0000000�00000002310�13247321071�0031070�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; class MicroKernelTraitTest extends TestCase { public function test() { $kernel = new ConcreteMicroKernel('test', false); $kernel->boot(); $request = Request::create('/'); $response = $kernel->handle($request); $this->assertEquals('halloween', $response->getContent()); $this->assertEquals('Have a great day!', $kernel->getContainer()->getParameter('halloween')); $this->assertInstanceOf('stdClass', $kernel->getContainer()->get('halloween')); } public function testAsEventSubscriber() { $kernel = new ConcreteMicroKernel('test', false); $kernel->boot(); $request = Request::create('/danger'); $response = $kernel->handle($request); $this->assertSame('It\'s dangerous to go alone. Take this ⚔', $response->getContent()); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/�������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024514�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php�������������0000664�0000000�0000000�00000001367�13247321071�0031266�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php namespace Symfony\Bundle\FrameworkBundle\Tests\Routing; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader; use Symfony\Component\Config\Loader\LoaderResolver; class DelegatingLoaderTest extends TestCase { public function testConstructorApi() { $controllerNameParser = $this->getMockBuilder(ControllerNameParser::class) ->disableOriginalConstructor() ->getMock(); new DelegatingLoader($controllerNameParser, new LoaderResolver()); $this->assertTrue(true, '__construct() takes a ControllerNameParser and LoaderResolverInterface respectively as its first and second argument.'); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php�������0000664�0000000�0000000�00000003745�13247321071�0032452�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Routing; use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; use Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher; use Symfony\Component\Routing\RequestContext; class RedirectableUrlMatcherTest extends TestCase { public function testRedirectWhenNoSlash() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo/')); $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); $this->assertEquals(array( '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'path' => '/foo/', 'permanent' => true, 'scheme' => null, 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', ), $matcher->match('/foo') ); } public function testSchemeRedirect() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); $this->assertEquals(array( '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'path' => '/foo', 'permanent' => true, 'scheme' => 'https', 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', ), $matcher->match('/foo') ); } } ���������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php�����������������������0000664�0000000�0000000�00000017670�13247321071�0027360�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Routing; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Routing\Router; use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; class RouterTest extends TestCase { public function testGenerateWithServiceParam() { $routes = new RouteCollection(); $routes->add('foo', new Route( ' /{_locale}', array( '_locale' => '%locale%', ), array( '_locale' => 'en|es', ), array(), '', array(), array(), '"%foo%" == "bar"' )); $sc = $this->getServiceContainer($routes); $sc->setParameter('locale', 'es'); $sc->setParameter('foo', 'bar'); $router = new Router($sc, 'foo'); $this->assertSame('/en', $router->generate('foo', array('_locale' => 'en'))); $this->assertSame('/', $router->generate('foo', array('_locale' => 'es'))); $this->assertSame('"bar" == "bar"', $router->getRouteCollection()->get('foo')->getCondition()); } public function testDefaultsPlaceholders() { $routes = new RouteCollection(); $routes->add('foo', new Route( '/foo', array( 'foo' => 'before_%parameter.foo%', 'bar' => '%parameter.bar%_after', 'baz' => '%%escaped%%', 'boo' => array('%parameter%', '%%escaped_parameter%%', array('%bee_parameter%', 'bee')), 'bee' => array('bee', 'bee'), ), array( ) )); $sc = $this->getServiceContainer($routes); $sc->setParameter('parameter.foo', 'foo'); $sc->setParameter('parameter.bar', 'bar'); $sc->setParameter('parameter', 'boo'); $sc->setParameter('bee_parameter', 'foo_bee'); $router = new Router($sc, 'foo'); $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( array( 'foo' => 'before_foo', 'bar' => 'bar_after', 'baz' => '%escaped%', 'boo' => array('boo', '%escaped_parameter%', array('foo_bee', 'bee')), 'bee' => array('bee', 'bee'), ), $route->getDefaults() ); } public function testRequirementsPlaceholders() { $routes = new RouteCollection(); $routes->add('foo', new Route( '/foo', array( ), array( 'foo' => 'before_%parameter.foo%', 'bar' => '%parameter.bar%_after', 'baz' => '%%escaped%%', ) )); $sc = $this->getServiceContainer($routes); $sc->setParameter('parameter.foo', 'foo'); $sc->setParameter('parameter.bar', 'bar'); $router = new Router($sc, 'foo'); $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( array( 'foo' => 'before_foo', 'bar' => 'bar_after', 'baz' => '%escaped%', ), $route->getRequirements() ); } public function testPatternPlaceholders() { $routes = new RouteCollection(); $routes->add('foo', new Route('/before/%parameter.foo%/after/%%escaped%%')); $sc = $this->getServiceContainer($routes); $sc->setParameter('parameter.foo', 'foo'); $router = new Router($sc, 'foo'); $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( '/before/foo/after/%escaped%', $route->getPath() ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Using "%env(FOO)%" is not allowed in routing configuration. */ public function testEnvPlaceholders() { $routes = new RouteCollection(); $routes->add('foo', new Route('/%env(FOO)%')); $router = new Router($this->getServiceContainer($routes), 'foo'); $router->getRouteCollection(); } public function testHostPlaceholders() { $routes = new RouteCollection(); $route = new Route('foo'); $route->setHost('/before/%parameter.foo%/after/%%escaped%%'); $routes->add('foo', $route); $sc = $this->getServiceContainer($routes); $sc->setParameter('parameter.foo', 'foo'); $router = new Router($sc, 'foo'); $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( '/before/foo/after/%escaped%', $route->getHost() ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException * @expectedExceptionMessage You have requested a non-existent parameter "nope". */ public function testExceptionOnNonExistentParameter() { $routes = new RouteCollection(); $routes->add('foo', new Route('/%nope%')); $sc = $this->getServiceContainer($routes); $router = new Router($sc, 'foo'); $router->getRouteCollection()->get('foo'); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type object. */ public function testExceptionOnNonStringParameter() { $routes = new RouteCollection(); $routes->add('foo', new Route('/%object%')); $sc = $this->getServiceContainer($routes); $sc->setParameter('object', new \stdClass()); $router = new Router($sc, 'foo'); $router->getRouteCollection()->get('foo'); } /** * @dataProvider getNonStringValues */ public function testDefaultValuesAsNonStrings($value) { $routes = new RouteCollection(); $routes->add('foo', new Route('foo', array('foo' => $value), array('foo' => '\d+'))); $sc = $this->getServiceContainer($routes); $router = new Router($sc, 'foo'); $route = $router->getRouteCollection()->get('foo'); $this->assertSame($value, $route->getDefault('foo')); } public function testGetRouteCollectionAddsContainerParametersResource() { $routeCollection = new RouteCollection(); $routeCollection->add('foo', new Route('/%locale%')); $sc = $this->getServiceContainer($routeCollection); $sc->setParameter('locale', 'en'); $router = new Router($sc, 'foo'); $routeCollection = $router->getRouteCollection(); $this->assertEquals(array(new ContainerParametersResource(array('locale' => 'en'))), $routeCollection->getResources()); } public function getNonStringValues() { return array(array(null), array(false), array(true), array(new \stdClass()), array(array('foo', 'bar')), array(array(array()))); } /** * @return \Symfony\Component\DependencyInjection\Container */ private function getServiceContainer(RouteCollection $routes) { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader ->expects($this->any()) ->method('load') ->will($this->returnValue($routes)) ; $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(array('get'))->getMock(); $sc ->expects($this->once()) ->method('get') ->will($this->returnValue($loader)) ; return $sc; } } ������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025171�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php����������0000664�0000000�0000000�00000010454�13247321071�0031737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine; use Symfony\Component\HttpFoundation\Response; class DelegatingEngineTest extends TestCase { public function testSupportsRetrievesEngineFromTheContainer() { $container = $this->getContainerMock(array( 'engine.first' => $this->getEngineMock('template.php', false), 'engine.second' => $this->getEngineMock('template.php', true), )); $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); $this->assertTrue($delegatingEngine->supports('template.php')); } public function testGetExistingEngine() { $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', true); $container = $this->getContainerMock(array( 'engine.first' => $firstEngine, 'engine.second' => $secondEngine, )); $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); $this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php')); } /** * @expectedException \RuntimeException * @expectedExceptionMessage No engine is able to work with the template "template.php" */ public function testGetInvalidEngine() { $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false); $container = $this->getContainerMock(array( 'engine.first' => $firstEngine, 'engine.second' => $secondEngine, )); $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); $delegatingEngine->getEngine('template.php'); } public function testRenderResponseWithFrameworkEngine() { $response = new Response(); $engine = $this->getFrameworkEngineMock('template.php', true); $engine->expects($this->once()) ->method('renderResponse') ->with('template.php', array('foo' => 'bar')) ->will($this->returnValue($response)); $container = $this->getContainerMock(array('engine' => $engine)); $delegatingEngine = new DelegatingEngine($container, array('engine')); $this->assertSame($response, $delegatingEngine->renderResponse('template.php', array('foo' => 'bar'))); } public function testRenderResponseWithTemplatingEngine() { $engine = $this->getEngineMock('template.php', true); $container = $this->getContainerMock(array('engine' => $engine)); $delegatingEngine = new DelegatingEngine($container, array('engine')); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', array('foo' => 'bar'))); } private function getEngineMock($template, $supports) { $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock(); $engine->expects($this->once()) ->method('supports') ->with($template) ->will($this->returnValue($supports)); return $engine; } private function getFrameworkEngineMock($template, $supports) { $engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $engine->expects($this->once()) ->method('supports') ->with($template) ->will($this->returnValue($supports)); return $engine; } private function getContainerMock($services) { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $i = 0; foreach ($services as $id => $service) { $container->expects($this->at($i++)) ->method('get') ->with($id) ->will($this->returnValue($service)); } return $container; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php�����������0000664�0000000�0000000�00000006552�13247321071�0031603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Container; class GlobalVariablesTest extends TestCase { private $container; private $globals; protected function setUp() { $this->container = new Container(); $this->globals = new GlobalVariables($this->container); } public function testGetTokenNoTokenStorage() { $this->assertNull($this->globals->getToken()); } public function testGetTokenNoToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->container->set('security.token_storage', $tokenStorage); $this->assertNull($this->globals->getToken()); } public function testGetToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->container->set('security.token_storage', $tokenStorage); $tokenStorage ->expects($this->once()) ->method('getToken') ->will($this->returnValue('token')); $this->assertSame('token', $this->globals->getToken()); } public function testGetUserNoTokenStorage() { $this->assertNull($this->globals->getUser()); } public function testGetUserNoToken() { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $this->container->set('security.token_storage', $tokenStorage); $this->assertNull($this->globals->getUser()); } /** * @dataProvider getUserProvider */ public function testGetUser($user, $expectedUser) { $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->container->set('security.token_storage', $tokenStorage); $token ->expects($this->once()) ->method('getUser') ->will($this->returnValue($user)); $tokenStorage ->expects($this->once()) ->method('getToken') ->will($this->returnValue($token)); $this->assertSame($expectedUser, $this->globals->getUser()); } public function getUserProvider() { $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $std = new \stdClass(); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); return array( array($user, $user), array($std, $std), array($token, $token), array('Anon.', null), array(null, null), array(10, null), array(true, null), ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026410�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php�������0000664�0000000�0000000�00000002473�13247321071�0032371�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; class AssetsHelperTest extends TestCase { private $helper; protected function setUp() { $fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s')); $barPackage = new Package(new StaticVersionStrategy('22', '%s?%s')); $packages = new Packages($fooPackage, array('bar' => $barPackage)); $this->helper = new AssetsHelper($packages); } public function testGetUrl() { $this->assertEquals('me.png?v=42', $this->helper->getUrl('me.png')); $this->assertEquals('me.png?22', $this->helper->getUrl('me.png', 'bar')); } public function testGetVersion() { $this->assertEquals('42', $this->helper->getVersion('/')); $this->assertEquals('22', $this->helper->getVersion('/', 'bar')); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/������������������0000775�0000000�0000000�00000000000�13247321071�0030221�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������StubTemplateNameParser.php��������������������������������������������������������������������������0000664�0000000�0000000�00000002173�13247321071�0035245�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures��������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReference; class StubTemplateNameParser implements TemplateNameParserInterface { private $root; private $rootTheme; public function __construct($root, $rootTheme) { $this->root = $root; $this->rootTheme = $rootTheme; } public function parse($name) { list($bundle, $controller, $template) = explode(':', $name, 3); if ('_' == $template[0]) { $path = $this->rootTheme.'/Custom/'.$template; } elseif ('TestBundle' === $bundle) { $path = $this->rootTheme.'/'.$controller.'/'.$template; } else { $path = $this->root.'/'.$controller.'/'.$template; } return new TemplateReference($path, 'php'); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php0000664�0000000�0000000�00000001475�13247321071�0033730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures; use Symfony\Component\Translation\TranslatorInterface; class StubTranslator implements TranslatorInterface { public function trans($id, array $parameters = array(), $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } public function setLocale($locale) { } public function getLocale() { } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php0000664�0000000�0000000�00000011002�13247321071�0033657�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Extension\Templating\TemplatingExtension; use Symfony\Component\Form\Tests\AbstractDivLayoutTest; use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser; use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator; use Symfony\Component\Templating\PhpEngine; use Symfony\Component\Templating\Loader\FilesystemLoader; use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper; class FormHelperDivLayoutTest extends AbstractDivLayoutTest { /** * @var PhpEngine */ protected $engine; protected function getExtensions() { // should be moved to the Form component once absolute file paths are supported // by the default name parser in the Templating component $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); $root = realpath(dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); $loader = new FilesystemLoader(array()); $this->engine = new PhpEngine($templateNameParser, $loader); $this->engine->addGlobal('global', ''); $this->engine->setHelpers(array( new TranslatorHelper(new StubTranslator()), )); return array_merge(parent::getExtensions(), array( new TemplatingExtension($this->engine, $this->csrfTokenManager, array( 'FrameworkBundle:Form', )), )); } protected function tearDown() { $this->engine = null; parent::tearDown(); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->form($view, $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { return (string) $this->engine->get('form')->label($view, $label, $vars); } protected function renderErrors(FormView $view) { return (string) $this->engine->get('form')->errors($view); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->widget($view, $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->row($view, $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->rest($view, $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->start($view, $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->end($view, $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes); } public static function themeBlockInheritanceProvider() { return array( array(array('TestBundle:Parent')), ); } public static function themeInheritanceProvider() { return array( array(array('TestBundle:Parent'), array('TestBundle:Child')), ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������FormHelperTableLayoutTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000010357�13247321071�0034121�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper�����������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Extension\Templating\TemplatingExtension; use Symfony\Component\Form\Tests\AbstractTableLayoutTest; use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser; use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator; use Symfony\Component\Templating\PhpEngine; use Symfony\Component\Templating\Loader\FilesystemLoader; use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper; class FormHelperTableLayoutTest extends AbstractTableLayoutTest { /** * @var PhpEngine */ protected $engine; public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get">', $html); } public function testStartTagHasActionAttributeWhenActionIsZero() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => '0', )); $html = $this->renderStart($form->createView()); $this->assertSame('<form name="form" method="get" action="0">', $html); } protected function getExtensions() { // should be moved to the Form component once absolute file paths are supported // by the default name parser in the Templating component $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); $root = realpath(dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); $loader = new FilesystemLoader(array()); $this->engine = new PhpEngine($templateNameParser, $loader); $this->engine->addGlobal('global', ''); $this->engine->setHelpers(array( new TranslatorHelper(new StubTranslator()), )); return array_merge(parent::getExtensions(), array( new TemplatingExtension($this->engine, $this->csrfTokenManager, array( 'FrameworkBundle:Form', 'FrameworkBundle:FormTable', )), )); } protected function tearDown() { $this->engine = null; parent::tearDown(); } protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->form($view, $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) { return (string) $this->engine->get('form')->label($view, $label, $vars); } protected function renderErrors(FormView $view) { return (string) $this->engine->get('form')->errors($view); } protected function renderWidget(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->widget($view, $vars); } protected function renderRow(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->row($view, $vars); } protected function renderRest(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->rest($view, $vars); } protected function renderStart(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->start($view, $vars); } protected function renderEnd(FormView $view, array $vars = array()) { return (string) $this->engine->get('form')->end($view, $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) { $this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php������0000664�0000000�0000000�00000002650�13247321071�0032554�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper; class RequestHelperTest extends TestCase { protected $requestStack; protected function setUp() { $this->requestStack = new RequestStack(); $request = new Request(); $request->initialize(array('foobar' => 'bar')); $this->requestStack->push($request); } public function testGetParameter() { $helper = new RequestHelper($this->requestStack); $this->assertEquals('bar', $helper->getParameter('foobar')); $this->assertEquals('foo', $helper->getParameter('bar', 'foo')); $this->assertNull($helper->getParameter('foo')); } public function testGetLocale() { $helper = new RequestHelper($this->requestStack); $this->assertEquals('en', $helper->getLocale()); } public function testGetName() { $helper = new RequestHelper($this->requestStack); $this->assertEquals('request', $helper->getName()); } } ����������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/�����������������0000775�0000000�0000000�00000000000�13247321071�0030362�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/�����������0000775�0000000�0000000�00000000000�13247321071�0031405�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_label.html.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000053�13247321071�0035102�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child�������������������������������������������������������������������������������<label><?php echo $global; ?>child</label> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/����������0000775�0000000�0000000�00000000000�13247321071�0031634�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������_name_c_entry_label.html.php������������������������������������������������������������������������0000664�0000000�0000000�00000000303�13247321071�0037166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom������������������������������������������������������������������������������<?php if (!$label) { $label = $view['form']->humanize($name); } ?> <label>Custom name label: <?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������_names_entry_label.html.php�������������������������������������������������������������������������0000664�0000000�0000000�00000000302�13247321071�0037046�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom������������������������������������������������������������������������������<?php if (!$label) { $label = $view['form']->humanize($name); } ?> <label>Custom label: <?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������_text_id_widget.html.php����������������������������������������������������������������������������0000664�0000000�0000000�00000000113�13247321071�0036366�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom������������������������������������������������������������������������������<div id="container"> <?php echo $view['form']->widget($form) ?> </div> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/����������0000775�0000000�0000000�00000000000�13247321071�0031613�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_label.html.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000026�13247321071�0035310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent������������������������������������������������������������������������������<label>parent</label> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������form_widget_simple.html.php�������������������������������������������������������������������������0000664�0000000�0000000�00000000273�13247321071�0037071�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent������������������������������������������������������������������������������<?php $type = isset($type) ? $type : 'text'; ?> <input type="<?php echo $type; ?>" <?php $view['form']->block($form, 'widget_attributes'); ?> value="<?php echo $value; ?>" rel="theme" /> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php������0000664�0000000�0000000�00000003761�13247321071�0032553�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper; class SessionHelperTest extends TestCase { protected $requestStack; protected function setUp() { $request = new Request(); $session = new Session(new MockArraySessionStorage()); $session->set('foobar', 'bar'); $session->getFlashBag()->set('notice', 'bar'); $request->setSession($session); $this->requestStack = new RequestStack(); $this->requestStack->push($request); } protected function tearDown() { $this->requestStack = null; } public function testFlash() { $helper = new SessionHelper($this->requestStack); $this->assertTrue($helper->hasFlash('notice')); $this->assertEquals(array('bar'), $helper->getFlash('notice')); } public function testGetFlashes() { $helper = new SessionHelper($this->requestStack); $this->assertEquals(array('notice' => array('bar')), $helper->getFlashes()); } public function testGet() { $helper = new SessionHelper($this->requestStack); $this->assertEquals('bar', $helper->get('foobar')); $this->assertEquals('foo', $helper->get('bar', 'foo')); $this->assertNull($helper->get('foo')); } public function testGetName() { $helper = new SessionHelper($this->requestStack); $this->assertEquals('session', $helper->getName()); } } ���������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php����0000664�0000000�0000000�00000002151�13247321071�0033074�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper; class StopwatchHelperTest extends TestCase { public function testDevEnvironment() { $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); $stopwatch->expects($this->once()) ->method('start') ->with('foo'); $helper = new StopwatchHelper($stopwatch); $helper->start('foo'); } public function testProdEnvironment() { $helper = new StopwatchHelper(null); $helper->start('foo'); // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above // can be executed without throwing any exceptions $this->addToAssertionCount(1); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026377�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php����0000664�0000000�0000000�00000006134�13247321071�0033053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Loader; use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; class TemplateLocatorTest extends TestCase { public function testLocateATemplate() { $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); $fileLocator = $this->getFileLocator(); $fileLocator ->expects($this->once()) ->method('locate') ->with($template->getPath()) ->will($this->returnValue('/path/to/template')) ; $locator = new TemplateLocator($fileLocator); $this->assertEquals('/path/to/template', $locator->locate($template)); // Assert cache is used as $fileLocator->locate should be called only once $this->assertEquals('/path/to/template', $locator->locate($template)); } public function testLocateATemplateFromCacheDir() { $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); $fileLocator = $this->getFileLocator(); $locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures'); $this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template)); } public function testThrowsExceptionWhenTemplateNotFound() { $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); $fileLocator = $this->getFileLocator(); $errorMessage = 'FileLocator exception message'; $fileLocator ->expects($this->once()) ->method('locate') ->will($this->throwException(new \InvalidArgumentException($errorMessage))) ; $locator = new TemplateLocator($fileLocator); try { $locator->locate($template); $this->fail('->locate() should throw an exception when the file is not found.'); } catch (\InvalidArgumentException $e) { $this->assertContains( $errorMessage, $e->getMessage(), 'TemplateLocator exception should propagate the FileLocator exception message' ); } } /** * @expectedException \InvalidArgumentException */ public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface() { $locator = new TemplateLocator($this->getFileLocator()); $locator->locate('template'); } protected function getFileLocator() { return $this ->getMockBuilder('Symfony\Component\Config\FileLocator') ->setMethods(array('locate')) ->setConstructorArgs(array('/path/to/fallback')) ->getMock() ; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php�����������������0000664�0000000�0000000�00000005076�13247321071�0030427�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\Templating\TemplateNameParser; use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; class PhpEngineTest extends TestCase { public function testEvaluateAddsAppGlobal() { $container = $this->getContainer(); $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container)); $globals = $engine->getGlobals(); $this->assertSame($app, $globals['app']); } public function testEvaluateWithoutAvailableRequest() { $container = new Container(); $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container)); $this->assertFalse($container->has('request_stack')); $globals = $engine->getGlobals(); $this->assertEmpty($globals['app']->getRequest()); } /** * @expectedException \InvalidArgumentException */ public function testGetInvalidHelper() { $container = $this->getContainer(); $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader); $engine->get('non-existing-helper'); } /** * Creates a Container with a Session-containing Request service. * * @return Container */ protected function getContainer() { $container = new Container(); $session = new Session(new MockArraySessionStorage()); $request = new Request(); $stack = new RequestStack(); $stack->push($request); $request->setSession($session); $container->set('request_stack', $stack); return $container; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php����0000664�0000000�0000000�00000003163�13247321071�0033136�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; class TemplateFilenameParserTest extends TestCase { protected $parser; protected function setUp() { $this->parser = new TemplateFilenameParser(); } protected function tearDown() { $this->parser = null; } /** * @dataProvider getFilenameToTemplateProvider */ public function testParseFromFilename($file, $ref) { $template = $this->parser->parse($file); if (false === $ref) { $this->assertFalse($template); } else { $this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); } } public function getFilenameToTemplateProvider() { return array( array('/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')), array('\\path\\to\\section\\name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')), array('name.format.engine', new TemplateReference('', '', 'name', 'format', 'engine')), array('name.format', false), array('name', false), ); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php��������0000664�0000000�0000000�00000013724�13247321071�0032302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; class TemplateNameParserTest extends TestCase { protected $parser; protected function setUp() { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('getBundle') ->will($this->returnCallback(function ($bundle) { if (in_array($bundle, array('SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'))) { return true; } throw new \InvalidArgumentException(); })) ; $this->parser = new TemplateNameParser($kernel); } protected function tearDown() { $this->parser = null; } /** * @dataProvider parseProvider */ public function testParse($name, $logicalName, $path, $ref) { $template = $this->parser->parse($name); $this->assertSame($ref->getLogicalName(), $template->getLogicalName()); $this->assertSame($logicalName, $template->getLogicalName()); $this->assertSame($path, $template->getPath()); } public function parseProvider() { return array( array('FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')), array('FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')), array('FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')), array('SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')), array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')), array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')), array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')), array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), array('name', 'name', 'name', new BaseTemplateReference('name')), array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')), ); } /** * @expectedException \InvalidArgumentException */ public function testParseValidNameWithNotFoundBundle() { $this->parser->parse('BarBundle:Post:index.html.php'); } /** * @group legacy * @dataProvider provideAbsolutePaths * @expectedDeprecation Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0. */ public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref) { $template = $this->parser->parse($name); $this->assertSame($ref->getLogicalName(), $template->getLogicalName()); $this->assertSame($logicalName, $template->getLogicalName()); $this->assertSame($path, $template->getPath()); } public function provideAbsolutePaths() { return array( array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')), array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')), array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')), array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')), array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), ); } } ��������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php���������0000664�0000000�0000000�00000001424�13247321071�0032135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; class TemplateReferenceTest extends TestCase { public function testGetPathWorksWithNamespacedControllers() { $reference = new TemplateReference('AcmeBlogBundle', 'Admin\Post', 'index', 'html', 'twig'); $this->assertSame( '@AcmeBlogBundle/Resources/views/Admin/Post/index.html.twig', $reference->getPath() ); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php������������������0000664�0000000�0000000�00000002275�13247321071�0030323�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; class TemplateTest extends TestCase { /** * @dataProvider getTemplateToPathProvider */ public function testGetPathForTemplate($template, $path) { $this->assertSame($template->getPath(), $path); } public function getTemplateToPathProvider() { return array( array(new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'), array(new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'), array(new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'), array(new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'), ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php������������0000664�0000000�0000000�00000007054�13247321071�0031410�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine; use Symfony\Component\DependencyInjection\Container; use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; class TimedPhpEngineTest extends TestCase { public function testThatRenderLogsTime() { $container = $this->getContainer(); $templateNameParser = $this->getTemplateNameParser(); $globalVariables = $this->getGlobalVariables(); $loader = $this->getLoader($this->getStorage()); $stopwatch = $this->getStopwatch(); $stopwatchEvent = $this->getStopwatchEvent(); $stopwatch->expects($this->once()) ->method('start') ->with('template.php (index.php)', 'template') ->will($this->returnValue($stopwatchEvent)); $stopwatchEvent->expects($this->once())->method('stop'); $engine = new TimedPhpEngine($templateNameParser, $container, $loader, $stopwatch, $globalVariables); $engine->render('index.php'); } /** * @return Container */ private function getContainer() { return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock(); } /** * @return \Symfony\Component\Templating\TemplateNameParserInterface */ private function getTemplateNameParser() { $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock(); $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $templateNameParser->expects($this->any()) ->method('parse') ->will($this->returnValue($templateReference)); return $templateNameParser; } /** * @return GlobalVariables */ private function getGlobalVariables() { return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables') ->disableOriginalConstructor() ->getMock(); } /** * @return \Symfony\Component\Templating\Storage\StringStorage */ private function getStorage() { return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage') ->disableOriginalConstructor() ->getMockForAbstractClass(); } /** * @param \Symfony\Component\Templating\Storage\StringStorage $storage * * @return \Symfony\Component\Templating\Loader\Loader */ private function getLoader($storage) { $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader->expects($this->once()) ->method('load') ->will($this->returnValue($storage)); return $loader; } /** * @return \Symfony\Component\Stopwatch\StopwatchEvent */ private function getStopwatchEvent() { return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') ->disableOriginalConstructor() ->getMock(); } /** * @return \Symfony\Component\Stopwatch\Stopwatch */ private function getStopwatch() { return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/TestCase.php���������������������������������0000664�0000000�0000000�00000000576�13247321071�0025321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests; use PHPUnit\Framework\TestCase as PHPUnitTestCase; class TestCase extends PHPUnitTestCase { } ����������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/���������������������������������0000775�0000000�0000000�00000000000�13247321071�0025363�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php�������������0000664�0000000�0000000�00000007553�13247321071�0031371�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Translation; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Translation\PhpExtractor; use Symfony\Component\Translation\MessageCatalogue; /** * @group legacy */ class PhpExtractorTest extends TestCase { /** * @dataProvider resourcesProvider * * @param array|string $resource */ public function testExtraction($resource) { // Arrange $extractor = new PhpExtractor(); $extractor->setPrefix('prefix'); $catalogue = new MessageCatalogue('en'); // Act $extractor->extract($resource, $catalogue); $expectedHeredoc = <<<EOF heredoc key with whitespace and escaped \$\n sequences EOF; $expectedNowdoc = <<<'EOF' nowdoc key with whitespace and nonescaped \$\n sequences EOF; // Assert $expectedCatalogue = array( 'messages' => array( 'single-quoted key' => 'prefixsingle-quoted key', 'double-quoted key' => 'prefixdouble-quoted key', 'heredoc key' => 'prefixheredoc key', 'nowdoc key' => 'prefixnowdoc key', "double-quoted key with whitespace and escaped \$\n\" sequences" => "prefixdouble-quoted key with whitespace and escaped \$\n\" sequences", 'single-quoted key with whitespace and nonescaped \$\n\' sequences' => 'prefixsingle-quoted key with whitespace and nonescaped \$\n\' sequences', 'single-quoted key with "quote mark at the end"' => 'prefixsingle-quoted key with "quote mark at the end"', $expectedHeredoc => 'prefix'.$expectedHeredoc, $expectedNowdoc => 'prefix'.$expectedNowdoc, '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', ), 'not_messages' => array( 'other-domain-test-no-params-short-array' => 'prefixother-domain-test-no-params-short-array', 'other-domain-test-no-params-long-array' => 'prefixother-domain-test-no-params-long-array', 'other-domain-test-params-short-array' => 'prefixother-domain-test-params-short-array', 'other-domain-test-params-long-array' => 'prefixother-domain-test-params-long-array', 'other-domain-test-trans-choice-short-array-%count%' => 'prefixother-domain-test-trans-choice-short-array-%count%', 'other-domain-test-trans-choice-long-array-%count%' => 'prefixother-domain-test-trans-choice-long-array-%count%', 'typecast' => 'prefixtypecast', 'msg1' => 'prefixmsg1', 'msg2' => 'prefixmsg2', ), ); $actualCatalogue = $catalogue->all(); $this->assertEquals($expectedCatalogue, $actualCatalogue); } public function resourcesProvider() { $directory = __DIR__.'/../Fixtures/Resources/views/'; $splFiles = array(); foreach (new \DirectoryIterator($directory) as $fileInfo) { if ($fileInfo->isDot()) { continue; } if ('translation.html.php' === $fileInfo->getBasename()) { $phpFile = $fileInfo->getPathname(); } $splFiles[] = $fileInfo->getFileInfo(); } return array( array($directory), array($phpFile), array(glob($directory.'*')), array($splFiles), array(new \ArrayObject(glob($directory.'*'))), array(new \ArrayObject($splFiles)), ); } } �����������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php���������������0000664�0000000�0000000�00000052223�13247321071�0031071�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Translation; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\Translation\Translator; use Symfony\Component\Translation\Formatter\MessageFormatter; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Filesystem\Filesystem; class TranslatorTest extends TestCase { protected $tmpDir; protected function setUp() { $this->tmpDir = sys_get_temp_dir().'/sf2_translation'; $this->deleteTmpDir(); } protected function tearDown() { $this->deleteTmpDir(); } protected function deleteTmpDir() { if (!file_exists($dir = $this->tmpDir)) { return; } $fs = new Filesystem(); $fs->remove($dir); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. */ public function testTransWithoutCachingOmittingLocale() { $translator = $this->getTranslator($this->getLoader(), array(), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. */ public function testTransWithCachingOmittingLocale() { // prime the cache $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); // do it another time as the cache is primed now $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader->expects($this->never())->method('load'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. * @expectedException \InvalidArgumentException */ public function testTransWithCachingWithInvalidLocaleOmittingLocale() { $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale', null); $translator->trans('foo'); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. */ public function testLoadResourcesWithoutCachingOmittingLocale() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( 'fr' => array( __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ), ); $translator = $this->getTranslator($loader, array('resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $this->assertEquals('répertoire', $translator->trans('folder')); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. */ public function testGetDefaultLocaleOmittingLocale() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->once()) ->method('getParameter') ->with('kernel.default_locale') ->will($this->returnValue('en')) ; $translator = new Translator($container, new MessageFormatter()); $this->assertSame('en', $translator->getLocale()); } /** * @group legacy * @expectedException \InvalidArgumentException * @expectedExceptionMessage Missing third $defaultLocale argument. */ public function testGetDefaultLocaleOmittingLocaleWithPsrContainer() { $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); $translator = new Translator($container, new MessageFormatter()); } /** * @group legacy * @expectedDeprecation Method Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0. */ public function testWarmupOmittingLocale() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( 'fr' => array( __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ), ); // prime the cache $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setFallbackLocales(array('fr')); $translator->warmup($this->tmpDir); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader ->expects($this->never()) ->method('load'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $translator->setFallbackLocales(array('fr')); $this->assertEquals('répertoire', $translator->trans('folder')); } public function testTransWithoutCaching() { $translator = $this->getTranslator($this->getLoader()); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } public function testTransWithCaching() { // prime the cache $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); // do it another time as the cache is primed now $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader->expects($this->never())->method('load'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); $this->assertEquals('foobar (ES)', $translator->trans('foobar')); $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0)); $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid "invalid locale" locale. */ public function testTransWithCachingWithInvalidLocale() { $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale'); $translator->trans('foo'); } public function testLoadResourcesWithoutCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( 'fr' => array( __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ), ); $translator = $this->getTranslator($loader, array('resource_files' => $resourceFiles), 'yml'); $translator->setLocale('fr'); $this->assertEquals('répertoire', $translator->trans('folder')); } public function testGetDefaultLocale() { $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); $translator = new Translator($container, new MessageFormatter(), 'en'); $this->assertSame('en', $translator->getLocale()); } /** * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException * @expectedExceptionMessage The Translator does not support the following options: 'foo' */ public function testInvalidOptions() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); (new Translator($container, new MessageFormatter(), 'en', array(), array('foo' => 'bar'))); } /** @dataProvider getDebugModeAndCacheDirCombinations */ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache) { $someCatalogue = $this->getCatalogue('some_locale', array()); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader->expects($this->at(0)) ->method('load') /* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */ ->with('messages.some_locale.loader', 'some_locale', 'messages') ->willReturn($someCatalogue); $loader->expects($this->at(1)) ->method('load') /* This resource is added by an addResource() call and shall be loaded after the resource_files */ ->with('second_resource.some_locale.loader', 'some_locale', 'messages') ->willReturn($someCatalogue); $options = array( 'resource_files' => array('some_locale' => array('messages.some_locale.loader')), 'debug' => $debug, ); if ($enableCache) { $options['cache_dir'] = $this->tmpDir; } /** @var Translator $translator */ $translator = $this->createTranslator($loader, $options); $translator->addResource('loader', 'second_resource.some_locale.loader', 'some_locale', 'messages'); $translator->trans('some_message', array(), null, 'some_locale'); } public function getDebugModeAndCacheDirCombinations() { return array( array(false, false), array(true, false), array(false, true), array(true, true), ); } protected function getCatalogue($locale, $messages, $resources = array()) { $catalogue = new MessageCatalogue($locale); foreach ($messages as $key => $translation) { $catalogue->set($key, $translation); } foreach ($resources as $resource) { $catalogue->addResource($resource); } return $catalogue; } protected function getLoader() { $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader ->expects($this->at(0)) ->method('load') ->will($this->returnValue($this->getCatalogue('fr', array( 'foo' => 'foo (FR)', )))) ; $loader ->expects($this->at(1)) ->method('load') ->will($this->returnValue($this->getCatalogue('en', array( 'foo' => 'foo (EN)', 'bar' => 'bar (EN)', 'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)', )))) ; $loader ->expects($this->at(2)) ->method('load') ->will($this->returnValue($this->getCatalogue('es', array( 'foobar' => 'foobar (ES)', )))) ; $loader ->expects($this->at(3)) ->method('load') ->will($this->returnValue($this->getCatalogue('pt-PT', array( 'foobarfoo' => 'foobarfoo (PT-PT)', )))) ; $loader ->expects($this->at(4)) ->method('load') ->will($this->returnValue($this->getCatalogue('pt_BR', array( 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', )))) ; $loader ->expects($this->at(5)) ->method('load') ->will($this->returnValue($this->getCatalogue('fr.UTF-8', array( 'foobarbaz' => 'foobarbaz (fr.UTF-8)', )))) ; $loader ->expects($this->at(6)) ->method('load') ->will($this->returnValue($this->getCatalogue('sr@latin', array( 'foobarbax' => 'foobarbax (sr@latin)', )))) ; return $loader; } protected function getContainer($loader) { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') ->will($this->returnValue($loader)) ; return $container; } public function getTranslator($loader, $options = array(), $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en') { $translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale); if ('loader' === $loaderFomat) { $translator->addResource('loader', 'foo', 'fr'); $translator->addResource('loader', 'foo', 'en'); $translator->addResource('loader', 'foo', 'es'); $translator->addResource('loader', 'foo', 'pt-PT'); // European Portuguese $translator->addResource('loader', 'foo', 'pt_BR'); // Brazilian Portuguese $translator->addResource('loader', 'foo', 'fr.UTF-8'); $translator->addResource('loader', 'foo', 'sr@latin'); // Latin Serbian } return $translator; } public function testWarmup() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( 'fr' => array( __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ), ); // prime the cache $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); $translator->setFallbackLocales(array('fr')); $translator->warmup($this->tmpDir); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader ->expects($this->never()) ->method('load'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); $translator->setLocale('fr'); $translator->setFallbackLocales(array('fr')); $this->assertEquals('répertoire', $translator->trans('folder')); } private function createTranslator($loader, $options, $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $loaderFomat = 'loader', $defaultLocale = 'en') { if (null === $defaultLocale) { return new $translatorClass( $this->getContainer($loader), new MessageFormatter(), array($loaderFomat => array($loaderFomat)), $options ); } return new $translatorClass( $this->getContainer($loader), new MessageFormatter(), $defaultLocale, array($loaderFomat => array($loaderFomat)), $options ); } } class TranslatorWithInvalidLocale extends Translator { /** * {@inheritdoc} */ public function getLocale() { return 'invalid locale'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025012�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php�0000664�0000000�0000000�00000006012�13247321071�0033704�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Tests\Validator; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Blank as BlankConstraint; use Symfony\Component\Validator\ConstraintValidator; /** * @group legacy */ class ConstraintValidatorFactoryTest extends TestCase { public function testGetInstanceCreatesValidator() { $factory = new ConstraintValidatorFactory(new Container()); $this->assertInstanceOf(DummyConstraintValidator::class, $factory->getInstance(new DummyConstraint())); } public function testGetInstanceReturnsExistingValidator() { $factory = new ConstraintValidatorFactory(new Container()); $v1 = $factory->getInstance(new BlankConstraint()); $v2 = $factory->getInstance(new BlankConstraint()); $this->assertSame($v1, $v2); } public function testGetInstanceReturnsService() { $validator = new DummyConstraintValidator(); $container = new Container(); $container->set(DummyConstraintValidator::class, $validator); $factory = new ConstraintValidatorFactory($container); $this->assertSame($validator, $factory->getInstance(new DummyConstraint())); } public function testGetInstanceReturnsServiceWithAlias() { $validator = new DummyConstraintValidator(); $container = new Container(); $container->set('validator_constraint_service', $validator); $factory = new ConstraintValidatorFactory($container, array('validator_constraint_alias' => 'validator_constraint_service')); $this->assertSame($validator, $factory->getInstance(new ConstraintAliasStub())); } /** * @expectedException \Symfony\Component\Validator\Exception\ValidatorException */ public function testGetInstanceInvalidValidatorClass() { $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock(); $constraint ->expects($this->exactly(2)) ->method('validatedBy') ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name')); $factory = new ConstraintValidatorFactory(new Container()); $factory->getInstance($constraint); } } class ConstraintAliasStub extends Constraint { public function validatedBy() { return 'validator_constraint_alias'; } } class DummyConstraint extends Constraint { public function validatedBy() { return DummyConstraintValidator::class; } } class DummyConstraintValidator extends ConstraintValidator { public function validate($value, Constraint $constraint) { } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Translation/���������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024261�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php�����������������������0000664�0000000�0000000�00000001343�13247321071�0027416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Translation; use Symfony\Component\Translation\Extractor\PhpExtractor as NewPhpExtractor; @trigger_error(sprintf('The class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use "%s" instead. ', PhpExtractor::class, NewPhpExtractor::class), E_USER_DEPRECATED); /** * @deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\Extractor\PhpExtractor instead */ class PhpExtractor extends NewPhpExtractor { } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php���������������0000664�0000000�0000000�00000001411�13247321071�0031063�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Translation; @trigger_error(sprintf('The class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use "%s" instead. ', PhpStringTokenParser::class, \Symfony\Component\Translation\Extractor\PhpStringTokenParser::class), E_USER_DEPRECATED); /** * @deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\Extractor\PhpStringTokenParser instead */ class PhpStringTokenParser extends \Symfony\Component\Translation\Extractor\PhpStringTokenParser { } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Translation/TranslationLoader.php������������������0000664�0000000�0000000�00000002162�13247321071�0030420�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Translation; use Symfony\Component\Translation\Reader\TranslationReader; use Symfony\Component\Translation\MessageCatalogue; @trigger_error(sprintf('The class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use "%s" instead. ', TranslationLoader::class, TranslationReader::class), E_USER_DEPRECATED); /** * @deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\Reader\TranslationReader instead */ class TranslationLoader extends TranslationReader { /** * Loads translation messages from a directory to the catalogue. * * @param string $directory The directory to look into * @param MessageCatalogue $catalogue The catalogue */ public function loadMessages($directory, MessageCatalogue $catalogue) { $this->read($directory, $catalogue); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php�������������������������0000664�0000000�0000000�00000012532�13247321071�0027126�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Translation; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\Translation\Translator as BaseTranslator; use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Translation\Formatter\MessageFormatterInterface; /** * Translator. * * @author Fabien Potencier <fabien@symfony.com> */ class Translator extends BaseTranslator implements WarmableInterface { protected $container; protected $loaderIds; protected $options = array( 'cache_dir' => null, 'debug' => false, 'resource_files' => array(), ); /** * @var array */ private $resourceLocales; /** * Holds parameters from addResource() calls so we can defer the actual * parent::addResource() calls until initialize() is executed. * * @var array */ private $resources = array(); /** * Constructor. * * Available options: * * * cache_dir: The cache directory (or null to disable caching) * * debug: Whether to enable debugging or not (false by default) * * resource_files: List of translation resources available grouped by locale. * * @param ContainerInterface $container A ContainerInterface instance * @param MessageFormatterInterface $formatter The message formatter * @param string $defaultLocale * @param array $loaderIds An array of loader Ids * @param array $options An array of options * * @throws InvalidArgumentException */ public function __construct(ContainerInterface $container, $formatter, $defaultLocale = null, array $loaderIds = array(), array $options = array()) { // BC 3.x, to be removed in 4.0 along with the $defaultLocale default value if (is_array($defaultLocale) || 3 > func_num_args()) { if (!$container instanceof SymfonyContainerInterface) { throw new \InvalidArgumentException('Missing third $defaultLocale argument.'); } $options = $loaderIds; $loaderIds = $defaultLocale; $defaultLocale = $container->getParameter('kernel.default_locale'); @trigger_error(sprintf('Method %s() takes the default locale as 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0.', __METHOD__), E_USER_DEPRECATED); } $this->container = $container; $this->loaderIds = $loaderIds; // check option names if ($diff = array_diff(array_keys($options), array_keys($this->options))) { throw new InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff))); } $this->options = array_merge($this->options, $options); $this->resourceLocales = array_keys($this->options['resource_files']); $this->addResourceFiles($this->options['resource_files']); parent::__construct($defaultLocale, $formatter, $this->options['cache_dir'], $this->options['debug']); } /** * {@inheritdoc} */ public function warmUp($cacheDir) { // skip warmUp when translator doesn't use cache if (null === $this->options['cache_dir']) { return; } $locales = array_merge($this->getFallbackLocales(), array($this->getLocale()), $this->resourceLocales); foreach (array_unique($locales) as $locale) { // reset catalogue in case it's already loaded during the dump of the other locales. if (isset($this->catalogues[$locale])) { unset($this->catalogues[$locale]); } $this->loadCatalogue($locale); } } public function addResource($format, $resource, $locale, $domain = null) { $this->resources[] = array($format, $resource, $locale, $domain); } /** * {@inheritdoc} */ protected function initializeCatalogue($locale) { $this->initialize(); parent::initializeCatalogue($locale); } protected function initialize() { foreach ($this->resources as $key => $params) { list($format, $resource, $locale, $domain) = $params; parent::addResource($format, $resource, $locale, $domain); } $this->resources = array(); foreach ($this->loaderIds as $id => $aliases) { foreach ($aliases as $alias) { $this->addLoader($alias, $this->container->get($id)); } } } private function addResourceFiles($filesByLocale) { foreach ($filesByLocale as $locale => $files) { foreach ($files as $key => $file) { // filename is domain.locale.format list($domain, $locale, $format) = explode('.', basename($file), 3); $this->addResource($format, $file, $locale, $domain); } } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Validator/�����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023710�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php�����������0000664�0000000�0000000�00000005517�13247321071�0031753�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Validator; use Psr\Container\ContainerInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\ContainerConstraintValidatorFactory; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\ValidatorException; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s instead.', ConstraintValidatorFactory::class, ContainerConstraintValidatorFactory::class), E_USER_DEPRECATED); /** * Uses a service container to create constraint validators. * * A constraint validator should be tagged as "validator.constraint_validator" * in the service container and include an "alias" attribute: * * <service id="some_doctrine_validator"> * <argument type="service" id="doctrine.orm.some_entity_manager" /> * <tag name="validator.constraint_validator" alias="some_alias" /> * </service> * * A constraint may then return this alias in its validatedBy() method: * * public function validatedBy() * { * return 'some_alias'; * } * * @author Kris Wallsmith <kris@symfony.com> * * @deprecated since version 3.3 */ class ConstraintValidatorFactory extends ContainerConstraintValidatorFactory { protected $container; protected $validators; public function __construct(ContainerInterface $container, array $validators = array()) { parent::__construct($container); $this->validators = $validators; $this->container = $container; } /** * Returns the validator for the supplied constraint. * * @return ConstraintValidatorInterface A validator for the supplied constraint * * @throws ValidatorException When the validator class does not exist * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface */ public function getInstance(Constraint $constraint) { $name = $constraint->validatedBy(); if (!isset($this->validators[$name])) { return parent::getInstance($constraint); } if (is_string($this->validators[$name])) { $this->validators[$name] = $this->container->get($this->validators[$name]); } if (!$this->validators[$name] instanceof ConstraintValidatorInterface) { throw new UnexpectedTypeException($this->validators[$name], 'Symfony\Component\Validator\ConstraintValidatorInterface'); } return $this->validators[$name]; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/composer.json��������������������������������������0000664�0000000�0000000�00000007051�13247321071�0024510�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "symfony/framework-bundle", "type": "symfony-bundle", "description": "Symfony FrameworkBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "ext-xml": "*", "symfony/cache": "~3.4|~4.0", "symfony/class-loader": "~3.2", "symfony/dependency-injection": "^3.4.3|^4.0.3", "symfony/config": "~3.4|~4.0", "symfony/event-dispatcher": "~3.4|~4.0", "symfony/http-foundation": "^3.3.11|~4.0", "symfony/http-kernel": "~3.4|~4.0", "symfony/polyfill-mbstring": "~1.0", "symfony/filesystem": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/routing": "^3.4.5|^4.0.5" }, "require-dev": { "doctrine/cache": "~1.0", "fig/link-util": "^1.0", "symfony/asset": "~3.3|~4.0", "symfony/browser-kit": "~2.8|~3.0|~4.0", "symfony/console": "~3.4|~4.0", "symfony/css-selector": "~2.8|~3.0|~4.0", "symfony/dom-crawler": "~2.8|~3.0|~4.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/security": "~2.8|~3.0|~4.0", "symfony/form": "~3.4|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/process": "~2.8|~3.0|~4.0", "symfony/security-core": "~3.2|~4.0", "symfony/security-csrf": "~2.8|~3.0|~4.0", "symfony/serializer": "~3.3|~4.0", "symfony/stopwatch": "~3.4|~4.0", "symfony/translation": "~3.4|~4.0", "symfony/templating": "~2.8|~3.0|~4.0", "symfony/validator": "~3.4|~4.0", "symfony/var-dumper": "~3.3|~4.0", "symfony/workflow": "~3.3|~4.0", "symfony/yaml": "~3.2|~4.0", "symfony/property-info": "~3.3|~4.0", "symfony/lock": "~3.4|~4.0", "symfony/web-link": "~3.3|~4.0", "doctrine/annotations": "~1.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0", "twig/twig": "~1.34|~2.4" }, "conflict": { "phpdocumentor/reflection-docblock": "<3.0", "phpdocumentor/type-resolver": "<0.2.1", "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", "symfony/asset": "<3.3", "symfony/console": "<3.4", "symfony/form": "<3.4", "symfony/property-info": "<3.3", "symfony/serializer": "<3.3", "symfony/stopwatch": "<3.4", "symfony/translation": "<3.4", "symfony/validator": "<3.4", "symfony/workflow": "<3.3" }, "suggest": { "ext-apcu": "For best performance of the system caches", "symfony/console": "For using the console commands", "symfony/form": "For using forms", "symfony/serializer": "For using the serializer service", "symfony/validator": "For using validation", "symfony/yaml": "For using the debug:config and lint:yaml commands", "symfony/property-info": "For using the property_info service", "symfony/web-link": "For using web links, features such as preloading, prefetching or prerendering" }, "autoload": { "psr-4": { "Symfony\\Bundle\\FrameworkBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist�����������������������������������0000664�0000000�0000000�00000001737�13247321071�0025146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" > <php> <ini name="error_reporting" value="-1" /> <env name="REDIS_HOST" value="localhost" /> <env name="MEMCACHED_HOST" value="localhost" /> </php> <testsuites> <testsuite name="Symfony FrameworkBundle Test Suite"> <directory>./Tests/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./</directory> <exclude> <directory>./Resources</directory> <directory>./Tests</directory> <directory>./vendor</directory> </exclude> </whitelist> </filter> </phpunit> ���������������������������������symfony-3.4.6/src/Symfony/Bundle/FullStack.php������������������������������������������������������0000664�0000000�0000000�00000000651�13247321071�0021277�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle; /** * A marker to be able to check if symfony/symfony is installed instead of the individual components/bundles. * * @internal */ final class FullStack { } ���������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/����������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0021635�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/.gitignore������������������������������������������0000664�0000000�0000000�00000000042�13247321071�0023621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������vendor/ composer.lock phpunit.xml ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md����������������������������������������0000664�0000000�0000000�00000013172�13247321071�0023452�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������CHANGELOG ========= 3.4.0 ----- * Added new `security.helper` service that is an instance of `Symfony\Component\Security\Core\Security` and provides shortcuts for common security tasks. * Tagging voters with the `security.voter` tag without implementing the `VoterInterface` on the class is now deprecated and will be removed in 4.0. * [BC BREAK] `FirewallContext::getListeners()` now returns `\Traversable|array` * added info about called security listeners in profiler * Added `logout_on_user_change` to the firewall options. This config item will trigger a logout when the user has changed. Should be set to true to avoid deprecations in the configuration. * deprecated HTTP digest authentication * deprecated command `acl:set` along with `SetAclCommand` class * deprecated command `init:acl` along with `InitAclCommand` class * Added support for the new Argon2i password encoder * added `stateless` option to the `switch_user` listener * deprecated auto picking the first registered provider when no configured provider on a firewall and ambiguous 3.3.0 ----- * Deprecated instantiating `UserPasswordEncoderCommand` without its constructor arguments fully provided. * Deprecated `UserPasswordEncoderCommand::getContainer()` and relying on the `ContainerAwareCommand` sub class or `ContainerAwareInterface` implementation for this command. * Deprecated the `FirewallMap::$map` and `$container` properties. * [BC BREAK] Keys of the `users` node for `in_memory` user provider are no longer normalized. * deprecated `FirewallContext::getListeners()` 3.2.0 ----- * Added the `SecurityUserValueResolver` to inject the security users in actions via `Symfony\Component\Security\Core\User\UserInterface` in the method signature. 3.0.0 ----- * Removed the `security.context` service. 2.8.0 ----- * deprecated the `key` setting of `anonymous`, `remember_me` and `http_digest` in favor of the `secret` setting. * deprecated the `intention` firewall listener setting in favor of the `csrf_token_id`. 2.6.0 ----- * Added the possibility to override the default success/failure handler to get the provider key and the options injected * Deprecated the `security.context` service for the `security.token_storage` and `security.authorization_checker` services. 2.4.0 ----- * Added 'host' option to firewall configuration * Added 'csrf_token_generator' and 'csrf_token_id' options to firewall logout listener configuration to supersede/alias 'csrf_provider' and 'intention' respectively * Moved 'security.secure_random' service configuration to FrameworkBundle 2.3.0 ----- * allowed for multiple IP address in security access_control rules 2.2.0 ----- * Added PBKDF2 Password encoder * Added BCrypt password encoder 2.1.0 ----- * [BC BREAK] The custom factories for the firewall configuration are now registered during the build method of bundles instead of being registered by the end-user (you need to remove the 'factories' keys in your security configuration). * [BC BREAK] The Firewall listener is now registered after the Router one. This means that specific Firewall URLs (like /login_check and /logout must now have proper route defined in your routing configuration) * [BC BREAK] refactored the user provider configuration. The configuration changed for the chain provider and the memory provider: Before: ``` yaml security: providers: my_chain_provider: providers: [my_memory_provider, my_doctrine_provider] my_memory_provider: users: toto: { password: foobar, roles: [ROLE_USER] } foo: { password: bar, roles: [ROLE_USER, ROLE_ADMIN] } ``` After: ``` yaml security: providers: my_chain_provider: chain: providers: [my_memory_provider, my_doctrine_provider] my_memory_provider: memory: users: toto: { password: foobar, roles: [ROLE_USER] } foo: { password: bar, roles: [ROLE_USER, ROLE_ADMIN] } ``` * [BC BREAK] Method `equals` was removed from `UserInterface` to its own new `EquatableInterface`. The user class can now implement this interface to override the default implementation of users equality test. * added a validator for the user password * added 'erase_credentials' as a configuration key (true by default) * added new events: `security.authentication.success` and `security.authentication.failure` fired on authentication success/failure, regardless of authentication method, events are defined in new event class: `Symfony\Component\Security\Core\AuthenticationEvents`. * Added optional CSRF protection to LogoutListener: ``` yaml security: firewalls: default: logout: path: /logout_path target: / csrf_parameter: _csrf_token # Optional (defaults to "_csrf_token") csrf_provider: security.csrf.token_generator # Required to enable protection intention: logout # Optional (defaults to "logout") ``` If the LogoutListener has CSRF protection enabled but cannot validate a token, then a LogoutException will be thrown. * Added `logout_url` templating helper and Twig extension, which may be used to generate logout URL's within templates. The security firewall's config key must be specified. If a firewall's logout listener has CSRF protection enabled, a token will be automatically added to the generated URL. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Command/��������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023213�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php��������������������������0000664�0000000�0000000�00000006720�13247321071�0026553�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Schema\SchemaException; @trigger_error(sprintf('Class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bundle\AclBundle\Command\InitAclCommand instead.', InitAclCommand::class), E_USER_DEPRECATED); /** * Installs the tables required by the ACL system. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> * * @deprecated since version 3.4, to be removed in 4.0. See Symfony\Bundle\AclBundle\Command\SetAclCommand instead. */ class InitAclCommand extends ContainerAwareCommand { protected static $defaultName = 'init:acl'; private $connection; private $schema; public function __construct($connection = null, Schema $schema = null) { if (!$connection instanceof Connection) { parent::__construct($connection); return; } parent::__construct(); $this->connection = $connection; $this->schema = $schema; } /** * {@inheritdoc} */ public function isEnabled() { if (!$this->connection && !$this->getContainer()->has('security.acl.dbal.connection')) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDescription('Mounts ACL tables in the database') ->setHelp(<<<'EOF' The <info>%command.name%</info> command mounts ACL tables in the database. <info>php %command.full_name%</info> The name of the DBAL connection must be configured in your <info>app/config/security.yml</info> configuration file in the <info>security.acl.connection</info> variable. <info>security: acl: connection: default</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { (new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output))->warning('Command "init:acl" is deprecated since Symfony 3.4 and will be removed from SecurityBundle in 4.0. Install symfony/acl-bundle and use "acl:init" instead.'); if (null === $this->connection) { $this->connection = $this->getContainer()->get('security.acl.dbal.connection'); $this->schema = $this->getContainer()->get('security.acl.dbal.schema'); } try { $this->schema->addToSchema($this->connection->getSchemaManager()->createSchema()); } catch (SchemaException $e) { $output->writeln('Aborting: '.$e->getMessage()); return 1; } foreach ($this->schema->toSql($this->connection->getDatabasePlatform()) as $sql) { $this->connection->exec($sql); } $output->writeln('ACL tables have been initialized successfully.'); } } ������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php���������������������������0000664�0000000�0000000�00000015610�13247321071�0026401�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Command; @trigger_error(sprintf('Class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bundle\AclBundle\Command\SetAclCommand instead.', SetAclCommand::class), E_USER_DEPRECATED); use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Security\Acl\Domain\ObjectIdentity; use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; use Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException; use Symfony\Component\Security\Acl\Permission\MaskBuilder; use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface; /** * Sets ACL for objects. * * @author Kévin Dunglas <kevin@les-tilleuls.coop> * * @deprecated since version 3.4, to be removed in 4.0. See Symfony\Bundle\AclBundle\Command\SetAclCommand instead. */ class SetAclCommand extends ContainerAwareCommand { protected static $defaultName = 'acl:set'; private $provider; /** * @param MutableAclProviderInterface $provider */ public function __construct($provider = null) { if (!$provider instanceof MutableAclProviderInterface) { parent::__construct($provider); return; } parent::__construct(); $this->provider = $provider; } /** * {@inheritdoc} */ public function isEnabled() { if (null !== $this->provider) { return parent::isEnabled(); } if (!$this->getContainer()->has('security.acl.provider')) { return false; } $provider = $this->getContainer()->get('security.acl.provider'); if (!$provider instanceof MutableAclProviderInterface) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDescription('Sets ACL for objects') ->setHelp(<<<EOF The <info>%command.name%</info> command sets ACL. The ACL system must have been initialized with the <info>init:acl</info> command. To set <comment>VIEW</comment> and <comment>EDIT</comment> permissions for the user <comment>kevin</comment> on the instance of <comment>Acme\MyClass</comment> having the identifier <comment>42</comment>: <info>php %command.full_name% --user=Symfony/Component/Security/Core/User/User:kevin VIEW EDIT Acme/MyClass:42</info> Note that you can use <comment>/</comment> instead of <comment>\\ </comment>for the namespace delimiter to avoid any problem. To set permissions for a role, use the <info>--role</info> option: <info>php %command.full_name% --role=ROLE_USER VIEW Acme/MyClass:1936</info> To set permissions at the class scope, use the <info>--class-scope</info> option: <info>php %command.full_name% --class-scope --user=Symfony/Component/Security/Core/User/User:anne OWNER Acme/MyClass:42</info> EOF ) ->addArgument('arguments', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of permissions and object identities (class name and ID separated by a column)') ->addOption('user', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A list of security identities') ->addOption('role', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A list of roles') ->addOption('class-scope', null, InputOption::VALUE_NONE, 'Use class-scope entries') ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { (new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output))->warning('Command "acl:set" is deprecated since Symfony 3.4 and will be removed from SecurityBundle in 4.0. Install symfony/acl-bundle to use this command.'); if (null === $this->provider) { $this->provider = $this->getContainer()->get('security.acl.provider'); } // Parse arguments $objectIdentities = array(); $maskBuilder = $this->getMaskBuilder(); foreach ($input->getArgument('arguments') as $argument) { $data = explode(':', $argument, 2); if (count($data) > 1) { $objectIdentities[] = new ObjectIdentity($data[1], strtr($data[0], '/', '\\')); } else { $maskBuilder->add($data[0]); } } // Build permissions mask $mask = $maskBuilder->get(); $userOption = $input->getOption('user'); $roleOption = $input->getOption('role'); $classScopeOption = $input->getOption('class-scope'); if (empty($userOption) && empty($roleOption)) { throw new \InvalidArgumentException('A Role or a User must be specified.'); } // Create security identities $securityIdentities = array(); if ($userOption) { foreach ($userOption as $user) { $data = explode(':', $user, 2); if (1 === count($data)) { throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".'); } $securityIdentities[] = new UserSecurityIdentity($data[1], strtr($data[0], '/', '\\')); } } if ($roleOption) { foreach ($roleOption as $role) { $securityIdentities[] = new RoleSecurityIdentity($role); } } // Sets ACL foreach ($objectIdentities as $objectIdentity) { // Creates a new ACL if it does not already exist try { $this->provider->createAcl($objectIdentity); } catch (AclAlreadyExistsException $e) { } $acl = $this->provider->findAcl($objectIdentity, $securityIdentities); foreach ($securityIdentities as $securityIdentity) { if ($classScopeOption) { $acl->insertClassAce($securityIdentity, $mask); } else { $acl->insertObjectAce($securityIdentity, $mask); } } $this->provider->updateAcl($acl); } } /** * Gets the mask builder. * * @return MaskBuilder */ protected function getMaskBuilder() { return new MaskBuilder(); } } ������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php��������������0000664�0000000�0000000�00000017456�13247321071�0031201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface; use Symfony\Component\Security\Core\User\User; /** * Encode a user's password. * * @author Sarah Khalil <mkhalil.sarah@gmail.com> * * @final since version 3.4 */ class UserPasswordEncoderCommand extends ContainerAwareCommand { protected static $defaultName = 'security:encode-password'; private $encoderFactory; private $userClasses; public function __construct(EncoderFactoryInterface $encoderFactory = null, array $userClasses = array()) { if (null === $encoderFactory) { @trigger_error(sprintf('Passing null as the first argument of "%s" is deprecated since Symfony 3.3 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); } $this->encoderFactory = $encoderFactory; $this->userClasses = $userClasses; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDescription('Encodes a password.') ->addArgument('password', InputArgument::OPTIONAL, 'The plain password to encode.') ->addArgument('user-class', InputArgument::OPTIONAL, 'The User entity class path associated with the encoder used to encode the password.') ->addOption('empty-salt', null, InputOption::VALUE_NONE, 'Do not generate a salt or let the encoder generate one.') ->setHelp(<<<EOF The <info>%command.name%</info> command encodes passwords according to your security configuration. This command is mainly used to generate passwords for the <comment>in_memory</comment> user provider type and for changing passwords in the database while developing the application. Suppose that you have the following security configuration in your application: <comment> # app/config/security.yml security: encoders: Symfony\Component\Security\Core\User\User: plaintext AppBundle\Entity\User: bcrypt </comment> If you execute the command non-interactively, the first available configured user class under the <comment>security.encoders</comment> key is used and a random salt is generated to encode the password: <info>php %command.full_name% --no-interaction [password]</info> Pass the full user class path as the second argument to encode passwords for your own entities: <info>php %command.full_name% --no-interaction [password] AppBundle\Entity\User</info> Executing the command interactively allows you to generate a random salt for encoding the password: <info>php %command.full_name% [password] AppBundle\Entity\User</info> In case your encoder doesn't require a salt, add the <comment>empty-salt</comment> option: <info>php %command.full_name% --empty-salt [password] AppBundle\Entity\User</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; $input->isInteractive() ? $errorIo->title('Symfony Password Encoder Utility') : $errorIo->newLine(); $password = $input->getArgument('password'); $userClass = $this->getUserClass($input, $io); $emptySalt = $input->getOption('empty-salt'); $encoderFactory = $this->encoderFactory ?: $this->getContainer()->get('security.encoder_factory'); $encoder = $encoderFactory->getEncoder($userClass); $saltlessWithoutEmptySalt = !$emptySalt && $encoder instanceof SelfSaltingEncoderInterface; if ($saltlessWithoutEmptySalt) { $emptySalt = true; } if (!$password) { if (!$input->isInteractive()) { $errorIo->error('The password must not be empty.'); return 1; } $passwordQuestion = $this->createPasswordQuestion(); $password = $errorIo->askQuestion($passwordQuestion); } $salt = null; if ($input->isInteractive() && !$emptySalt) { $emptySalt = true; $errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); if ($errorIo->confirm('Confirm salt generation ?')) { $salt = $this->generateSalt(); $emptySalt = false; } } elseif (!$emptySalt) { $salt = $this->generateSalt(); } $encodedPassword = $encoder->encodePassword($password, $salt); $rows = array( array('Encoder used', get_class($encoder)), array('Encoded password', $encodedPassword), ); if (!$emptySalt) { $rows[] = array('Generated salt', $salt); } $io->table(array('Key', 'Value'), $rows); if (!$emptySalt) { $errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt))); } elseif ($saltlessWithoutEmptySalt) { $errorIo->note('Self-salting encoder used: the encoder generated its own built-in salt.'); } $errorIo->success('Password encoding succeeded'); } /** * Create the password question to ask the user for the password to be encoded. * * @return Question */ private function createPasswordQuestion() { $passwordQuestion = new Question('Type in your password to be encoded'); return $passwordQuestion->setValidator(function ($value) { if ('' === trim($value)) { throw new \Exception('The password must not be empty.'); } return $value; })->setHidden(true)->setMaxAttempts(20); } private function generateSalt() { return base64_encode(random_bytes(30)); } private function getUserClass(InputInterface $input, SymfonyStyle $io) { if (null !== $userClass = $input->getArgument('user-class')) { return $userClass; } if (empty($this->userClasses)) { if (null === $this->encoderFactory) { // BC to be removed and simply keep the exception whenever there is no configured user classes in 4.0 return User::class; } throw new \RuntimeException('There are no configured encoders for the "security" extension.'); } if (!$input->isInteractive() || 1 === count($this->userClasses)) { return reset($this->userClasses); } $userClasses = $this->userClasses; natcasesort($userClasses); $userClasses = array_values($userClasses); return $io->choice('For which user class would you like to encode a password?', $userClasses, reset($userClasses)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DataCollector/��������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024355�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php�������������0000664�0000000�0000000�00000027760�13247321071�0031352�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DataCollector; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Symfony\Component\Security\Core\Role\RoleInterface; use Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener; use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Http\Firewall\SwitchUserListener; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\VarDumper\Caster\ClassStub; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; /** * @author Fabien Potencier <fabien@symfony.com> */ class SecurityDataCollector extends DataCollector implements LateDataCollectorInterface { private $tokenStorage; private $roleHierarchy; private $logoutUrlGenerator; private $accessDecisionManager; private $firewallMap; private $firewall; private $hasVarDumper; public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null) { $this->tokenStorage = $tokenStorage; $this->roleHierarchy = $roleHierarchy; $this->logoutUrlGenerator = $logoutUrlGenerator; $this->accessDecisionManager = $accessDecisionManager; $this->firewallMap = $firewallMap; $this->firewall = $firewall; $this->hasVarDumper = class_exists(ClassStub::class); } /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { if (null === $this->tokenStorage) { $this->data = array( 'enabled' => false, 'authenticated' => false, 'impersonated' => false, 'impersonator_user' => null, 'impersonation_exit_path' => null, 'token' => null, 'token_class' => null, 'logout_url' => null, 'user' => '', 'roles' => array(), 'inherited_roles' => array(), 'supports_role_hierarchy' => null !== $this->roleHierarchy, ); } elseif (null === $token = $this->tokenStorage->getToken()) { $this->data = array( 'enabled' => true, 'authenticated' => false, 'impersonated' => false, 'impersonator_user' => null, 'impersonation_exit_path' => null, 'token' => null, 'token_class' => null, 'logout_url' => null, 'user' => '', 'roles' => array(), 'inherited_roles' => array(), 'supports_role_hierarchy' => null !== $this->roleHierarchy, ); } else { $inheritedRoles = array(); $assignedRoles = $token->getRoles(); $impersonatorUser = null; foreach ($assignedRoles as $role) { if ($role instanceof SwitchUserRole) { $impersonatorUser = $role->getSource()->getUsername(); break; } } if (null !== $this->roleHierarchy) { $allRoles = $this->roleHierarchy->getReachableRoles($assignedRoles); foreach ($allRoles as $role) { if (!in_array($role, $assignedRoles, true)) { $inheritedRoles[] = $role; } } } $logoutUrl = null; try { if (null !== $this->logoutUrlGenerator) { $logoutUrl = $this->logoutUrlGenerator->getLogoutPath(); } } catch (\Exception $e) { // fail silently when the logout URL cannot be generated } $extractRoles = function ($role) { if (!$role instanceof RoleInterface && !$role instanceof Role) { throw new \InvalidArgumentException(sprintf('Roles must be instances of %s or %s (%s given).', RoleInterface::class, Role::class, is_object($role) ? get_class($role) : gettype($role))); } return $role->getRole(); }; $this->data = array( 'enabled' => true, 'authenticated' => $token->isAuthenticated(), 'impersonated' => null !== $impersonatorUser, 'impersonator_user' => $impersonatorUser, 'impersonation_exit_path' => null, 'token' => $token, 'token_class' => $this->hasVarDumper ? new ClassStub(get_class($token)) : get_class($token), 'logout_url' => $logoutUrl, 'user' => $token->getUsername(), 'roles' => array_map($extractRoles, $assignedRoles), 'inherited_roles' => array_unique(array_map($extractRoles, $inheritedRoles)), 'supports_role_hierarchy' => null !== $this->roleHierarchy, ); } // collect voters and access decision manager information if ($this->accessDecisionManager instanceof TraceableAccessDecisionManager) { $this->data['access_decision_log'] = $this->accessDecisionManager->getDecisionLog(); $this->data['voter_strategy'] = $this->accessDecisionManager->getStrategy(); foreach ($this->accessDecisionManager->getVoters() as $voter) { $this->data['voters'][] = $this->hasVarDumper ? new ClassStub(get_class($voter)) : get_class($voter); } } else { $this->data['access_decision_log'] = array(); $this->data['voter_strategy'] = 'unknown'; $this->data['voters'] = array(); } // collect firewall context information $this->data['firewall'] = null; if ($this->firewallMap instanceof FirewallMap) { $firewallConfig = $this->firewallMap->getFirewallConfig($request); if (null !== $firewallConfig) { $this->data['firewall'] = array( 'name' => $firewallConfig->getName(), 'allows_anonymous' => $firewallConfig->allowsAnonymous(), 'request_matcher' => $firewallConfig->getRequestMatcher(), 'security_enabled' => $firewallConfig->isSecurityEnabled(), 'stateless' => $firewallConfig->isStateless(), 'provider' => $firewallConfig->getProvider(), 'context' => $firewallConfig->getContext(), 'entry_point' => $firewallConfig->getEntryPoint(), 'access_denied_handler' => $firewallConfig->getAccessDeniedHandler(), 'access_denied_url' => $firewallConfig->getAccessDeniedUrl(), 'user_checker' => $firewallConfig->getUserChecker(), 'listeners' => $firewallConfig->getListeners(), ); // generate exit impersonation path from current request if ($this->data['impersonated'] && null !== $switchUserConfig = $firewallConfig->getSwitchUser()) { $exitPath = $request->getRequestUri(); $exitPath .= null === $request->getQueryString() ? '?' : '&'; $exitPath .= sprintf('%s=%s', urlencode($switchUserConfig['parameter']), SwitchUserListener::EXIT_VALUE); $this->data['impersonation_exit_path'] = $exitPath; } } } // collect firewall listeners information $this->data['listeners'] = array(); if ($this->firewall) { $this->data['listeners'] = $this->firewall->getWrappedListeners(); } } /** * {@inheritdoc} */ public function reset() { $this->data = array(); } public function lateCollect() { $this->data = $this->cloneVar($this->data); } /** * Checks if security is enabled. * * @return bool true if security is enabled, false otherwise */ public function isEnabled() { return $this->data['enabled']; } /** * Gets the user. * * @return string The user */ public function getUser() { return $this->data['user']; } /** * Gets the roles of the user. * * @return array The roles */ public function getRoles() { return $this->data['roles']; } /** * Gets the inherited roles of the user. * * @return array The inherited roles */ public function getInheritedRoles() { return $this->data['inherited_roles']; } /** * Checks if the data contains information about inherited roles. Still the inherited * roles can be an empty array. * * @return bool true if the profile was contains inherited role information */ public function supportsRoleHierarchy() { return $this->data['supports_role_hierarchy']; } /** * Checks if the user is authenticated or not. * * @return bool true if the user is authenticated, false otherwise */ public function isAuthenticated() { return $this->data['authenticated']; } public function isImpersonated() { return $this->data['impersonated']; } public function getImpersonatorUser() { return $this->data['impersonator_user']; } public function getImpersonationExitPath() { return $this->data['impersonation_exit_path']; } /** * Get the class name of the security token. * * @return string The token */ public function getTokenClass() { return $this->data['token_class']; } /** * Get the full security token class as Data object. * * @return Data */ public function getToken() { return $this->data['token']; } /** * Get the logout URL. * * @return string The logout URL */ public function getLogoutUrl() { return $this->data['logout_url']; } /** * Returns the FQCN of the security voters enabled in the application. * * @return string[] */ public function getVoters() { return $this->data['voters']; } /** * Returns the strategy configured for the security voters. * * @return string */ public function getVoterStrategy() { return $this->data['voter_strategy']; } /** * Returns the log of the security decisions made by the access decision manager. * * @return array */ public function getAccessDecisionLog() { return $this->data['access_decision_log']; } /** * Returns the configuration of the current firewall context. * * @return array */ public function getFirewall() { return $this->data['firewall']; } public function getListeners() { return $this->data['listeners']; } /** * {@inheritdoc} */ public function getName() { return 'security'; } } ����������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Debug/����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022663�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Debug/TraceableFirewallListener.php�����������������0000664�0000000�0000000�00000002116�13247321071�0030452�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Debug; use Symfony\Bundle\SecurityBundle\EventListener\FirewallListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** * Firewall collecting called listeners. * * @author Robin Chalas <robin.chalas@gmail.com> */ final class TraceableFirewallListener extends FirewallListener { private $wrappedListeners; public function getWrappedListeners() { return $this->wrappedListeners; } protected function handleRequest(GetResponseEvent $event, $listeners) { foreach ($listeners as $listener) { $wrappedListener = new WrappedListener($listener); $wrappedListener->handle($event); $this->wrappedListeners[] = $wrappedListener->getInfo(); if ($event->hasResponse()) { break; } } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php���������������������������0000664�0000000�0000000�00000003575�13247321071�0026516�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Debug; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Http\Firewall\ListenerInterface; use Symfony\Component\VarDumper\Caster\ClassStub; /** * Wraps a security listener for calls record. * * @author Robin Chalas <robin.chalas@gmail.com> */ final class WrappedListener implements ListenerInterface { private $response; private $listener; private $time; private $stub; private static $hasVarDumper; public function __construct(ListenerInterface $listener) { $this->listener = $listener; if (null === self::$hasVarDumper) { self::$hasVarDumper = class_exists(ClassStub::class); } } /** * {@inheritdoc} */ public function handle(GetResponseEvent $event) { $startTime = microtime(true); $this->listener->handle($event); $this->time = microtime(true) - $startTime; $this->response = $event->getResponse(); } /** * Proxies all method calls to the original listener. */ public function __call($method, $arguments) { return call_user_func_array(array($this->listener, $method), $arguments); } public function getWrappedListener() { return $this->listener; } public function getInfo() { if (null === $this->stub) { $this->stub = self::$hasVarDumper ? new ClassStub(get_class($this->listener)) : get_class($this->listener); } return array( 'response' => $this->response, 'time' => $this->time, 'stub' => $this->stub, ); } } �����������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/��������������������������������0000775�0000000�0000000�00000000000�13247321071�0025556�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/�����������������������0000775�0000000�0000000�00000000000�13247321071�0027330�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddSecurityVotersPass.php���������������������������������������������������������������������������0000664�0000000�0000000�00000004546�13247321071�0034245�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler�������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; /** * Adds all configured security voters to the access decision manager. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class AddSecurityVotersPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('security.access.decision_manager')) { return; } $voters = $this->findAndSortTaggedServices('security.voter', $container); if (!$voters) { throw new LogicException('No security voters found. You need to tag at least one with "security.voter"'); } foreach ($voters as $voter) { $definition = $container->getDefinition((string) $voter); $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!is_a($class, VoterInterface::class, true)) { @trigger_error(sprintf('Using a "security.voter" tag on a class without implementing the "%s" is deprecated as of 3.4 and will throw an exception in 4.0. Implement the interface instead.', VoterInterface::class), E_USER_DEPRECATED); } if (!method_exists($class, 'vote')) { // in case the vote method is completely missing, to prevent exceptions when voting throw new LogicException(sprintf('%s should implement the %s interface when used as voter.', $class, VoterInterface::class)); } } $adm = $container->getDefinition('security.access.decision_manager'); $adm->replaceArgument(0, new IteratorArgument($voters)); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������AddSessionDomainConstraintPass.php������������������������������������������������������������������0000664�0000000�0000000�00000002500�13247321071�0036037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler�������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Uses the session domain to restrict allowed redirection targets. * * @author Nicolas Grekas <p@tchwork.com> */ class AddSessionDomainConstraintPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasParameter('session.storage.options') || !$container->has('security.http_utils')) { return; } $sessionOptions = $container->getParameter('session.storage.options'); $domainRegexp = empty($sessionOptions['cookie_domain']) ? '%s' : sprintf('(?:%%s|(?:.+\.)?%s)', preg_quote(trim($sessionOptions['cookie_domain'], '.'))); $domainRegexp = (empty($sessionOptions['cookie_secure']) ? 'https?://' : 'https://').$domainRegexp; $container->findDefinition('security.http_utils')->addArgument(sprintf('{^%s$}i', $domainRegexp)); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php�����������0000664�0000000�0000000�00000046165�13247321071�0031717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory; use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy; /** * This class contains the configuration information. * * This information is for the following tags: * * * security.config * * security.acl * * This information is solely responsible for how the different configuration * sections are normalized, and merged. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class MainConfiguration implements ConfigurationInterface { private $factories; private $userProviderFactories; public function __construct(array $factories, array $userProviderFactories) { $this->factories = $factories; $this->userProviderFactories = $userProviderFactories; } /** * Generates the configuration tree builder. * * @return TreeBuilder The tree builder */ public function getConfigTreeBuilder() { $tb = new TreeBuilder(); $rootNode = $tb->root('security'); $rootNode ->beforeNormalization() ->ifTrue(function ($v) { if (!isset($v['access_decision_manager'])) { return true; } if (!isset($v['access_decision_manager']['strategy']) && !isset($v['access_decision_manager']['service'])) { return true; } return false; }) ->then(function ($v) { $v['access_decision_manager'] = array( 'strategy' => AccessDecisionManager::STRATEGY_AFFIRMATIVE, ); return $v; }) ->end() ->children() ->scalarNode('access_denied_url')->defaultNull()->example('/foo/error403')->end() ->enumNode('session_fixation_strategy') ->values(array(SessionAuthenticationStrategy::NONE, SessionAuthenticationStrategy::MIGRATE, SessionAuthenticationStrategy::INVALIDATE)) ->defaultValue(SessionAuthenticationStrategy::MIGRATE) ->end() ->booleanNode('hide_user_not_found')->defaultTrue()->end() ->booleanNode('always_authenticate_before_granting')->defaultFalse()->end() ->booleanNode('erase_credentials')->defaultTrue()->end() ->arrayNode('access_decision_manager') ->addDefaultsIfNotSet() ->children() ->enumNode('strategy') ->values(array(AccessDecisionManager::STRATEGY_AFFIRMATIVE, AccessDecisionManager::STRATEGY_CONSENSUS, AccessDecisionManager::STRATEGY_UNANIMOUS)) ->end() ->scalarNode('service')->end() ->booleanNode('allow_if_all_abstain')->defaultFalse()->end() ->booleanNode('allow_if_equal_granted_denied')->defaultTrue()->end() ->end() ->validate() ->ifTrue(function ($v) { return isset($v['strategy']) && isset($v['service']); }) ->thenInvalid('"strategy" and "service" cannot be used together.') ->end() ->end() ->end() ; $this->addAclSection($rootNode); $this->addEncodersSection($rootNode); $this->addProvidersSection($rootNode); $this->addFirewallsSection($rootNode, $this->factories); $this->addAccessControlSection($rootNode); $this->addRoleHierarchySection($rootNode); return $tb; } private function addAclSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('acl') ->setDeprecated('The "security.acl" configuration key is deprecated since Symfony 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.') ->children() ->scalarNode('connection') ->defaultNull() ->info('any name configured in doctrine.dbal section') ->end() ->arrayNode('cache') ->addDefaultsIfNotSet() ->children() ->scalarNode('id')->end() ->scalarNode('prefix')->defaultValue('sf2_acl_')->end() ->end() ->end() ->scalarNode('provider')->end() ->arrayNode('tables') ->addDefaultsIfNotSet() ->children() ->scalarNode('class')->defaultValue('acl_classes')->end() ->scalarNode('entry')->defaultValue('acl_entries')->end() ->scalarNode('object_identity')->defaultValue('acl_object_identities')->end() ->scalarNode('object_identity_ancestors')->defaultValue('acl_object_identity_ancestors')->end() ->scalarNode('security_identity')->defaultValue('acl_security_identities')->end() ->end() ->end() ->arrayNode('voter') ->addDefaultsIfNotSet() ->children() ->booleanNode('allow_if_object_identity_unavailable')->defaultTrue()->end() ->end() ->end() ->end() ->end() ->end() ; } private function addRoleHierarchySection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('role', 'role_hierarchy') ->children() ->arrayNode('role_hierarchy') ->useAttributeAsKey('id') ->prototype('array') ->performNoDeepMerging() ->beforeNormalization()->ifString()->then(function ($v) { return array('value' => $v); })->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && isset($v['value']); }) ->then(function ($v) { return preg_split('/\s*,\s*/', $v['value']); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->end() ; } private function addAccessControlSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('rule', 'access_control') ->children() ->arrayNode('access_control') ->cannotBeOverwritten() ->prototype('array') ->fixXmlConfig('ip') ->fixXmlConfig('method') ->children() ->scalarNode('requires_channel')->defaultNull()->end() ->scalarNode('path') ->defaultNull() ->info('use the urldecoded format') ->example('^/path to resource/') ->end() ->scalarNode('host')->defaultNull()->end() ->arrayNode('ips') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->end() ->arrayNode('methods') ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->prototype('scalar')->end() ->end() ->scalarNode('allow_if')->defaultNull()->end() ->end() ->fixXmlConfig('role') ->children() ->arrayNode('roles') ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ; } private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $factories) { $firewallNodeBuilder = $rootNode ->fixXmlConfig('firewall') ->children() ->arrayNode('firewalls') ->isRequired() ->requiresAtLeastOneElement() ->disallowNewKeysInSubsequentConfigs() ->useAttributeAsKey('name') ->prototype('array') ->children() ; $firewallNodeBuilder ->scalarNode('pattern')->end() ->scalarNode('host')->end() ->arrayNode('methods') ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->prototype('scalar')->end() ->end() ->booleanNode('security')->defaultTrue()->end() ->scalarNode('user_checker') ->defaultValue('security.user_checker') ->treatNullLike('security.user_checker') ->info('The UserChecker to use when authenticating users in this firewall.') ->end() ->scalarNode('request_matcher')->end() ->scalarNode('access_denied_url')->end() ->scalarNode('access_denied_handler')->end() ->scalarNode('entry_point')->end() ->scalarNode('provider')->end() ->booleanNode('stateless')->defaultFalse()->end() ->scalarNode('context')->cannotBeEmpty()->end() ->booleanNode('logout_on_user_change') ->defaultFalse() ->info('When true, it will trigger a logout for the user if something has changed. This will be the default behavior as of Syfmony 4.0.') ->end() ->arrayNode('logout') ->treatTrueLike(array()) ->canBeUnset() ->children() ->scalarNode('csrf_parameter')->defaultValue('_csrf_token')->end() ->scalarNode('csrf_token_generator')->cannotBeEmpty()->end() ->scalarNode('csrf_token_id')->defaultValue('logout')->end() ->scalarNode('path')->defaultValue('/logout')->end() ->scalarNode('target')->defaultValue('/')->end() ->scalarNode('success_handler')->end() ->booleanNode('invalidate_session')->defaultTrue()->end() ->end() ->fixXmlConfig('delete_cookie') ->children() ->arrayNode('delete_cookies') ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && is_int(key($v)); }) ->then(function ($v) { return array_map(function ($v) { return array('name' => $v); }, $v); }) ->end() ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('path')->defaultNull()->end() ->scalarNode('domain')->defaultNull()->end() ->end() ->end() ->end() ->end() ->fixXmlConfig('handler') ->children() ->arrayNode('handlers') ->prototype('scalar')->end() ->end() ->end() ->end() ->arrayNode('anonymous') ->canBeUnset() ->children() ->scalarNode('secret')->defaultNull()->end() ->end() ->end() ->arrayNode('switch_user') ->canBeUnset() ->children() ->scalarNode('provider')->end() ->scalarNode('parameter')->defaultValue('_switch_user')->end() ->scalarNode('role')->defaultValue('ROLE_ALLOWED_TO_SWITCH')->end() ->booleanNode('stateless')->defaultValue(false)->end() ->end() ->end() ; $abstractFactoryKeys = array(); foreach ($factories as $factoriesAtPosition) { foreach ($factoriesAtPosition as $factory) { $name = str_replace('-', '_', $factory->getKey()); $factoryNode = $firewallNodeBuilder->arrayNode($name) ->canBeUnset() ; if ($factory instanceof AbstractFactory) { $abstractFactoryKeys[] = $name; } $factory->addConfiguration($factoryNode); } } // check for unreachable check paths $firewallNodeBuilder ->end() ->validate() ->ifTrue(function ($v) { return true === $v['security'] && isset($v['pattern']) && !isset($v['request_matcher']); }) ->then(function ($firewall) use ($abstractFactoryKeys) { foreach ($abstractFactoryKeys as $k) { if (!isset($firewall[$k]['check_path'])) { continue; } if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern'])); } } return $firewall; }) ->end() ; } private function addProvidersSection(ArrayNodeDefinition $rootNode) { $providerNodeBuilder = $rootNode ->fixXmlConfig('provider') ->children() ->arrayNode('providers') ->example(array( 'my_memory_provider' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), 'bar' => array('password' => 'bar', 'roles' => '[ROLE_USER, ROLE_ADMIN]'), ), ), ), 'my_entity_provider' => array('entity' => array('class' => 'SecurityBundle:User', 'property' => 'username')), )) ->isRequired() ->requiresAtLeastOneElement() ->useAttributeAsKey('name') ->prototype('array') ; $providerNodeBuilder ->children() ->scalarNode('id')->end() ->arrayNode('chain') ->fixXmlConfig('provider') ->children() ->arrayNode('providers') ->beforeNormalization() ->ifString() ->then(function ($v) { return preg_split('/\s*,\s*/', $v); }) ->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ; foreach ($this->userProviderFactories as $factory) { $name = str_replace('-', '_', $factory->getKey()); $factoryNode = $providerNodeBuilder->children()->arrayNode($name)->canBeUnset(); $factory->addConfiguration($factoryNode); } $providerNodeBuilder ->validate() ->ifTrue(function ($v) { return count($v) > 1; }) ->thenInvalid('You cannot set multiple provider types for the same provider') ->end() ->validate() ->ifTrue(function ($v) { return 0 === count($v); }) ->thenInvalid('You must set a provider definition for the provider.') ->end() ; } private function addEncodersSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('encoder') ->children() ->arrayNode('encoders') ->example(array( 'AppBundle\Entity\User1' => 'bcrypt', 'AppBundle\Entity\User2' => array( 'algorithm' => 'bcrypt', 'cost' => 13, ), )) ->requiresAtLeastOneElement() ->useAttributeAsKey('class') ->prototype('array') ->canBeUnset() ->performNoDeepMerging() ->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end() ->children() ->scalarNode('algorithm')->cannotBeEmpty()->end() ->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end() ->scalarNode('key_length')->defaultValue(40)->end() ->booleanNode('ignore_case')->defaultFalse()->end() ->booleanNode('encode_as_base64')->defaultTrue()->end() ->scalarNode('iterations')->defaultValue(5000)->end() ->integerNode('cost') ->min(4) ->max(31) ->defaultValue(13) ->end() ->scalarNode('id')->end() ->end() ->end() ->end() ->end() ; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/�����������������������0000775�0000000�0000000�00000000000�13247321071�0027365�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/���������������0000775�0000000�0000000�00000000000�13247321071�0030774�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AbstractFactory.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000017662�13247321071�0034535�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * AbstractFactory is the base class for all classes inheriting from * AbstractAuthenticationListener. * * @author Fabien Potencier <fabien@symfony.com> * @author Lukas Kahwe Smith <smith@pooteeweet.org> * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ abstract class AbstractFactory implements SecurityFactoryInterface { protected $options = array( 'check_path' => '/login_check', 'use_forward' => false, 'require_previous_session' => false, ); protected $defaultSuccessHandlerOptions = array( 'always_use_default_target_path' => false, 'default_target_path' => '/', 'login_path' => '/login', 'target_path_parameter' => '_target_path', 'use_referer' => false, ); protected $defaultFailureHandlerOptions = array( 'failure_path' => null, 'failure_forward' => false, 'login_path' => '/login', 'failure_path_parameter' => '_failure_path', ); public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId) { // authentication provider $authProviderId = $this->createAuthProvider($container, $id, $config, $userProviderId); // authentication listener $listenerId = $this->createListener($container, $id, $config, $userProviderId); // add remember-me aware tag if requested if ($this->isRememberMeAware($config)) { $container ->getDefinition($listenerId) ->addTag('security.remember_me_aware', array('id' => $id, 'provider' => $userProviderId)) ; } // create entry point if applicable (optional) $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPointId); return array($authProviderId, $listenerId, $entryPointId); } public function addConfiguration(NodeDefinition $node) { $builder = $node->children(); $builder ->scalarNode('provider')->end() ->booleanNode('remember_me')->defaultTrue()->end() ->scalarNode('success_handler')->end() ->scalarNode('failure_handler')->end() ; foreach (array_merge($this->options, $this->defaultSuccessHandlerOptions, $this->defaultFailureHandlerOptions) as $name => $default) { if (is_bool($default)) { $builder->booleanNode($name)->defaultValue($default); } else { $builder->scalarNode($name)->defaultValue($default); } } } final public function addOption($name, $default = null) { $this->options[$name] = $default; } /** * Subclasses must return the id of a service which implements the * AuthenticationProviderInterface. * * @param ContainerBuilder $container * @param string $id The unique id of the firewall * @param array $config The options array for this listener * @param string $userProviderId The id of the user provider * * @return string never null, the id of the authentication provider */ abstract protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId); /** * Subclasses must return the id of the abstract listener template. * * Listener definitions should inherit from the AbstractAuthenticationListener * like this: * * <service id="my.listener.id" * class="My\Concrete\Classname" * parent="security.authentication.listener.abstract" * abstract="true" /> * * In the above case, this method would return "my.listener.id". * * @return string */ abstract protected function getListenerId(); /** * Subclasses may create an entry point of their as they see fit. The * default implementation does not change the default entry point. * * @param ContainerBuilder $container * @param string $id * @param array $config * @param string $defaultEntryPointId * * @return string the entry point id */ protected function createEntryPoint($container, $id, $config, $defaultEntryPointId) { return $defaultEntryPointId; } /** * Subclasses may disable remember-me features for the listener, by * always returning false from this method. * * @return bool Whether a possibly configured RememberMeServices should be set for this listener */ protected function isRememberMeAware($config) { return $config['remember_me']; } protected function createListener($container, $id, $config, $userProvider) { $listenerId = $this->getListenerId(); $listener = new ChildDefinition($listenerId); $listener->replaceArgument(4, $id); $listener->replaceArgument(5, new Reference($this->createAuthenticationSuccessHandler($container, $id, $config))); $listener->replaceArgument(6, new Reference($this->createAuthenticationFailureHandler($container, $id, $config))); $listener->replaceArgument(7, array_intersect_key($config, $this->options)); $listenerId .= '.'.$id; $container->setDefinition($listenerId, $listener); return $listenerId; } protected function createAuthenticationSuccessHandler($container, $id, $config) { $successHandlerId = $this->getSuccessHandlerId($id); $options = array_intersect_key($config, $this->defaultSuccessHandlerOptions); if (isset($config['success_handler'])) { $successHandler = $container->setDefinition($successHandlerId, new ChildDefinition('security.authentication.custom_success_handler')); $successHandler->replaceArgument(0, new Reference($config['success_handler'])); $successHandler->replaceArgument(1, $options); $successHandler->replaceArgument(2, $id); } else { $successHandler = $container->setDefinition($successHandlerId, new ChildDefinition('security.authentication.success_handler')); $successHandler->addMethodCall('setOptions', array($options)); $successHandler->addMethodCall('setProviderKey', array($id)); } return $successHandlerId; } protected function createAuthenticationFailureHandler($container, $id, $config) { $id = $this->getFailureHandlerId($id); $options = array_intersect_key($config, $this->defaultFailureHandlerOptions); if (isset($config['failure_handler'])) { $failureHandler = $container->setDefinition($id, new ChildDefinition('security.authentication.custom_failure_handler')); $failureHandler->replaceArgument(0, new Reference($config['failure_handler'])); $failureHandler->replaceArgument(1, $options); } else { $failureHandler = $container->setDefinition($id, new ChildDefinition('security.authentication.failure_handler')); $failureHandler->addMethodCall('setOptions', array($options)); } return $id; } protected function getSuccessHandlerId($id) { return 'security.authentication.success_handler.'.$id.'.'.str_replace('-', '_', $this->getKey()); } protected function getFailureHandlerId($id) { return 'security.authentication.failure_handler.'.$id.'.'.str_replace('-', '_', $this->getKey()); } } ������������������������������������������������������������������������������FormLoginFactory.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000005750�13247321071�0034661�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * FormLoginFactory creates services for form login authentication. * * @author Fabien Potencier <fabien@symfony.com> * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class FormLoginFactory extends AbstractFactory { public function __construct() { $this->addOption('username_parameter', '_username'); $this->addOption('password_parameter', '_password'); $this->addOption('csrf_parameter', '_csrf_token'); $this->addOption('csrf_token_id', 'authenticate'); $this->addOption('post_only', true); } public function getPosition() { return 'form'; } public function getKey() { return 'form-login'; } public function addConfiguration(NodeDefinition $node) { parent::addConfiguration($node); $node ->children() ->scalarNode('csrf_token_generator')->cannotBeEmpty()->end() ->end() ; } protected function getListenerId() { return 'security.authentication.listener.form'; } protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) { $provider = 'security.authentication.provider.dao.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.dao')) ->replaceArgument(0, new Reference($userProviderId)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ; return $provider; } protected function createListener($container, $id, $config, $userProvider) { $listenerId = parent::createListener($container, $id, $config, $userProvider); $container ->getDefinition($listenerId) ->addArgument(isset($config['csrf_token_generator']) ? new Reference($config['csrf_token_generator']) : null) ; return $listenerId; } protected function createEntryPoint($container, $id, $config, $defaultEntryPoint) { $entryPointId = 'security.authentication.form_entry_point.'.$id; $container ->setDefinition($entryPointId, new ChildDefinition('security.authentication.form_entry_point')) ->addArgument(new Reference('security.http_utils')) ->addArgument($config['login_path']) ->addArgument($config['use_forward']) ; return $entryPointId; } } ������������������������FormLoginLdapFactory.php����������������������������������������������������������������������������0000664�0000000�0000000�00000004021�13247321071�0035450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * FormLoginLdapFactory creates services for form login ldap authentication. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * @author Charles Sarrazin <charles@sarraz.in> */ class FormLoginLdapFactory extends FormLoginFactory { protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) { $provider = 'security.authentication.provider.ldap_bind.'.$id; $definition = $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.ldap_bind')) ->replaceArgument(0, new Reference($userProviderId)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ->replaceArgument(3, new Reference($config['service'])) ->replaceArgument(4, $config['dn_string']) ; if (!empty($config['query_string'])) { $definition->addMethodCall('setQueryString', array($config['query_string'])); } return $provider; } public function addConfiguration(NodeDefinition $node) { parent::addConfiguration($node); $node ->children() ->scalarNode('service')->defaultValue('ldap')->end() ->scalarNode('dn_string')->defaultValue('{username}')->end() ->scalarNode('query_string')->end() ->end() ; } public function getKey() { return 'form-login-ldap'; } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GuardAuthenticationFactory.php����������������������������������������������������������������������0000664�0000000�0000000�00000011702�13247321071�0036721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * Configures the "guard" authentication provider key under a firewall. * * @author Ryan Weaver <ryan@knpuniversity.com> */ class GuardAuthenticationFactory implements SecurityFactoryInterface { public function getPosition() { return 'pre_auth'; } public function getKey() { return 'guard'; } public function addConfiguration(NodeDefinition $node) { $node ->fixXmlConfig('authenticator') ->children() ->scalarNode('provider') ->info('A key from the "providers" section of your security config, in case your user provider is different than the firewall') ->end() ->scalarNode('entry_point') ->info('A service id (of one of your authenticators) whose start() method should be called when an anonymous user hits a page that requires authentication') ->defaultValue(null) ->end() ->arrayNode('authenticators') ->info('An array of service ids for all of your "authenticators"') ->requiresAtLeastOneElement() ->prototype('scalar')->end() ->end() ->end() ; } public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $authenticatorIds = $config['authenticators']; $authenticatorReferences = array(); foreach ($authenticatorIds as $authenticatorId) { $authenticatorReferences[] = new Reference($authenticatorId); } $authenticators = new IteratorArgument($authenticatorReferences); // configure the GuardAuthenticationFactory to have the dynamic constructor arguments $providerId = 'security.authentication.provider.guard.'.$id; $container ->setDefinition($providerId, new ChildDefinition('security.authentication.provider.guard')) ->replaceArgument(0, $authenticators) ->replaceArgument(1, new Reference($userProvider)) ->replaceArgument(2, $id) ->replaceArgument(3, new Reference('security.user_checker.'.$id)) ; // listener $listenerId = 'security.authentication.listener.guard.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.guard')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, $authenticators); // determine the entryPointId to use $entryPointId = $this->determineEntryPoint($defaultEntryPoint, $config); // this is always injected - then the listener decides if it should be used $container ->getDefinition($listenerId) ->addTag('security.remember_me_aware', array('id' => $id, 'provider' => $userProvider)); return array($providerId, $listenerId, $entryPointId); } private function determineEntryPoint($defaultEntryPointId, array $config) { if ($defaultEntryPointId) { // explode if they've configured the entry_point, but there is already one if ($config['entry_point']) { throw new \LogicException(sprintf( 'The guard authentication provider cannot use the "%s" entry_point because another entry point is already configured by another provider! Either remove the other provider or move the entry_point configuration as a root key under your firewall (i.e. at the same level as "guard").', $config['entry_point'] )); } return $defaultEntryPointId; } if ($config['entry_point']) { // if it's configured explicitly, use it! return $config['entry_point']; } $authenticatorIds = $config['authenticators']; if (1 == count($authenticatorIds)) { // if there is only one authenticator, use that as the entry point return array_shift($authenticatorIds); } // we have multiple entry points - we must ask them to configure one throw new \LogicException(sprintf( 'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of you configurators (%s)', implode(', ', $authenticatorIds) )); } } ��������������������������������������������������������������HttpBasicFactory.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000005102�13247321071�0034635�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * HttpBasicFactory creates services for HTTP basic authentication. * * @author Fabien Potencier <fabien@symfony.com> */ class HttpBasicFactory implements SecurityFactoryInterface { public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $provider = 'security.authentication.provider.dao.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.dao')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ; // entry point $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPoint); // listener $listenerId = 'security.authentication.listener.basic.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.basic')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($entryPointId)); return array($provider, $listenerId, $entryPointId); } public function getPosition() { return 'http'; } public function getKey() { return 'http-basic'; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('provider')->end() ->scalarNode('realm')->defaultValue('Secured Area')->end() ->end() ; } protected function createEntryPoint($container, $id, $config, $defaultEntryPoint) { if (null !== $defaultEntryPoint) { return $defaultEntryPoint; } $entryPointId = 'security.authentication.basic_entry_point.'.$id; $container ->setDefinition($entryPointId, new ChildDefinition('security.authentication.basic_entry_point')) ->addArgument($config['realm']) ; return $entryPointId; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������HttpBasicLdapFactory.php����������������������������������������������������������������������������0000664�0000000�0000000�00000005032�13247321071�0035440�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * HttpBasicFactory creates services for HTTP basic authentication. * * @author Fabien Potencier <fabien@symfony.com> * @author Grégoire Pineau <lyrixx@lyrixx.info> * @author Charles Sarrazin <charles@sarraz.in> */ class HttpBasicLdapFactory extends HttpBasicFactory { public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $provider = 'security.authentication.provider.ldap_bind.'.$id; $definition = $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.ldap_bind')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ->replaceArgument(3, new Reference($config['service'])) ->replaceArgument(4, $config['dn_string']) ; // entry point $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPoint); if (!empty($config['query_string'])) { $definition->addMethodCall('setQueryString', array($config['query_string'])); } // listener $listenerId = 'security.authentication.listener.basic.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.basic')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($entryPointId)); return array($provider, $listenerId, $entryPointId); } public function addConfiguration(NodeDefinition $node) { parent::addConfiguration($node); $node ->children() ->scalarNode('service')->defaultValue('ldap')->end() ->scalarNode('dn_string')->defaultValue('{username}')->end() ->scalarNode('query_string')->end() ->end() ; } public function getKey() { return 'http-basic-ldap'; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������HttpDigestFactory.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000006344�13247321071�0035044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * HttpDigestFactory creates services for HTTP digest authentication. * * @author Fabien Potencier <fabien@symfony.com> * * @deprecated since 3.4, to be removed in 4.0 */ class HttpDigestFactory implements SecurityFactoryInterface { public function __construct($triggerDeprecation = true) { if ($triggerDeprecation) { @trigger_error(sprintf('The "%s" class and the whole HTTP digest authentication system is deprecated since Symfony 3.4 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); } } public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $provider = 'security.authentication.provider.dao.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.dao')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ; // entry point $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPoint); // listener $listenerId = 'security.authentication.listener.digest.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.digest')); $listener->replaceArgument(1, new Reference($userProvider)); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($entryPointId)); return array($provider, $listenerId, $entryPointId); } public function getPosition() { return 'http'; } public function getKey() { return 'http-digest'; } public function addConfiguration(NodeDefinition $node) { $node ->setDeprecated('The HTTP digest authentication is deprecated since 3.4 and will be removed in 4.0.') ->children() ->scalarNode('provider')->end() ->scalarNode('realm')->defaultValue('Secured Area')->end() ->scalarNode('secret')->isRequired()->cannotBeEmpty()->end() ->end() ; } protected function createEntryPoint($container, $id, $config, $defaultEntryPoint) { if (null !== $defaultEntryPoint) { return $defaultEntryPoint; } $entryPointId = 'security.authentication.digest_entry_point.'.$id; $container ->setDefinition($entryPointId, new ChildDefinition('security.authentication.digest_entry_point')) ->addArgument($config['realm']) ->addArgument($config['secret']) ; return $entryPointId; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������JsonLoginFactory.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000005333�13247321071�0034664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * JsonLoginFactory creates services for JSON login authentication. * * @author Kévin Dunglas <dunglas@gmail.com> */ class JsonLoginFactory extends AbstractFactory { public function __construct() { $this->addOption('username_path', 'username'); $this->addOption('password_path', 'password'); $this->defaultFailureHandlerOptions = array(); $this->defaultSuccessHandlerOptions = array(); } /** * {@inheritdoc} */ public function getPosition() { return 'form'; } /** * {@inheritdoc} */ public function getKey() { return 'json-login'; } /** * {@inheritdoc} */ protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) { $provider = 'security.authentication.provider.dao.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.dao')) ->replaceArgument(0, new Reference($userProviderId)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ; return $provider; } /** * {@inheritdoc} */ protected function getListenerId() { return 'security.authentication.listener.json'; } /** * {@inheritdoc} */ protected function isRememberMeAware($config) { return false; } /** * {@inheritdoc} */ protected function createListener($container, $id, $config, $userProvider) { $listenerId = $this->getListenerId(); $listener = new ChildDefinition($listenerId); $listener->replaceArgument(3, $id); $listener->replaceArgument(4, isset($config['success_handler']) ? new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)) : null); $listener->replaceArgument(5, isset($config['failure_handler']) ? new Reference($this->createAuthenticationFailureHandler($container, $id, $config)) : null); $listener->replaceArgument(6, array_intersect_key($config, $this->options)); $listenerId .= '.'.$id; $container->setDefinition($listenerId, $listener); return $listenerId; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������RememberMeFactory.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000013000�13247321071�0034770�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; class RememberMeFactory implements SecurityFactoryInterface { protected $options = array( 'name' => 'REMEMBERME', 'lifetime' => 31536000, 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => true, 'always_remember_me' => false, 'remember_me_parameter' => '_remember_me', ); public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { // authentication provider $authProviderId = 'security.authentication.provider.rememberme.'.$id; $container ->setDefinition($authProviderId, new ChildDefinition('security.authentication.provider.rememberme')) ->replaceArgument(0, new Reference('security.user_checker.'.$id)) ->addArgument($config['secret']) ->addArgument($id) ; // remember me services if (isset($config['token_provider'])) { $templateId = 'security.authentication.rememberme.services.persistent'; $rememberMeServicesId = $templateId.'.'.$id; } else { $templateId = 'security.authentication.rememberme.services.simplehash'; $rememberMeServicesId = $templateId.'.'.$id; } if ($container->hasDefinition('security.logout_listener.'.$id)) { $container ->getDefinition('security.logout_listener.'.$id) ->addMethodCall('addHandler', array(new Reference($rememberMeServicesId))) ; } $rememberMeServices = $container->setDefinition($rememberMeServicesId, new ChildDefinition($templateId)); $rememberMeServices->replaceArgument(1, $config['secret']); $rememberMeServices->replaceArgument(2, $id); if (isset($config['token_provider'])) { $rememberMeServices->addMethodCall('setTokenProvider', array( new Reference($config['token_provider']), )); } // remember-me options $rememberMeServices->replaceArgument(3, array_intersect_key($config, $this->options)); // attach to remember-me aware listeners $userProviders = array(); foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) { foreach ($attributes as $attribute) { if (!isset($attribute['id']) || $attribute['id'] !== $id) { continue; } if (!isset($attribute['provider'])) { throw new \RuntimeException('Each "security.remember_me_aware" tag must have a provider attribute.'); } $userProviders[] = new Reference($attribute['provider']); $container ->getDefinition($serviceId) ->addMethodCall('setRememberMeServices', array(new Reference($rememberMeServicesId))) ; } } if ($config['user_providers']) { $userProviders = array(); foreach ($config['user_providers'] as $providerName) { $userProviders[] = new Reference('security.user.provider.concrete.'.$providerName); } } if (0 === count($userProviders)) { throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.'); } $rememberMeServices->replaceArgument(0, array_unique($userProviders)); // remember-me listener $listenerId = 'security.authentication.listener.rememberme.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.rememberme')); $listener->replaceArgument(1, new Reference($rememberMeServicesId)); $listener->replaceArgument(5, $config['catch_exceptions']); return array($authProviderId, $listenerId, $defaultEntryPoint); } public function getPosition() { return 'remember_me'; } public function getKey() { return 'remember-me'; } public function addConfiguration(NodeDefinition $node) { $builder = $node ->fixXmlConfig('user_provider') ->children() ; $builder ->scalarNode('secret')->isRequired()->cannotBeEmpty()->end() ->scalarNode('token_provider')->end() ->arrayNode('user_providers') ->beforeNormalization() ->ifString()->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() ->end() ->scalarNode('catch_exceptions')->defaultTrue()->end() ; foreach ($this->options as $name => $value) { if (is_bool($value)) { $builder->booleanNode($name)->defaultValue($value); } else { $builder->scalarNode($name)->defaultValue($value); } } } } RemoteUserFactory.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000004072�13247321071�0035053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * RemoteUserFactory creates services for REMOTE_USER based authentication. * * @author Fabien Potencier <fabien@symfony.com> * @author Maxime Douailin <maxime.douailin@gmail.com> */ class RemoteUserFactory implements SecurityFactoryInterface { public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $providerId = 'security.authentication.provider.pre_authenticated.'.$id; $container ->setDefinition($providerId, new ChildDefinition('security.authentication.provider.pre_authenticated')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->addArgument($id) ; $listenerId = 'security.authentication.listener.remote_user.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.remote_user')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, $config['user']); return array($providerId, $listenerId, $defaultEntryPoint); } public function getPosition() { return 'pre_auth'; } public function getKey() { return 'remote-user'; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('provider')->end() ->scalarNode('user')->defaultValue('REMOTE_USER')->end() ->end() ; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SecurityFactoryInterface.php������������������������������������������������������������������������0000664�0000000�0000000�00000003422�13247321071�0036407�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * SecurityFactoryInterface is the interface for all security authentication listener. * * @author Fabien Potencier <fabien@symfony.com> */ interface SecurityFactoryInterface { /** * Configures the container services required to use the authentication listener. * * @param ContainerBuilder $container * @param string $id The unique id of the firewall * @param array $config The options array for the listener * @param string $userProvider The service id of the user provider * @param string $defaultEntryPoint * * @return array containing three values: * - the provider id * - the listener id * - the entry point id */ public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint); /** * Defines the position at which the provider is called. * Possible values: pre_auth, form, http, and remember_me. * * @return string */ public function getPosition(); /** * Defines the configuration key used to reference the provider * in the firewall configuration. * * @return string */ public function getKey(); public function addConfiguration(NodeDefinition $builder); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SimpleFormFactory.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000005276�13247321071�0035045�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * @author Jordi Boggiano <j.boggiano@seld.be> */ class SimpleFormFactory extends FormLoginFactory { public function __construct() { parent::__construct(); $this->addOption('authenticator', null); } public function getKey() { return 'simple-form'; } public function addConfiguration(NodeDefinition $node) { parent::addConfiguration($node); $node->children() ->scalarNode('authenticator')->cannotBeEmpty()->end() ->end(); } protected function getListenerId() { return 'security.authentication.listener.simple_form'; } protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) { $provider = 'security.authentication.provider.simple_form.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.simple')) ->replaceArgument(0, new Reference($config['authenticator'])) ->replaceArgument(1, new Reference($userProviderId)) ->replaceArgument(2, $id) ; return $provider; } protected function createListener($container, $id, $config, $userProvider) { $listenerId = parent::createListener($container, $id, $config, $userProvider); $simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id; $simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new ChildDefinition('security.authentication.simple_success_failure_handler')); $simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator'])); $simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id))); $simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id))); $listener = $container->getDefinition($listenerId); $listener->replaceArgument(5, new Reference($simpleAuthHandlerId)); $listener->replaceArgument(6, new Reference($simpleAuthHandlerId)); $listener->addArgument(new Reference($config['authenticator'])); return $listenerId; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SimplePreAuthenticationFactory.php������������������������������������������������������������������0000664�0000000�0000000�00000003722�13247321071�0037562�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory�����������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * @author Jordi Boggiano <j.boggiano@seld.be> */ class SimplePreAuthenticationFactory implements SecurityFactoryInterface { public function getPosition() { return 'pre_auth'; } public function getKey() { return 'simple-preauth'; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('provider')->end() ->scalarNode('authenticator')->cannotBeEmpty()->end() ->end() ; } public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $provider = 'security.authentication.provider.simple_preauth.'.$id; $container ->setDefinition($provider, new ChildDefinition('security.authentication.provider.simple')) ->replaceArgument(0, new Reference($config['authenticator'])) ->replaceArgument(1, new Reference($userProvider)) ->replaceArgument(2, $id) ; // listener $listenerId = 'security.authentication.listener.simple_preauth.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.simple_preauth')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($config['authenticator'])); return array($provider, $listenerId, null); } } ����������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php0000664�0000000�0000000�00000004222�13247321071�0033502�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * X509Factory creates services for X509 certificate authentication. * * @author Fabien Potencier <fabien@symfony.com> */ class X509Factory implements SecurityFactoryInterface { public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $providerId = 'security.authentication.provider.pre_authenticated.'.$id; $container ->setDefinition($providerId, new ChildDefinition('security.authentication.provider.pre_authenticated')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->addArgument($id) ; // listener $listenerId = 'security.authentication.listener.x509.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.x509')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, $config['user']); $listener->replaceArgument(4, $config['credentials']); return array($providerId, $listenerId, $defaultEntryPoint); } public function getPosition() { return 'pre_auth'; } public function getKey() { return 'x509'; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('provider')->end() ->scalarNode('user')->defaultValue('SSL_CLIENT_S_DN_Email')->end() ->scalarNode('credentials')->defaultValue('SSL_CLIENT_S_DN')->end() ->end() ; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/����������0000775�0000000�0000000�00000000000�13247321071�0032016�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������InMemoryFactory.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000004272�13247321071�0035544�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Parameter; /** * InMemoryFactory creates services for the memory provider. * * @author Fabien Potencier <fabien@symfony.com> * @author Christophe Coevoet <stof@notk.org> */ class InMemoryFactory implements UserProviderFactoryInterface { public function create(ContainerBuilder $container, $id, $config) { $definition = $container->setDefinition($id, new ChildDefinition('security.user.provider.in_memory')); $defaultPassword = new Parameter('container.build_id'); $users = array(); foreach ($config['users'] as $username => $user) { $users[$username] = array('password' => null !== $user['password'] ? (string) $user['password'] : $defaultPassword, 'roles' => $user['roles']); } $definition->addArgument($users); } public function getKey() { return 'memory'; } public function addConfiguration(NodeDefinition $node) { $node ->fixXmlConfig('user') ->children() ->arrayNode('users') ->useAttributeAsKey('name') ->normalizeKeys(false) ->prototype('array') ->children() ->scalarNode('password')->defaultNull()->end() ->arrayNode('roles') ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������LdapFactory.php�������������������������������������������������������������������������������������0000664�0000000�0000000�00000004640�13247321071�0034664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * LdapFactory creates services for Ldap user provider. * * @author Grégoire Pineau <lyrixx@lyrixx.info> * @author Charles Sarrazin <charles@sarraz.in> */ class LdapFactory implements UserProviderFactoryInterface { public function create(ContainerBuilder $container, $id, $config) { $container ->setDefinition($id, new ChildDefinition('security.user.provider.ldap')) ->replaceArgument(0, new Reference($config['service'])) ->replaceArgument(1, $config['base_dn']) ->replaceArgument(2, $config['search_dn']) ->replaceArgument(3, $config['search_password']) ->replaceArgument(4, $config['default_roles']) ->replaceArgument(5, $config['uid_key']) ->replaceArgument(6, $config['filter']) ->replaceArgument(7, $config['password_attribute']) ; } public function getKey() { return 'ldap'; } public function addConfiguration(NodeDefinition $node) { $node ->children() ->scalarNode('service')->isRequired()->cannotBeEmpty()->defaultValue('ldap')->end() ->scalarNode('base_dn')->isRequired()->cannotBeEmpty()->end() ->scalarNode('search_dn')->end() ->scalarNode('search_password')->end() ->arrayNode('default_roles') ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->requiresAtLeastOneElement() ->prototype('scalar')->end() ->end() ->scalarNode('uid_key')->defaultValue('sAMAccountName')->end() ->scalarNode('filter')->defaultValue('({uid_key}={username})')->end() ->scalarNode('password_attribute')->defaultNull()->end() ->end() ; } } ������������������������������������������������������������������������������������������������UserProviderFactoryInterface.php��������������������������������������������������������������������0000664�0000000�0000000�00000001514�13247321071�0040253�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * UserProviderFactoryInterface is the interface for all user provider factories. * * @author Fabien Potencier <fabien@symfony.com> * @author Christophe Coevoet <stof@notk.org> */ interface UserProviderFactoryInterface { public function create(ContainerBuilder $container, $id, $config); public function getKey(); public function addConfiguration(NodeDefinition $builder); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php�����������0000664�0000000�0000000�00000106442�13247321071�0032002�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Config\FileLocator; use Symfony\Component\Security\Core\Authorization\ExpressionLanguage; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; /** * SecurityExtension. * * @author Fabien Potencier <fabien@symfony.com> * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class SecurityExtension extends Extension { private $requestMatchers = array(); private $expressions = array(); private $contextListeners = array(); private $listenerPositions = array('pre_auth', 'form', 'http', 'remember_me'); private $factories = array(); private $userProviderFactories = array(); private $expressionLanguage; private $logoutOnUserChangeByContextKey = array(); public function __construct() { foreach ($this->listenerPositions as $position) { $this->factories[$position] = array(); } } public function load(array $configs, ContainerBuilder $container) { if (!array_filter($configs)) { return; } $mainConfig = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($mainConfig, $configs); // load services $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('security.xml'); $loader->load('security_listeners.xml'); $loader->load('security_rememberme.xml'); $loader->load('templating_php.xml'); $loader->load('templating_twig.xml'); $loader->load('collectors.xml'); $loader->load('guard.xml'); $container->getDefinition('security.authentication.guard_handler')->setPrivate(true); $container->getDefinition('security.firewall')->setPrivate(true); $container->getDefinition('security.firewall.context')->setPrivate(true); $container->getDefinition('security.validator.user_password')->setPrivate(true); $container->getDefinition('security.rememberme.response_listener')->setPrivate(true); $container->getDefinition('templating.helper.logout_url')->setPrivate(true); $container->getDefinition('templating.helper.security')->setPrivate(true); $container->getAlias('security.encoder_factory')->setPrivate(true); if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) { $loader->load('security_debug.xml'); $container->getAlias('security.firewall')->setPrivate(true); } if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { $container->removeDefinition('security.expression_language'); $container->removeDefinition('security.access.expression_voter'); } // set some global scalars $container->setParameter('security.access.denied_url', $config['access_denied_url']); $container->setParameter('security.authentication.manager.erase_credentials', $config['erase_credentials']); $container->setParameter('security.authentication.session_strategy.strategy', $config['session_fixation_strategy']); if (isset($config['access_decision_manager']['service'])) { $container->setAlias('security.access.decision_manager', $config['access_decision_manager']['service'])->setPrivate(true); } else { $container ->getDefinition('security.access.decision_manager') ->addArgument($config['access_decision_manager']['strategy']) ->addArgument($config['access_decision_manager']['allow_if_all_abstain']) ->addArgument($config['access_decision_manager']['allow_if_equal_granted_denied']); } $container->setParameter('security.access.always_authenticate_before_granting', $config['always_authenticate_before_granting']); $container->setParameter('security.authentication.hide_user_not_found', $config['hide_user_not_found']); $this->createFirewalls($config, $container); $this->createAuthorization($config, $container); $this->createRoleHierarchy($config, $container); if ($config['encoders']) { $this->createEncoders($config['encoders'], $container); } if (class_exists(Application::class)) { $loader->load('console.xml'); $container->getDefinition('security.command.user_password_encoder')->replaceArgument(1, array_keys($config['encoders'])); } // load ACL if (isset($config['acl'])) { $this->aclLoad($config['acl'], $container); } else { $container->removeDefinition('security.command.init_acl'); $container->removeDefinition('security.command.set_acl'); } $container->registerForAutoconfiguration(VoterInterface::class) ->addTag('security.voter'); if (\PHP_VERSION_ID < 70000) { // add some required classes for compilation $this->addClassesToCompile(array( 'Symfony\Component\Security\Http\Firewall', 'Symfony\Component\Security\Core\User\UserProviderInterface', 'Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager', 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage', 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager', 'Symfony\Component\Security\Core\Authorization\AuthorizationChecker', 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface', 'Symfony\Bundle\SecurityBundle\Security\FirewallConfig', 'Symfony\Bundle\SecurityBundle\Security\FirewallContext', 'Symfony\Component\HttpFoundation\RequestMatcher', )); } } private function aclLoad($config, ContainerBuilder $container) { if (!interface_exists('Symfony\Component\Security\Acl\Model\AclInterface')) { throw new \LogicException('You must install symfony/security-acl in order to use the ACL functionality.'); } $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('security_acl.xml'); if (isset($config['cache']['id'])) { $container->setAlias('security.acl.cache', $config['cache']['id'])->setPrivate(true); } $container->getDefinition('security.acl.voter.basic_permissions')->addArgument($config['voter']['allow_if_object_identity_unavailable']); // custom ACL provider if (isset($config['provider'])) { $container->setAlias('security.acl.provider', $config['provider'])->setPrivate(true); return; } $this->configureDbalAclProvider($config, $container, $loader); } private function configureDbalAclProvider(array $config, ContainerBuilder $container, $loader) { $loader->load('security_acl_dbal.xml'); $container->getDefinition('security.acl.dbal.schema')->setPrivate(true); $container->getAlias('security.acl.dbal.connection')->setPrivate(true); $container->getAlias('security.acl.provider')->setPrivate(true); if (null !== $config['connection']) { $container->setAlias('security.acl.dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['connection']))->setPrivate(true); } $container ->getDefinition('security.acl.dbal.schema_listener') ->addTag('doctrine.event_listener', array( 'connection' => $config['connection'], 'event' => 'postGenerateSchema', 'lazy' => true, )) ; $container->getDefinition('security.acl.cache.doctrine')->addArgument($config['cache']['prefix']); $container->setParameter('security.acl.dbal.class_table_name', $config['tables']['class']); $container->setParameter('security.acl.dbal.entry_table_name', $config['tables']['entry']); $container->setParameter('security.acl.dbal.oid_table_name', $config['tables']['object_identity']); $container->setParameter('security.acl.dbal.oid_ancestors_table_name', $config['tables']['object_identity_ancestors']); $container->setParameter('security.acl.dbal.sid_table_name', $config['tables']['security_identity']); } private function createRoleHierarchy(array $config, ContainerBuilder $container) { if (!isset($config['role_hierarchy']) || 0 === count($config['role_hierarchy'])) { $container->removeDefinition('security.access.role_hierarchy_voter'); return; } $container->setParameter('security.role_hierarchy.roles', $config['role_hierarchy']); $container->removeDefinition('security.access.simple_role_voter'); } private function createAuthorization($config, ContainerBuilder $container) { if (!$config['access_control']) { return; } if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Symfony\\Component\\Security\\Http\\AccessMap', )); } foreach ($config['access_control'] as $access) { $matcher = $this->createRequestMatcher( $container, $access['path'], $access['host'], $access['methods'], $access['ips'] ); $attributes = $access['roles']; if ($access['allow_if']) { $attributes[] = $this->createExpression($container, $access['allow_if']); } $container->getDefinition('security.access_map') ->addMethodCall('add', array($matcher, $attributes, $access['requires_channel'])); } } private function createFirewalls($config, ContainerBuilder $container) { if (!isset($config['firewalls'])) { return; } $firewalls = $config['firewalls']; $providerIds = $this->createUserProviders($config, $container); // make the ContextListener aware of the configured user providers $contextListenerDefinition = $container->getDefinition('security.context_listener'); $arguments = $contextListenerDefinition->getArguments(); $userProviders = array(); foreach ($providerIds as $userProviderId) { $userProviders[] = new Reference($userProviderId); } $arguments[1] = new IteratorArgument($userProviders); $contextListenerDefinition->setArguments($arguments); $customUserChecker = false; // load firewall map $mapDef = $container->getDefinition('security.firewall.map'); $map = $authenticationProviders = $contextRefs = array(); foreach ($firewalls as $name => $firewall) { if (isset($firewall['user_checker']) && 'security.user_checker' !== $firewall['user_checker']) { $customUserChecker = true; } $configId = 'security.firewall.map.config.'.$name; list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId); $contextId = 'security.firewall.map.context.'.$name; $context = $container->setDefinition($contextId, new ChildDefinition('security.firewall.context')); $context ->replaceArgument(0, new IteratorArgument($listeners)) ->replaceArgument(1, $exceptionListener) ->replaceArgument(2, new Reference($configId)) ; $contextRefs[$contextId] = new Reference($contextId); $map[$contextId] = $matcher; } $mapDef->replaceArgument(0, ServiceLocatorTagPass::register($container, $contextRefs)); $mapDef->replaceArgument(1, new IteratorArgument($map)); // add authentication providers to authentication manager $authenticationProviders = array_map(function ($id) { return new Reference($id); }, array_values(array_unique($authenticationProviders))); $container ->getDefinition('security.authentication.manager') ->replaceArgument(0, new IteratorArgument($authenticationProviders)) ; // register an autowire alias for the UserCheckerInterface if no custom user checker service is configured if (!$customUserChecker) { $container->setAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', new Alias('security.user_checker', false)); } } private function createFirewall(ContainerBuilder $container, $id, $firewall, &$authenticationProviders, $providerIds, $configId) { $config = $container->setDefinition($configId, new ChildDefinition('security.firewall.config')); $config->replaceArgument(0, $id); $config->replaceArgument(1, $firewall['user_checker']); // Matcher $matcher = null; if (isset($firewall['request_matcher'])) { $matcher = new Reference($firewall['request_matcher']); } elseif (isset($firewall['pattern']) || isset($firewall['host'])) { $pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null; $host = isset($firewall['host']) ? $firewall['host'] : null; $methods = isset($firewall['methods']) ? $firewall['methods'] : array(); $matcher = $this->createRequestMatcher($container, $pattern, $host, $methods); } $config->replaceArgument(2, $matcher ? (string) $matcher : null); $config->replaceArgument(3, $firewall['security']); // Security disabled? if (false === $firewall['security']) { return array($matcher, array(), null); } $config->replaceArgument(4, $firewall['stateless']); // Provider id (take the first registered provider if none defined) $defaultProvider = null; if (isset($firewall['provider'])) { if (!isset($providerIds[$normalizedName = str_replace('-', '_', $firewall['provider'])])) { throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall['provider'])); } $defaultProvider = $providerIds[$normalizedName]; } elseif (1 === count($providerIds)) { $defaultProvider = reset($providerIds); } $config->replaceArgument(5, $defaultProvider); // Register listeners $listeners = array(); $listenerKeys = array(); // Channel listener $listeners[] = new Reference('security.channel_listener'); $contextKey = null; // Context serializer listener if (false === $firewall['stateless']) { $contextKey = $id; if (isset($firewall['context'])) { $contextKey = $firewall['context']; } if (!$logoutOnUserChange = $firewall['logout_on_user_change']) { @trigger_error(sprintf('Not setting "logout_on_user_change" to true on firewall "%s" is deprecated as of 3.4, it will always be true in 4.0.', $id), E_USER_DEPRECATED); } if (isset($this->logoutOnUserChangeByContextKey[$contextKey]) && $this->logoutOnUserChangeByContextKey[$contextKey][1] !== $logoutOnUserChange) { throw new InvalidConfigurationException(sprintf('Firewalls "%s" and "%s" need to have the same value for option "logout_on_user_change" as they are sharing the context "%s"', $this->logoutOnUserChangeByContextKey[$contextKey][0], $id, $contextKey)); } $this->logoutOnUserChangeByContextKey[$contextKey] = array($id, $logoutOnUserChange); $listeners[] = new Reference($this->createContextListener($container, $contextKey, $logoutOnUserChange)); } $config->replaceArgument(6, $contextKey); // Logout listener if (isset($firewall['logout'])) { $listenerKeys[] = 'logout'; $listenerId = 'security.logout_listener.'.$id; $listener = $container->setDefinition($listenerId, new ChildDefinition('security.logout_listener')); $listener->replaceArgument(3, array( 'csrf_parameter' => $firewall['logout']['csrf_parameter'], 'csrf_token_id' => $firewall['logout']['csrf_token_id'], 'logout_path' => $firewall['logout']['path'], )); $listeners[] = new Reference($listenerId); // add logout success handler if (isset($firewall['logout']['success_handler'])) { $logoutSuccessHandlerId = $firewall['logout']['success_handler']; } else { $logoutSuccessHandlerId = 'security.logout.success_handler.'.$id; $logoutSuccessHandler = $container->setDefinition($logoutSuccessHandlerId, new ChildDefinition('security.logout.success_handler')); $logoutSuccessHandler->replaceArgument(1, $firewall['logout']['target']); } $listener->replaceArgument(2, new Reference($logoutSuccessHandlerId)); // add CSRF provider if (isset($firewall['logout']['csrf_token_generator'])) { $listener->addArgument(new Reference($firewall['logout']['csrf_token_generator'])); } // add session logout handler if (true === $firewall['logout']['invalidate_session'] && false === $firewall['stateless']) { $listener->addMethodCall('addHandler', array(new Reference('security.logout.handler.session'))); } // add cookie logout handler if (count($firewall['logout']['delete_cookies']) > 0) { $cookieHandlerId = 'security.logout.handler.cookie_clearing.'.$id; $cookieHandler = $container->setDefinition($cookieHandlerId, new ChildDefinition('security.logout.handler.cookie_clearing')); $cookieHandler->addArgument($firewall['logout']['delete_cookies']); $listener->addMethodCall('addHandler', array(new Reference($cookieHandlerId))); } // add custom handlers foreach ($firewall['logout']['handlers'] as $handlerId) { $listener->addMethodCall('addHandler', array(new Reference($handlerId))); } // register with LogoutUrlGenerator $container ->getDefinition('security.logout_url_generator') ->addMethodCall('registerListener', array( $id, $firewall['logout']['path'], $firewall['logout']['csrf_token_id'], $firewall['logout']['csrf_parameter'], isset($firewall['logout']['csrf_token_generator']) ? new Reference($firewall['logout']['csrf_token_generator']) : null, false === $firewall['stateless'] && isset($firewall['context']) ? $firewall['context'] : null, )) ; } // Determine default entry point $configuredEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null; // Authentication listeners list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $providerIds, $configuredEntryPoint); $config->replaceArgument(7, $configuredEntryPoint ?: $defaultEntryPoint); $listeners = array_merge($listeners, $authListeners); // Switch user listener if (isset($firewall['switch_user'])) { $listenerKeys[] = 'switch_user'; $listeners[] = new Reference($this->createSwitchUserListener($container, $id, $firewall['switch_user'], $defaultProvider, $firewall['stateless'], $providerIds)); } // Access listener $listeners[] = new Reference('security.access_listener'); // Exception listener $exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless'])); $config->replaceArgument(8, isset($firewall['access_denied_handler']) ? $firewall['access_denied_handler'] : null); $config->replaceArgument(9, isset($firewall['access_denied_url']) ? $firewall['access_denied_url'] : null); $container->setAlias('security.user_checker.'.$id, new Alias($firewall['user_checker'], false)); foreach ($this->factories as $position) { foreach ($position as $factory) { $key = str_replace('-', '_', $factory->getKey()); if (array_key_exists($key, $firewall)) { $listenerKeys[] = $key; } } } if (isset($firewall['anonymous'])) { $listenerKeys[] = 'anonymous'; } $config->replaceArgument(10, $listenerKeys); $config->replaceArgument(11, isset($firewall['switch_user']) ? $firewall['switch_user'] : null); return array($matcher, $listeners, $exceptionListener); } private function createContextListener($container, $contextKey, $logoutUserOnChange) { if (isset($this->contextListeners[$contextKey])) { return $this->contextListeners[$contextKey]; } $listenerId = 'security.context_listener.'.count($this->contextListeners); $listener = $container->setDefinition($listenerId, new ChildDefinition('security.context_listener')); $listener->replaceArgument(2, $contextKey); $listener->addMethodCall('setLogoutOnUserChange', array($logoutUserOnChange)); return $this->contextListeners[$contextKey] = $listenerId; } private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider = null, array $providerIds, $defaultEntryPoint) { $listeners = array(); $hasListeners = false; foreach ($this->listenerPositions as $position) { foreach ($this->factories[$position] as $factory) { $key = str_replace('-', '_', $factory->getKey()); if (isset($firewall[$key])) { if (isset($firewall[$key]['provider'])) { if (!isset($providerIds[$normalizedName = str_replace('-', '_', $firewall[$key]['provider'])])) { throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall[$key]['provider'])); } $userProvider = $providerIds[$normalizedName]; } elseif ('remember_me' === $key) { // RememberMeFactory will use the firewall secret when created $userProvider = null; } else { $userProvider = $defaultProvider ?: $this->getFirstProvider($id, $key, $providerIds); } list($provider, $listenerId, $defaultEntryPoint) = $factory->create($container, $id, $firewall[$key], $userProvider, $defaultEntryPoint); $listeners[] = new Reference($listenerId); $authenticationProviders[] = $provider; $hasListeners = true; } } } // Anonymous if (isset($firewall['anonymous'])) { if (null === $firewall['anonymous']['secret']) { $firewall['anonymous']['secret'] = new Parameter('container.build_hash'); } $listenerId = 'security.authentication.listener.anonymous.'.$id; $container ->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.anonymous')) ->replaceArgument(1, $firewall['anonymous']['secret']) ; $listeners[] = new Reference($listenerId); $providerId = 'security.authentication.provider.anonymous.'.$id; $container ->setDefinition($providerId, new ChildDefinition('security.authentication.provider.anonymous')) ->replaceArgument(0, $firewall['anonymous']['secret']) ; $authenticationProviders[] = $providerId; $hasListeners = true; } if (false === $hasListeners) { throw new InvalidConfigurationException(sprintf('No authentication listener registered for firewall "%s".', $id)); } return array($listeners, $defaultEntryPoint); } private function createEncoders($encoders, ContainerBuilder $container) { $encoderMap = array(); foreach ($encoders as $class => $encoder) { $encoderMap[$class] = $this->createEncoder($encoder, $container); } $container ->getDefinition('security.encoder_factory.generic') ->setArguments(array($encoderMap)) ; } private function createEncoder($config, ContainerBuilder $container) { // a custom encoder service if (isset($config['id'])) { return new Reference($config['id']); } // plaintext encoder if ('plaintext' === $config['algorithm']) { $arguments = array($config['ignore_case']); return array( 'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', 'arguments' => $arguments, ); } // pbkdf2 encoder if ('pbkdf2' === $config['algorithm']) { return array( 'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder', 'arguments' => array( $config['hash_algorithm'], $config['encode_as_base64'], $config['iterations'], $config['key_length'], ), ); } // bcrypt encoder if ('bcrypt' === $config['algorithm']) { return array( 'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', 'arguments' => array($config['cost']), ); } // Argon2i encoder if ('argon2i' === $config['algorithm']) { if (!Argon2iPasswordEncoder::isSupported()) { throw new InvalidConfigurationException('Argon2i algorithm is not supported. Please install the libsodium extension or upgrade to PHP 7.2+.'); } return array( 'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder', 'arguments' => array(), ); } // run-time configured encoder return $config; } // Parses user providers and returns an array of their ids private function createUserProviders($config, ContainerBuilder $container) { $providerIds = array(); foreach ($config['providers'] as $name => $provider) { $id = $this->createUserDaoProvider($name, $provider, $container); $providerIds[str_replace('-', '_', $name)] = $id; } return $providerIds; } // Parses a <provider> tag and returns the id for the related user provider service private function createUserDaoProvider($name, $provider, ContainerBuilder $container) { $name = $this->getUserProviderId($name); // Doctrine Entity and In-memory DAO provider are managed by factories foreach ($this->userProviderFactories as $factory) { $key = str_replace('-', '_', $factory->getKey()); if (!empty($provider[$key])) { $factory->create($container, $name, $provider[$key]); return $name; } } // Existing DAO service provider if (isset($provider['id'])) { $container->setAlias($name, new Alias($provider['id'], false)); return $provider['id']; } // Chain provider if (isset($provider['chain'])) { $providers = array(); foreach ($provider['chain']['providers'] as $providerName) { $providers[] = new Reference($this->getUserProviderId($providerName)); } $container ->setDefinition($name, new ChildDefinition('security.user.provider.chain')) ->addArgument(new IteratorArgument($providers)); return $name; } throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name)); } private function getUserProviderId($name) { return 'security.user.provider.concrete.'.strtolower($name); } private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless) { $exceptionListenerId = 'security.exception_listener.'.$id; $listener = $container->setDefinition($exceptionListenerId, new ChildDefinition('security.exception_listener')); $listener->replaceArgument(3, $id); $listener->replaceArgument(4, null === $defaultEntryPoint ? null : new Reference($defaultEntryPoint)); $listener->replaceArgument(8, $stateless); // access denied handler setup if (isset($config['access_denied_handler'])) { $listener->replaceArgument(6, new Reference($config['access_denied_handler'])); } elseif (isset($config['access_denied_url'])) { $listener->replaceArgument(5, $config['access_denied_url']); } return $exceptionListenerId; } private function createSwitchUserListener($container, $id, $config, $defaultProvider, $stateless, $providerIds) { $userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : ($defaultProvider ?: $this->getFirstProvider($id, 'switch_user', $providerIds)); // in 4.0, ignore the `switch_user.stateless` key if $stateless is `true` if ($stateless && false === $config['stateless']) { @trigger_error(sprintf('Firewall "%s" is configured as "stateless" but the "switch_user.stateless" key is set to false. Both should have the same value, the firewall\'s "stateless" value will be used as default value for the "switch_user.stateless" key in 4.0.', $id), E_USER_DEPRECATED); } $switchUserListenerId = 'security.authentication.switchuser_listener.'.$id; $listener = $container->setDefinition($switchUserListenerId, new ChildDefinition('security.authentication.switchuser_listener')); $listener->replaceArgument(1, new Reference($userProvider)); $listener->replaceArgument(2, new Reference('security.user_checker.'.$id)); $listener->replaceArgument(3, $id); $listener->replaceArgument(6, $config['parameter']); $listener->replaceArgument(7, $config['role']); $listener->replaceArgument(9, $config['stateless']); return $switchUserListenerId; } private function createExpression($container, $expression) { if (isset($this->expressions[$id = 'security.expression.'.ContainerBuilder::hash($expression)])) { return $this->expressions[$id]; } $container ->register($id, 'Symfony\Component\ExpressionLanguage\SerializedParsedExpression') ->setPublic(false) ->addArgument($expression) ->addArgument(serialize($this->getExpressionLanguage()->parse($expression, array('token', 'user', 'object', 'roles', 'request', 'trust_resolver'))->getNodes())) ; return $this->expressions[$id] = new Reference($id); } private function createRequestMatcher($container, $path = null, $host = null, $methods = array(), $ip = null, array $attributes = array()) { if ($methods) { $methods = array_map('strtoupper', (array) $methods); } $id = 'security.request_matcher.'.ContainerBuilder::hash(array($path, $host, $methods, $ip, $attributes)); if (isset($this->requestMatchers[$id])) { return $this->requestMatchers[$id]; } // only add arguments that are necessary $arguments = array($path, $host, $methods, $ip, $attributes); while (count($arguments) > 0 && !end($arguments)) { array_pop($arguments); } $container ->register($id, 'Symfony\Component\HttpFoundation\RequestMatcher') ->setPublic(false) ->setArguments($arguments) ; return $this->requestMatchers[$id] = new Reference($id); } public function addSecurityListenerFactory(SecurityFactoryInterface $factory) { $this->factories[$factory->getPosition()][] = $factory; } public function addUserProviderFactory(UserProviderFactoryInterface $factory) { $this->userProviderFactories[] = $factory; } /** * Returns the base path for the XSD files. * * @return string The XSD base path */ public function getXsdValidationBasePath() { return __DIR__.'/../Resources/config/schema'; } public function getNamespace() { return 'http://symfony.com/schema/dic/security'; } public function getConfiguration(array $config, ContainerBuilder $container) { // first assemble the factories return new MainConfiguration($this->factories, $this->userProviderFactories); } private function getExpressionLanguage() { if (null === $this->expressionLanguage) { if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(); } return $this->expressionLanguage; } /** * @deprecated since version 3.4, to be removed in 4.0 */ private function getFirstProvider($firewallName, $listenerName, array $providerIds) { @trigger_error(sprintf('Listener "%s" on firewall "%s" has no "provider" set but multiple providers exist. Using the first configured provider (%s) is deprecated since Symfony 3.4 and will throw an exception in 4.0, set the "provider" key on the firewall instead.', $listenerName, $firewallName, $first = array_keys($providerIds)[0]), E_USER_DEPRECATED); return $providerIds[$first]; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/EventListener/��������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024424�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/EventListener/AclSchemaListener.php�����������������0000664�0000000�0000000�00000002070�13247321071�0030462�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\EventListener; @trigger_error(sprintf('Class "%s" is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bundle\AclBundle\EventListener\AclSchemaListener instead.', AclSchemaListener::class), E_USER_DEPRECATED); use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; /** * Merges ACL schema into the given schema. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> * * @deprecated since 3.4, to be removed in 4.0 */ class AclSchemaListener { private $schema; public function __construct(Schema $schema) { $this->schema = $schema; } public function postGenerateSchema(GenerateSchemaEventArgs $args) { $schema = $args->getSchema(); $this->schema->addToSchema($schema); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php������������������0000664�0000000�0000000�00000003420�13247321071�0030407�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\EventListener; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Http\Firewall; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; /** * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> */ class FirewallListener extends Firewall { private $map; private $logoutUrlGenerator; public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher, LogoutUrlGenerator $logoutUrlGenerator) { $this->map = $map; $this->logoutUrlGenerator = $logoutUrlGenerator; parent::__construct($map, $dispatcher); } public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if ($this->map instanceof FirewallMap && $config = $this->map->getFirewallConfig($event->getRequest())) { $this->logoutUrlGenerator->setCurrentFirewall($config->getName(), $config->getContext()); } parent::onKernelRequest($event); } public function onKernelFinishRequest(FinishRequestEvent $event) { if ($event->isMasterRequest()) { $this->logoutUrlGenerator->setCurrentFirewall(null); } parent::onKernelFinishRequest($event); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/LICENSE���������������������������������������������0000664�0000000�0000000�00000002051�13247321071�0022640�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2004-2018 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/README.md�������������������������������������������0000664�0000000�0000000�00000000517�13247321071�0023117�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������SecurityBundle ============== Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023607�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025054�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml���������������������0000664�0000000�0000000�00000002054�13247321071�0027750�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="data_collector.security" class="Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector"> <tag name="data_collector" template="@Security/Collector/security.html.twig" id="security" priority="270" /> <argument type="service" id="security.token_storage" on-invalid="ignore" /> <argument type="service" id="security.role_hierarchy" /> <argument type="service" id="security.logout_url_generator" /> <argument type="service" id="security.access.decision_manager" /> <argument type="service" id="security.firewall.map" /> <argument type="service" id="debug.security.firewall" on-invalid="null" /> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml������������������������0000664�0000000�0000000�00000002437�13247321071�0027246�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.command.init_acl" class="Symfony\Bundle\SecurityBundle\Command\InitAclCommand"> <argument type="service" id="security.acl.dbal.connection" /> <argument type="service" id="security.acl.dbal.schema" /> <tag name="console.command" command="init:acl" /> </service> <service id="security.command.set_acl" class="Symfony\Bundle\SecurityBundle\Command\SetAclCommand"> <argument type="service" id="security.acl.provider" /> <tag name="console.command" command="acl:set" /> </service> <service id="security.command.user_password_encoder" class="Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand"> <argument type="service" id="security.encoder_factory"/> <argument type="collection" /> <!-- encoders' user classes --> <tag name="console.command" command="security:encode-password" /> </service> </services> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml��������������������������0000664�0000000�0000000�00000003552�13247321071�0026705�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.authentication.guard_handler" class="Symfony\Component\Security\Guard\GuardAuthenticatorHandler" > <argument type="service" id="security.token_storage" /> <argument type="service" id="event_dispatcher" on-invalid="null" /> </service> <service id="Symfony\Component\Security\Guard\GuardAuthenticatorHandler" alias="security.authentication.guard_handler" /> <!-- See GuardAuthenticationFactory --> <service id="security.authentication.provider.guard" class="Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider" abstract="true" > <argument /> <!-- Simple Authenticator --> <argument /> <!-- User Provider --> <argument /> <!-- Provider-shared Key --> <argument /> <!-- User Checker --> </service> <service id="security.authentication.listener.guard" class="Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener" abstract="true" > <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.authentication.guard_handler" /> <argument type="service" id="security.authentication.manager" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- Authenticator --> <argument type="service" id="logger" on-invalid="null" /> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml�����������������������0000664�0000000�0000000�00000026256�13247321071�0027460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="security.authentication.trust_resolver.anonymous_class">Symfony\Component\Security\Core\Authentication\Token\AnonymousToken</parameter> <parameter key="security.authentication.trust_resolver.rememberme_class">Symfony\Component\Security\Core\Authentication\Token\RememberMeToken</parameter> <parameter key="security.role_hierarchy.roles" type="collection" /> </parameters> <services> <defaults public="false" /> <service id="security.authorization_checker" class="Symfony\Component\Security\Core\Authorization\AuthorizationChecker" public="true"> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument type="service" id="security.access.decision_manager" /> <argument>%security.access.always_authenticate_before_granting%</argument> </service> <service id="Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface" alias="security.authorization_checker" /> <service id="security.token_storage" class="Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage" public="true"> <tag name="kernel.reset" method="setToken" /> </service> <service id="Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface" alias="security.token_storage" /> <service id="security.helper" class="Symfony\Component\Security\Core\Security"> <argument type="service"> <service class="Symfony\Component\DependencyInjection\ServiceLocator"> <tag name="container.service_locator" /> <argument type="collection"> <argument key="security.token_storage" type="service" id="security.token_storage" /> <argument key="security.authorization_checker" type="service" id="security.authorization_checker" /> </argument> </service> </argument> </service> <service id="Symfony\Component\Security\Core\Security" alias="security.helper" /> <service id="security.user_value_resolver" class="Symfony\Bundle\SecurityBundle\SecurityUserValueResolver"> <argument type="service" id="security.token_storage" /> <tag name="controller.argument_value_resolver" priority="40" /> </service> <!-- Authentication related services --> <service id="security.authentication.manager" class="Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager"> <argument /> <!-- providers --> <argument>%security.authentication.manager.erase_credentials%</argument> <call method="setEventDispatcher"> <argument type="service" id="event_dispatcher" /> </call> </service> <service id="Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface" alias="security.authentication.manager" /> <service id="security.authentication.trust_resolver" class="Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver"> <argument>%security.authentication.trust_resolver.anonymous_class%</argument> <argument>%security.authentication.trust_resolver.rememberme_class%</argument> </service> <service id="security.authentication.session_strategy" class="Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy"> <argument>%security.authentication.session_strategy.strategy%</argument> </service> <service id="Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface" alias="security.authentication.session_strategy" /> <service id="security.encoder_factory.generic" class="Symfony\Component\Security\Core\Encoder\EncoderFactory"> <argument type="collection" /> </service> <service id="security.encoder_factory" alias="security.encoder_factory.generic" /> <service id="Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface" alias="security.encoder_factory" /> <service id="security.user_password_encoder.generic" class="Symfony\Component\Security\Core\Encoder\UserPasswordEncoder"> <argument type="service" id="security.encoder_factory"></argument> </service> <service id="security.password_encoder" alias="security.user_password_encoder.generic" public="true" /> <service id="Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface" alias="security.password_encoder" /> <service id="security.user_checker" class="Symfony\Component\Security\Core\User\UserChecker" /> <service id="security.expression_language" class="Symfony\Component\Security\Core\Authorization\ExpressionLanguage" /> <service id="security.authentication_utils" class="Symfony\Component\Security\Http\Authentication\AuthenticationUtils" public="true"> <argument type="service" id="request_stack" /> </service> <service id="Symfony\Component\Security\Http\Authentication\AuthenticationUtils" alias="security.authentication_utils" /> <!-- Authorization related services --> <service id="security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\AccessDecisionManager"> <argument type="collection" /> </service> <service id="Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface" alias="security.access.decision_manager" /> <service id="security.role_hierarchy" class="Symfony\Component\Security\Core\Role\RoleHierarchy"> <argument>%security.role_hierarchy.roles%</argument> </service> <!-- Security Voters --> <service id="security.access.simple_role_voter" class="Symfony\Component\Security\Core\Authorization\Voter\RoleVoter"> <tag name="security.voter" priority="245" /> </service> <service id="security.access.authenticated_voter" class="Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter"> <argument type="service" id="security.authentication.trust_resolver" /> <tag name="security.voter" priority="250" /> </service> <service id="security.access.role_hierarchy_voter" class="Symfony\Component\Security\Core\Authorization\Voter\RoleHierarchyVoter"> <argument type="service" id="security.role_hierarchy" /> <tag name="security.voter" priority="245" /> </service> <service id="security.access.expression_voter" class="Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter"> <argument type="service" id="security.expression_language" /> <argument type="service" id="security.authentication.trust_resolver" /> <argument type="service" id="security.role_hierarchy" on-invalid="null" /> <tag name="security.voter" priority="245" /> </service> <!-- Firewall related services --> <service id="security.firewall" class="Symfony\Bundle\SecurityBundle\EventListener\FirewallListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="security.firewall.map" /> <argument type="service" id="event_dispatcher" /> <argument type="service" id="security.logout_url_generator" /> </service> <service id="Symfony\Component\Security\Http\Firewall" alias="security.firewall" /> <service id="security.firewall.map" class="Symfony\Bundle\SecurityBundle\Security\FirewallMap"> <argument /> <!-- Firewall context locator --> <argument /> <!-- Request matchers --> </service> <service id="security.firewall.context" class="Symfony\Bundle\SecurityBundle\Security\FirewallContext" abstract="true"> <argument type="collection" /> <argument type="service" id="security.exception_listener" /> <argument /> <!-- FirewallConfig --> </service> <service id="security.firewall.config" class="Symfony\Bundle\SecurityBundle\Security\FirewallConfig" abstract="true"> <argument /> <!-- name --> <argument /> <!-- user_checker --> <argument /> <!-- request_matcher --> <argument /> <!-- security enabled --> <argument /> <!-- stateless --> <argument /> <!-- provider --> <argument /> <!-- context --> <argument /> <!-- entry_point --> <argument /> <!-- access_denied_handler --> <argument /> <!-- access_denied_url --> <argument type="collection" /> <!-- listeners --> <argument /> <!-- switch_user --> </service> <service id="security.logout_url_generator" class="Symfony\Component\Security\Http\Logout\LogoutUrlGenerator"> <argument type="service" id="request_stack" on-invalid="null" /> <argument type="service" id="router" on-invalid="null" /> <argument type="service" id="security.token_storage" on-invalid="null" /> </service> <!-- Provisioning --> <service id="security.user.provider.in_memory" class="Symfony\Component\Security\Core\User\InMemoryUserProvider" abstract="true" /> <service id="security.user.provider.in_memory.user" class="Symfony\Component\Security\Core\User\User" abstract="true" /> <service id="security.user.provider.ldap" class="Symfony\Component\Security\Core\User\LdapUserProvider" abstract="true"> <argument /> <!-- security.ldap.ldap --> <argument /> <!-- base dn --> <argument /> <!-- search dn --> <argument /> <!-- search password --> <argument /> <!-- default_roles --> <argument /> <!-- uid key --> <argument /> <!-- filter --> <argument /> <!-- password_attribute --> </service> <service id="security.user.provider.chain" class="Symfony\Component\Security\Core\User\ChainUserProvider" abstract="true" /> <service id="security.http_utils" class="Symfony\Component\Security\Http\HttpUtils"> <argument type="service" id="router" on-invalid="null" /> <argument type="service" id="router" on-invalid="null" /> </service> <!-- Validator --> <service id="security.validator.user_password" class="Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator"> <tag name="validator.constraint_validator" alias="security.validator.user_password" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.encoder_factory" /> </service> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl.xml�������������������0000664�0000000�0000000�00000003605�13247321071�0030270�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.acl.object_identity_retrieval_strategy" class="Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy" /> <service id="security.acl.security_identity_retrieval_strategy" class="Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy"> <argument type="service" id="security.role_hierarchy" /> <argument type="service" id="security.authentication.trust_resolver" /> </service> <service id="security.acl.permission_granting_strategy" class="Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy"> <call method="setAuditLogger"> <argument type="service" id="security.acl.audit_logger" on-invalid="ignore" /> </call> </service> <service id="security.acl.permission.map" class="Symfony\Component\Security\Acl\Permission\BasicPermissionMap" /> <service id="security.acl.voter.basic_permissions" class="Symfony\Component\Security\Acl\Voter\AclVoter"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.acl.provider" /> <argument type="service" id="security.acl.object_identity_retrieval_strategy" /> <argument type="service" id="security.acl.security_identity_retrieval_strategy" /> <argument type="service" id="security.acl.permission.map" /> <argument type="service" id="logger" on-invalid="null" /> <tag name="security.voter" priority="255" /> </service> </services> </container> ���������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl_dbal.xml��������������0000664�0000000�0000000�00000005606�13247321071�0031255�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.acl.dbal.connection" alias="database_connection" /> <service id="security.acl.dbal.provider" class="Symfony\Component\Security\Acl\Dbal\MutableAclProvider"> <argument type="service" id="security.acl.dbal.connection" /> <argument type="service" id="security.acl.permission_granting_strategy" /> <argument type="collection"> <argument key="class_table_name">%security.acl.dbal.class_table_name%</argument> <argument key="entry_table_name">%security.acl.dbal.entry_table_name%</argument> <argument key="oid_table_name">%security.acl.dbal.oid_table_name%</argument> <argument key="oid_ancestors_table_name">%security.acl.dbal.oid_ancestors_table_name%</argument> <argument key="sid_table_name">%security.acl.dbal.sid_table_name%</argument> </argument> <argument type="service" id="security.acl.cache" on-invalid="null" /> </service> <service id="security.acl.dbal.schema" class="Symfony\Component\Security\Acl\Dbal\Schema"> <argument type="collection"> <argument key="class_table_name">%security.acl.dbal.class_table_name%</argument> <argument key="entry_table_name">%security.acl.dbal.entry_table_name%</argument> <argument key="oid_table_name">%security.acl.dbal.oid_table_name%</argument> <argument key="oid_ancestors_table_name">%security.acl.dbal.oid_ancestors_table_name%</argument> <argument key="sid_table_name">%security.acl.dbal.sid_table_name%</argument> </argument> <argument type="service" id="security.acl.dbal.connection" /> </service> <service id="security.acl.dbal.schema_listener" class="Symfony\Bundle\SecurityBundle\EventListener\AclSchemaListener"> <argument type="service" id="security.acl.dbal.schema" /> </service> <service id="security.acl.provider" alias="security.acl.dbal.provider" /> <service id="Symfony\Component\Security\Acl\Model\AclProviderInterface" alias="security.acl.provider" /> <service id="security.acl.cache.doctrine" class="Symfony\Component\Security\Acl\Domain\DoctrineAclCache"> <argument type="service" id="security.acl.cache.doctrine.cache_impl" /> <argument type="service" id="security.acl.permission_granting_strategy" /> </service> <service id="security.acl.cache.doctrine.cache_impl" alias="doctrine.orm.default_result_cache" /> </services> </container> ��������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml�����������������0000664�0000000�0000000�00000002146�13247321071�0030616�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="debug.security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager" decorates="security.access.decision_manager"> <argument type="service" id="debug.security.access.decision_manager.inner" /> </service> <service id="debug.security.firewall" class="Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener"> <tag name="kernel.event_subscriber" /> <argument type="service" id="security.firewall.map" /> <argument type="service" id="event_dispatcher" /> <argument type="service" id="security.logout_url_generator" /> </service> <service id="security.firewall" alias="debug.security.firewall" /> </services> </container> ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml�������������0000664�0000000�0000000�00000035566�13247321071�0031554�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.authentication.listener.anonymous" class="Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument /> <!-- Key --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="security.authentication.manager" /> </service> <service id="security.authentication.provider.anonymous" class="Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider"> <argument /> <!-- Key --> </service> <service id="security.authentication.retry_entry_point" class="Symfony\Component\Security\Http\EntryPoint\RetryAuthenticationEntryPoint"> <argument>%request_listener.http_port%</argument> <argument>%request_listener.https_port%</argument> </service> <service id="security.authentication.basic_entry_point" class="Symfony\Component\Security\Http\EntryPoint\BasicAuthenticationEntryPoint" /> <service id="security.authentication.digest_entry_point" class="Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint" /> <service id="security.channel_listener" class="Symfony\Component\Security\Http\Firewall\ChannelListener"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.access_map" /> <argument type="service" id="security.authentication.retry_entry_point" /> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.access_map" class="Symfony\Component\Security\Http\AccessMap" /> <service id="security.context_listener" class="Symfony\Component\Security\Http\Firewall\ContextListener"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="collection" /> <argument /> <!-- Provider Key --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null" /> <argument type="service" id="security.authentication.trust_resolver" /> </service> <service id="security.logout_listener" class="Symfony\Component\Security\Http\Firewall\LogoutListener" abstract="true"> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.http_utils" /> <argument type="service" id="security.logout.success_handler" /> <argument /> <!-- Options --> </service> <service id="security.logout.handler.session" class="Symfony\Component\Security\Http\Logout\SessionLogoutHandler" /> <service id="security.logout.handler.cookie_clearing" class="Symfony\Component\Security\Http\Logout\CookieClearingLogoutHandler" abstract="true" /> <service id="security.logout.success_handler" class="Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler" abstract="true"> <argument type="service" id="security.http_utils" /> <argument>/</argument> </service> <service id="security.authentication.form_entry_point" class="Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint" abstract="true"> <argument type="service" id="http_kernel" /> </service> <service id="security.authentication.listener.abstract" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument type="service" id="security.authentication.session_strategy" /> <argument type="service" id="security.http_utils" /> <argument /> <argument type="service" id="security.authentication.success_handler" /> <argument type="service" id="security.authentication.failure_handler" /> <argument type="collection" /> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null" /> </service> <service id="security.authentication.custom_success_handler" class="Symfony\Component\Security\Http\Authentication\CustomAuthenticationSuccessHandler" abstract="true"> <argument /> <!-- The custom success handler service id --> <argument type="collection" /> <!-- Options --> <argument /> <!-- Provider-shared Key --> </service> <service id="security.authentication.success_handler" class="Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler" abstract="true"> <argument type="service" id="security.http_utils" /> <argument type="collection" /> <!-- Options --> </service> <service id="security.authentication.custom_failure_handler" class="Symfony\Component\Security\Http\Authentication\CustomAuthenticationFailureHandler" abstract="true"> <argument /> <!-- The custom failure handler service id --> <argument type="collection" /> <!-- Options --> </service> <service id="security.authentication.failure_handler" class="Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="http_kernel" /> <argument type="service" id="security.http_utils" /> <argument type="collection" /> <!-- Options --> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.authentication.listener.form" class="Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener" parent="security.authentication.listener.abstract" public="false" abstract="true" /> <service id="security.authentication.listener.simple_form" class="Symfony\Component\Security\Http\Firewall\SimpleFormAuthenticationListener" parent="security.authentication.listener.abstract" public="false" abstract="true"> </service> <service id="security.authentication.simple_success_failure_handler" class="Symfony\Component\Security\Http\Authentication\SimpleAuthenticationHandler" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument /> <!-- Authenticator --> <argument type="service" id="security.authentication.success_handler" /> <argument type="service" id="security.authentication.failure_handler" /> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.authentication.listener.simple_preauth" class="Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- Authenticator --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null"/> </service> <service id="security.authentication.listener.x509" class="Symfony\Component\Security\Http\Firewall\X509AuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- x509 user --> <argument /> <!-- x509 credentials --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null" /> </service> <service id="security.authentication.listener.json" class="Symfony\Component\Security\Http\Firewall\UsernamePasswordJsonAuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument type="service" id="security.http_utils" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- Failure handler --> <argument /> <!-- Success Handler --> <argument type="collection" /> <!-- Options --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null" /> <argument type="service" id="property_accessor" on-invalid="null" /> </service> <service id="security.authentication.listener.remote_user" class="Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- REMOTE_USER server env var --> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null"/> </service> <service id="security.authentication.listener.basic" class="Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.manager" /> <argument /> <!-- Provider-shared Key --> <argument /> <!-- Entry Point --> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.authentication.listener.digest" class="Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument /> <!-- User Provider --> <argument /> <!-- Provider-shared Key --> <argument /> <!-- Entry Point --> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.authentication.provider.dao" class="Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider" abstract="true"> <argument /> <!-- User Provider --> <argument /> <!-- User Checker --> <argument /> <!-- Provider-shared Key --> <argument type="service" id="security.encoder_factory" /> <argument>%security.authentication.hide_user_not_found%</argument> </service> <service id="security.authentication.provider.ldap_bind" class="Symfony\Component\Security\Core\Authentication\Provider\LdapBindAuthenticationProvider" abstract="true"> <argument /> <!-- User Provider --> <argument /> <!-- UserChecker --> <argument /> <!-- Provider-shared Key --> <argument /> <!-- LDAP --> <argument /> <!-- Base DN --> <argument>%security.authentication.hide_user_not_found%</argument> </service> <service id="security.authentication.provider.simple" class="Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider" abstract="true"> <argument /> <!-- Simple Authenticator --> <argument /> <!-- User Provider --> <argument /> <!-- Provider-shared Key --> </service> <service id="security.authentication.provider.pre_authenticated" class="Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider" abstract="true"> <argument /> <!-- User Provider --> <argument /> <!-- User Checker --> </service> <service id="security.exception_listener" class="Symfony\Component\Security\Http\Firewall\ExceptionListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.trust_resolver" /> <argument type="service" id="security.http_utils" /> <argument /> <argument type="service" id="security.authentication.entry_point" on-invalid="null" /> <argument>%security.access.denied_url%</argument> <argument type="service" id="security.access.denied_handler" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" /> <argument>false</argument> <!-- Stateless --> </service> <service id="security.authentication.switchuser_listener" class="Symfony\Component\Security\Http\Firewall\SwitchUserListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument /> <!-- User Provider --> <argument /> <!-- User Checker --> <argument /> <!-- Provider Key --> <argument type="service" id="security.access.decision_manager" /> <argument type="service" id="logger" on-invalid="null" /> <argument>_switch_user</argument> <argument>ROLE_ALLOWED_TO_SWITCH</argument> <argument type="service" id="event_dispatcher" on-invalid="null"/> <argument>false</argument> <!-- Stateless --> </service> <service id="security.access_listener" class="Symfony\Component\Security\Http\Firewall\AccessListener"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.access.decision_manager" /> <argument type="service" id="security.access_map" /> <argument type="service" id="security.authentication.manager" /> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml������������0000664�0000000�0000000�00000005442�13247321071�0031652�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="security.authentication.listener.rememberme" class="Symfony\Component\Security\Http\Firewall\RememberMeListener" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="service" id="security.token_storage" /> <argument type="service" id="security.authentication.rememberme" /> <argument type="service" id="security.authentication.manager" /> <argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null"/> <argument /> <!-- Catch exception flag set in RememberMeFactory --> <argument type="service" id="security.authentication.session_strategy" /> </service> <service id="security.authentication.provider.rememberme" class="Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider" abstract="true"> <argument /> <!-- User Checker --> </service> <service id="security.rememberme.token.provider.in_memory" class="Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider" /> <service id="security.authentication.rememberme.services.abstract" abstract="true"> <tag name="monolog.logger" channel="security" /> <argument type="collection" /> <!-- User Providers --> <argument /> <!-- Shared Token Key --> <argument /> <!-- Shared Provider Key --> <argument type="collection" /> <!-- Options --> <argument type="service" id="logger" on-invalid="null" /> </service> <service id="security.authentication.rememberme.services.persistent" class="Symfony\Component\Security\Http\RememberMe\PersistentTokenBasedRememberMeServices" parent="security.authentication.rememberme.services.abstract" public="false" abstract="true" /> <service id="security.authentication.rememberme.services.simplehash" class="Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices" parent="security.authentication.rememberme.services.abstract" public="false" abstract="true" /> <service id="security.rememberme.response_listener" class="Symfony\Component\Security\Http\RememberMe\ResponseListener"> <tag name="kernel.event_subscriber" /> </service> </services> </container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml�����������������0000664�0000000�0000000�00000001634�13247321071�0030615�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="templating.helper.logout_url" class="Symfony\Bundle\SecurityBundle\Templating\Helper\LogoutUrlHelper"> <tag name="templating.helper" alias="logout_url" /> <argument type="service" id="security.logout_url_generator" /> </service> <service id="templating.helper.security" class="Symfony\Bundle\SecurityBundle\Templating\Helper\SecurityHelper"> <tag name="templating.helper" alias="security" /> <argument type="service" id="security.authorization_checker" on-invalid="ignore" /> </service> </services> </container> ����������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.xml����������������0000664�0000000�0000000�00000001516�13247321071�0030777�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <defaults public="false" /> <service id="twig.extension.logout_url" class="Symfony\Bridge\Twig\Extension\LogoutUrlExtension"> <tag name="twig.extension" /> <argument type="service" id="security.logout_url_generator" /> </service> <service id="twig.extension.security" class="Symfony\Bridge\Twig\Extension\SecurityExtension"> <tag name="twig.extension" /> <argument type="service" id="security.authorization_checker" on-invalid="ignore" /> </service> </services> </container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/views/������������������������������������0000775�0000000�0000000�00000000000�13247321071�0024744�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/��������������������������0000775�0000000�0000000�00000000000�13247321071�0026672�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/icon.svg������������������0000664�0000000�0000000�00000000544�13247321071�0030346�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> <path fill="#AAAAAA" d="M21,20.4V22H3v-1.6c0-3.7,2.4-6.9,5.8-8c-1.7-1.1-2.9-3-2.9-5.2c0-3.4,2.7-6.1,6.1-6.1s6.1,2.7,6.1,6.1c0,2.2-1.2,4.1-2.9,5.2C18.6,13.5,21,16.7,21,20.4z"/> </svg> ������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig��������0000664�0000000�0000000�00000031704�13247321071�0032405�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block page_title 'Security' %} {% block toolbar %} {% if collector.token %} {% set is_authenticated = collector.enabled and collector.authenticated %} {% set color_code = is_authenticated ? '' : 'yellow' %} {% else %} {% set color_code = collector.enabled ? 'red' : '' %} {% endif %} {% set icon %} {{ include('@Security/Collector/icon.svg') }} <span class="sf-toolbar-value">{{ collector.user|default('n/a') }}</span> {% endset %} {% set text %} {% if collector.impersonated %} <div class="sf-toolbar-info-group"> <div class="sf-toolbar-info-piece"> <b>Impersonator</b> <span>{{ collector.impersonatorUser }}</span> </div> </div> {% endif %} <div class="sf-toolbar-info-group"> {% if collector.enabled %} {% if collector.token %} <div class="sf-toolbar-info-piece"> <b>Logged in as</b> <span>{{ collector.user }}</span> </div> <div class="sf-toolbar-info-piece"> <b>Authenticated</b> <span class="sf-toolbar-status sf-toolbar-status-{{ is_authenticated ? 'green' : 'red' }}">{{ is_authenticated ? 'Yes' : 'No' }}</span> </div> <div class="sf-toolbar-info-piece"> <b>Token class</b> <span>{{ collector.tokenClass|abbr_class }}</span> </div> {% else %} <div class="sf-toolbar-info-piece"> <b>Authenticated</b> <span class="sf-toolbar-status sf-toolbar-status-red">No</span> </div> {% endif %} {% if collector.firewall %} <div class="sf-toolbar-info-piece"> <b>Firewall name</b> <span>{{ collector.firewall.name }}</span> </div> {% endif %} {% if collector.token and collector.logoutUrl %} <div class="sf-toolbar-info-piece"> <b>Actions</b> <span> <a href="{{ collector.logoutUrl }}">Logout</a> {% if collector.impersonated and collector.impersonationExitPath %} | <a href="{{ collector.impersonationExitPath }}">Exit impersonation</a> {% endif %} </span> </div> {% endif %} {% else %} <div class="sf-toolbar-info-piece"> <span>The security is disabled.</span> </div> {% endif %} </div> {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: color_code }) }} {% endblock %} {% block menu %} <span class="label {{ not collector.enabled or not collector.token ? 'disabled' }}"> <span class="icon">{{ include('@Security/Collector/icon.svg') }}</span> <strong>Security</strong> </span> {% endblock %} {% block panel %} <h2>Security Token</h2> {% if collector.enabled %} {% if collector.token %} <div class="metrics"> <div class="metric"> <span class="value">{{ collector.user == 'anon.' ? 'Anonymous' : collector.user }}</span> <span class="label">Username</span> </div> <div class="metric"> <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.authenticated ? 'yes' : 'no') ~ '.svg') }}</span> <span class="label">Authenticated</span> </div> </div> <table> <thead> <tr> <th scope="col" class="key">Property</th> <th scope="col">Value</th> </tr> </thead> <tbody> <tr> <th>Roles</th> <td> {{ collector.roles is empty ? 'none' : profiler_dump(collector.roles, maxDepth=1) }} {% if not collector.authenticated and collector.roles is empty %} <p class="help">User is not authenticated probably because they have no roles.</p> {% endif %} </td> </tr> {% if collector.supportsRoleHierarchy %} <tr> <th>Inherited Roles</th> <td>{{ collector.inheritedRoles is empty ? 'none' : profiler_dump(collector.inheritedRoles, maxDepth=1) }}</td> </tr> {% endif %} {% if collector.token %} <tr> <th>Token</th> <td>{{ profiler_dump(collector.token) }}</td> </tr> {% endif %} </tbody> </table> {% elseif collector.enabled %} <div class="empty"> <p>There is no security token.</p> </div> {% endif %} <h2>Security Firewall</h2> {% if collector.firewall %} <div class="metrics"> <div class="metric"> <span class="value">{{ collector.firewall.name }}</span> <span class="label">Name</span> </div> <div class="metric"> <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.security_enabled ? 'yes' : 'no') ~ '.svg') }}</span> <span class="label">Security enabled</span> </div> <div class="metric"> <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.stateless ? 'yes' : 'no') ~ '.svg') }}</span> <span class="label">Stateless</span> </div> <div class="metric"> <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.allows_anonymous ? 'yes' : 'no') ~ '.svg') }}</span> <span class="label">Allows anonymous</span> </div> </div> {% if collector.firewall.security_enabled %} <h4>Configuration</h4> <table> <thead> <tr> <th scope="col" class="key">Key</th> <th scope="col">Value</th> </tr> </thead> <tbody> <tr> <th>provider</th> <td>{{ collector.firewall.provider ?: '(none)' }}</td> </tr> <tr> <th>context</th> <td>{{ collector.firewall.context ?: '(none)' }}</td> </tr> <tr> <th>entry_point</th> <td>{{ collector.firewall.entry_point ?: '(none)' }}</td> </tr> <tr> <th>user_checker</th> <td>{{ collector.firewall.user_checker ?: '(none)' }}</td> </tr> <tr> <th>access_denied_handler</th> <td>{{ collector.firewall.access_denied_handler ?: '(none)' }}</td> </tr> <tr> <th>access_denied_url</th> <td>{{ collector.firewall.access_denied_url ?: '(none)' }}</td> </tr> <tr> <th>listeners</th> <td>{{ collector.firewall.listeners is empty ? '(none)' : profiler_dump(collector.firewall.listeners, maxDepth=1) }}</td> </tr> </tbody> </table> <h4>Listeners</h4> {% if collector.listeners|default([]) is empty %} <div class="empty"> <p>No security listeners have been recorded. Check that debugging is enabled in the kernel.</p> </div> {% else %} <table> <thead> <tr> <th>Listener</th> <th>Duration</th> <th>Response</th> </tr> </thead> {% set previous_event = (collector.listeners|first) %} {% for listener in collector.listeners %} {% if loop.first or listener != previous_event %} {% if not loop.first %} </tbody> {% endif %} <tbody> {% set previous_event = listener %} {% endif %} <tr> <td class="font-normal">{{ profiler_dump(listener.stub) }}</td> <td class="no-wrap">{{ '%0.2f'|format(listener.time * 1000) }} ms</td> <td class="font-normal">{{ listener.response ? profiler_dump(listener.response) : '(none)' }}</td> </tr> {% if loop.last %} </tbody> {% endif %} {% endfor %} </table> {% endif %} {% endif %} {% elseif collector.enabled %} <div class="empty"> <p>This request was not covered by any firewall.</p> </div> {% endif %} {% else %} <div class="empty"> <p>The security component is disabled.</p> </div> {% endif %} {% if collector.voters|default([]) is not empty %} <h2>Security Voters <small>({{ collector.voters|length }})</small></h2> <div class="metrics"> <div class="metric"> <span class="value">{{ collector.voterStrategy|default('unknown') }}</span> <span class="label">Strategy</span> </div> </div> <table class="voters"> <thead> <tr> <th>#</th> <th>Voter class</th> </tr> </thead> <tbody> {% for voter in collector.voters %} <tr> <td class="font-normal text-small text-muted nowrap">{{ loop.index }}</td> <td class="font-normal">{{ profiler_dump(voter) }}</td> </tr> {% endfor %} </tbody> </table> {% endif %} {% if collector.accessDecisionLog|default([]) is not empty %} <h2>Access decision log</h2> <table class="decision-log"> <col style="width: 30px"> <col style="width: 120px"> <col style="width: 25%"> <col style="width: 60%"> <thead> <tr> <th>#</th> <th>Result</th> <th>Attributes</th> <th>Object</th> </tr> </thead> <tbody> {% for decision in collector.accessDecisionLog %} <tr> <td class="font-normal text-small text-muted nowrap">{{ loop.index }}</td> <td class="font-normal"> {{ decision.result ? '<span class="label status-success same-width">GRANTED</span>' : '<span class="label status-error same-width">DENIED</span>' }} </td> <td> {% if decision.attributes|length == 1 %} {{ decision.attributes|first }} {% else %} {{ profiler_dump(decision.attributes) }} {% endif %} </td> <td>{{ profiler_dump(decision.seek('object')) }}</td> </tr> {% endfor %} </tbody> </table> {% endif %} {% endblock %} ������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Security/�������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023444�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Security/FirewallConfig.php�������������������������0000664�0000000�0000000�00000007631�13247321071�0027057�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Security; /** * @author Robin Chalas <robin.chalas@gmail.com> */ final class FirewallConfig { private $name; private $userChecker; private $requestMatcher; private $securityEnabled; private $stateless; private $provider; private $context; private $entryPoint; private $accessDeniedHandler; private $accessDeniedUrl; private $listeners; private $switchUser; /** * @param string $name * @param string $userChecker * @param string|null $requestMatcher * @param bool $securityEnabled * @param bool $stateless * @param string|null $provider * @param string|null $context * @param string|null $entryPoint * @param string|null $accessDeniedHandler * @param string|null $accessDeniedUrl * @param string[] $listeners * @param array|null $switchUser */ public function __construct($name, $userChecker, $requestMatcher = null, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $listeners = array(), $switchUser = null) { $this->name = $name; $this->userChecker = $userChecker; $this->requestMatcher = $requestMatcher; $this->securityEnabled = $securityEnabled; $this->stateless = $stateless; $this->provider = $provider; $this->context = $context; $this->entryPoint = $entryPoint; $this->accessDeniedHandler = $accessDeniedHandler; $this->accessDeniedUrl = $accessDeniedUrl; $this->listeners = $listeners; $this->switchUser = $switchUser; } public function getName() { return $this->name; } /** * @return string|null The request matcher service id or null if neither the request matcher, pattern or host * options were provided */ public function getRequestMatcher() { return $this->requestMatcher; } public function isSecurityEnabled() { return $this->securityEnabled; } public function allowsAnonymous() { return in_array('anonymous', $this->listeners, true); } public function isStateless() { return $this->stateless; } /** * @return string|null The provider service id */ public function getProvider() { return $this->provider; } /** * @return string|null The context key (will be null if the firewall is stateless) */ public function getContext() { return $this->context; } /** * @return string|null The entry_point service id if configured, null otherwise */ public function getEntryPoint() { return $this->entryPoint; } /** * @return string The user_checker service id */ public function getUserChecker() { return $this->userChecker; } /** * @return string|null The access_denied_handler service id if configured, null otherwise */ public function getAccessDeniedHandler() { return $this->accessDeniedHandler; } /** * @return string|null The access_denied_handler URL if configured, null otherwise */ public function getAccessDeniedUrl() { return $this->accessDeniedUrl; } /** * @return string[] An array of listener keys */ public function getListeners() { return $this->listeners; } /** * @return array|null The switch_user parameters if configured, null otherwise */ public function getSwitchUser() { return $this->switchUser; } } �������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php������������������������0000664�0000000�0000000�00000003542�13247321071�0027273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Http\Firewall\ExceptionListener; /** * This is a wrapper around the actual firewall configuration which allows us * to lazy load the context for one specific firewall only when we need it. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class FirewallContext { private $listeners; private $exceptionListener; private $config; /** * @param \Traversable|array $listeners * @param ExceptionListener|null $exceptionListener * @param FirewallConfig|null $firewallConfig */ public function __construct($listeners, ExceptionListener $exceptionListener = null, FirewallConfig $config = null) { $this->listeners = $listeners; $this->exceptionListener = $exceptionListener; $this->config = $config; } public function getConfig() { return $this->config; } /** * @deprecated since version 3.3, will be removed in 4.0. Use {@link getListeners()} and/or {@link getExceptionListener()} instead. */ public function getContext() { @trigger_error(sprintf('Method %s() is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s::getListeners/getExceptionListener() instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); return array($this->getListeners(), $this->getExceptionListener()); } /** * @return \Traversable|array */ public function getListeners() { return $this->listeners; } public function getExceptionListener() { return $this->exceptionListener; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php����������������������������0000664�0000000�0000000�00000011216�13247321071�0026361�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Security; use Psr\Container\ContainerInterface; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\HttpFoundation\Request; /** * This is a lazy-loading firewall map implementation. * * Listeners will only be initialized if we really need them. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class FirewallMap extends _FirewallMap implements FirewallMapInterface { /** * @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below */ private $container; /** * @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below */ private $map; public function __construct(ContainerInterface $container, $map) { parent::__construct($container, $map); $this->container = $container; $this->map = $map; } /** * @internal */ public function __get($name) { if ('map' === $name || 'container' === $name) { @trigger_error(sprintf('Using the "%s::$%s" property is deprecated since Symfony 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED); if ('map' === $name && $this->map instanceof \Traversable) { $this->map = iterator_to_array($this->map); } } return $this->$name; } /** * @internal */ public function __set($name, $value) { if ('map' === $name || 'container' === $name) { @trigger_error(sprintf('Using the "%s::$%s" property is deprecated since Symfony 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED); $set = \Closure::bind(function ($name, $value) { $this->$name = $value; }, $this, parent::class); $set($name, $value); } $this->$name = $value; } /** * @internal */ public function __isset($name) { if ('map' === $name || 'container' === $name) { @trigger_error(sprintf('Using the "%s::$%s" property is deprecated since Symfony 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED); } return isset($this->$name); } /** * @internal */ public function __unset($name) { if ('map' === $name || 'container' === $name) { @trigger_error(sprintf('Using the "%s::$%s" property is deprecated since Symfony 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED); $unset = \Closure::bind(function ($name) { unset($this->$name); }, $this, parent::class); $unset($name); } unset($this->$name); } } /** * @internal to be removed in 4.0 */ class _FirewallMap { private $container; private $map; private $contexts; public function __construct(ContainerInterface $container, $map) { $this->container = $container; $this->map = $map; $this->contexts = new \SplObjectStorage(); } public function getListeners(Request $request) { $context = $this->getFirewallContext($request); if (null === $context) { return array(array(), null); } return array($context->getListeners(), $context->getExceptionListener()); } /** * @return FirewallConfig|null */ public function getFirewallConfig(Request $request) { $context = $this->getFirewallContext($request); if (null === $context) { return; } return $context->getConfig(); } /** * @return FirewallContext */ private function getFirewallContext(Request $request) { if ($request->attributes->has('_firewall_context')) { $storedContextId = $request->attributes->get('_firewall_context'); foreach ($this->map as $contextId => $requestMatcher) { if ($contextId === $storedContextId) { return $this->container->get($contextId); } } $request->attributes->remove('_firewall_context'); } foreach ($this->map as $contextId => $requestMatcher) { if (null === $requestMatcher || $requestMatcher->matches($request)) { $request->attributes->set('_firewall_context', $contextId); return $this->container->get($contextId); } } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php����������������������������������0000664�0000000�0000000�00000006707�13247321071�0025321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginFactory; use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSessionDomainConstraintPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginLdapFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicLdapFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpDigestFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RemoteUserFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\LdapFactory; /** * Bundle. * * @author Fabien Potencier <fabien@symfony.com> */ class SecurityBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); $extension = $container->getExtension('security'); $extension->addSecurityListenerFactory(new FormLoginFactory()); $extension->addSecurityListenerFactory(new FormLoginLdapFactory()); $extension->addSecurityListenerFactory(new JsonLoginFactory()); $extension->addSecurityListenerFactory(new HttpBasicFactory()); $extension->addSecurityListenerFactory(new HttpBasicLdapFactory()); $extension->addSecurityListenerFactory(new HttpDigestFactory(false)); $extension->addSecurityListenerFactory(new RememberMeFactory()); $extension->addSecurityListenerFactory(new X509Factory()); $extension->addSecurityListenerFactory(new RemoteUserFactory()); $extension->addSecurityListenerFactory(new SimplePreAuthenticationFactory()); $extension->addSecurityListenerFactory(new SimpleFormFactory()); $extension->addSecurityListenerFactory(new GuardAuthenticationFactory()); $extension->addUserProviderFactory(new InMemoryFactory()); $extension->addUserProviderFactory(new LdapFactory()); $container->addCompilerPass(new AddSecurityVotersPass()); $container->addCompilerPass(new AddSessionDomainConstraintPass(), PassConfig::TYPE_AFTER_REMOVING); } public function registerCommands(Application $application) { // noop } } ���������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php�����������������������0000664�0000000�0000000�00000003307�13247321071�0027536�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; /** * Supports the argument type of {@see UserInterface}. * * @author Iltar van der Berg <kjarli@gmail.com> */ final class SecurityUserValueResolver implements ArgumentValueResolverInterface { private $tokenStorage; public function __construct(TokenStorageInterface $tokenStorage) { $this->tokenStorage = $tokenStorage; } public function supports(Request $request, ArgumentMetadata $argument) { // only security user implementations are supported if (UserInterface::class !== $argument->getType()) { return false; } $token = $this->tokenStorage->getToken(); if (!$token instanceof TokenInterface) { return false; } $user = $token->getUser(); // in case it's not an object we cannot do anything with it; E.g. "anon." return $user instanceof UserInterface; } public function resolve(Request $request, ArgumentMetadata $argument) { yield $this->tokenStorage->getToken()->getUser(); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Templating/�����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023741�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Templating/Helper/����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025160�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php���������������0000664�0000000�0000000�00000003103�13247321071�0030762�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Templating\Helper; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Symfony\Component\Templating\Helper\Helper; /** * LogoutUrlHelper provides generator functions for the logout URL. * * @author Jeremy Mikola <jmikola@gmail.com> */ class LogoutUrlHelper extends Helper { private $generator; public function __construct(LogoutUrlGenerator $generator) { $this->generator = $generator; } /** * Generates the absolute logout path for the firewall. * * @param string|null $key The firewall key or null to use the current firewall key * * @return string The logout path */ public function getLogoutPath($key) { return $this->generator->getLogoutPath($key, UrlGeneratorInterface::ABSOLUTE_PATH); } /** * Generates the absolute logout URL for the firewall. * * @param string|null $key The firewall key or null to use the current firewall key * * @return string The logout URL */ public function getLogoutUrl($key) { return $this->generator->getLogoutUrl($key, UrlGeneratorInterface::ABSOLUTE_URL); } /** * {@inheritdoc} */ public function getName() { return 'logout_url'; } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php����������������0000664�0000000�0000000�00000002360�13247321071�0030641�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Templating\Helper; use Symfony\Component\Security\Acl\Voter\FieldVote; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; /** * SecurityHelper provides read-only access to the security checker. * * @author Fabien Potencier <fabien@symfony.com> */ class SecurityHelper extends Helper { private $securityChecker; public function __construct(AuthorizationCheckerInterface $securityChecker = null) { $this->securityChecker = $securityChecker; } public function isGranted($role, $object = null, $field = null) { if (null === $this->securityChecker) { return false; } if (null !== $field) { $object = new FieldVote($object, $field); } return $this->securityChecker->isGranted($role, $object); } /** * {@inheritdoc} */ public function getName() { return 'security'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/����������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0022737�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/��������������������������������0000775�0000000�0000000�00000000000�13247321071�0025457�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php���0000664�0000000�0000000�00000027472�13247321071�0033314�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DataCollector; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector; use Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchy; use Symfony\Component\Security\Http\Firewall\ListenerInterface; use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; class SecurityDataCollectorTest extends TestCase { public function testCollectWhenSecurityIsDisabled() { $collector = new SecurityDataCollector(); $collector->collect($this->getRequest(), $this->getResponse()); $this->assertSame('security', $collector->getName()); $this->assertFalse($collector->isEnabled()); $this->assertFalse($collector->isAuthenticated()); $this->assertFalse($collector->isImpersonated()); $this->assertNull($collector->getImpersonatorUser()); $this->assertNull($collector->getImpersonationExitPath()); $this->assertNull($collector->getTokenClass()); $this->assertFalse($collector->supportsRoleHierarchy()); $this->assertCount(0, $collector->getRoles()); $this->assertCount(0, $collector->getInheritedRoles()); $this->assertEmpty($collector->getUser()); $this->assertNull($collector->getFirewall()); } public function testCollectWhenAuthenticationTokenIsNull() { $tokenStorage = new TokenStorage(); $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); $collector->collect($this->getRequest(), $this->getResponse()); $this->assertTrue($collector->isEnabled()); $this->assertFalse($collector->isAuthenticated()); $this->assertFalse($collector->isImpersonated()); $this->assertNull($collector->getImpersonatorUser()); $this->assertNull($collector->getImpersonationExitPath()); $this->assertNull($collector->getTokenClass()); $this->assertTrue($collector->supportsRoleHierarchy()); $this->assertCount(0, $collector->getRoles()); $this->assertCount(0, $collector->getInheritedRoles()); $this->assertEmpty($collector->getUser()); $this->assertNull($collector->getFirewall()); } /** @dataProvider provideRoles */ public function testCollectAuthenticationTokenAndRoles(array $roles, array $normalizedRoles, array $inheritedRoles) { $tokenStorage = new TokenStorage(); $tokenStorage->setToken(new UsernamePasswordToken('hhamon', 'P4$$w0rD', 'provider', $roles)); $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); $collector->collect($this->getRequest(), $this->getResponse()); $collector->lateCollect(); $this->assertTrue($collector->isEnabled()); $this->assertTrue($collector->isAuthenticated()); $this->assertFalse($collector->isImpersonated()); $this->assertNull($collector->getImpersonatorUser()); $this->assertNull($collector->getImpersonationExitPath()); $this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $collector->getTokenClass()->getValue()); $this->assertTrue($collector->supportsRoleHierarchy()); $this->assertSame($normalizedRoles, $collector->getRoles()->getValue(true)); $this->assertSame($inheritedRoles, $collector->getInheritedRoles()->getValue(true)); $this->assertSame('hhamon', $collector->getUser()); } public function testCollectImpersonatedToken() { $adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', array('ROLE_ADMIN')); $userRoles = array( 'ROLE_USER', new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $adminToken), ); $tokenStorage = new TokenStorage(); $tokenStorage->setToken(new UsernamePasswordToken('hhamon', 'P4$$w0rD', 'provider', $userRoles)); $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); $collector->collect($this->getRequest(), $this->getResponse()); $collector->lateCollect(); $this->assertTrue($collector->isEnabled()); $this->assertTrue($collector->isAuthenticated()); $this->assertTrue($collector->isImpersonated()); $this->assertSame('yceruto', $collector->getImpersonatorUser()); $this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $collector->getTokenClass()->getValue()); $this->assertTrue($collector->supportsRoleHierarchy()); $this->assertSame(array('ROLE_USER', 'ROLE_PREVIOUS_ADMIN'), $collector->getRoles()->getValue(true)); $this->assertSame(array(), $collector->getInheritedRoles()->getValue(true)); $this->assertSame('hhamon', $collector->getUser()); } public function testGetFirewall() { $firewallConfig = new FirewallConfig('dummy', 'security.request_matcher.dummy', 'security.user_checker.dummy'); $request = $this->getRequest(); $firewallMap = $this ->getMockBuilder(FirewallMap::class) ->disableOriginalConstructor() ->getMock(); $firewallMap ->expects($this->once()) ->method('getFirewallConfig') ->with($request) ->willReturn($firewallConfig); $collector = new SecurityDataCollector(null, null, null, null, $firewallMap, new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator())); $collector->collect($request, $this->getResponse()); $collector->lateCollect(); $collected = $collector->getFirewall(); $this->assertSame($firewallConfig->getName(), $collected['name']); $this->assertSame($firewallConfig->allowsAnonymous(), $collected['allows_anonymous']); $this->assertSame($firewallConfig->getRequestMatcher(), $collected['request_matcher']); $this->assertSame($firewallConfig->isSecurityEnabled(), $collected['security_enabled']); $this->assertSame($firewallConfig->isStateless(), $collected['stateless']); $this->assertSame($firewallConfig->getProvider(), $collected['provider']); $this->assertSame($firewallConfig->getContext(), $collected['context']); $this->assertSame($firewallConfig->getEntryPoint(), $collected['entry_point']); $this->assertSame($firewallConfig->getAccessDeniedHandler(), $collected['access_denied_handler']); $this->assertSame($firewallConfig->getAccessDeniedUrl(), $collected['access_denied_url']); $this->assertSame($firewallConfig->getUserChecker(), $collected['user_checker']); $this->assertSame($firewallConfig->getListeners(), $collected['listeners']->getValue()); } public function testGetFirewallReturnsNull() { $request = $this->getRequest(); $response = $this->getResponse(); // Don't inject any firewall map $collector = new SecurityDataCollector(); $collector->collect($request, $response); $this->assertNull($collector->getFirewall()); // Inject an instance that is not context aware $firewallMap = $this ->getMockBuilder(FirewallMapInterface::class) ->disableOriginalConstructor() ->getMock(); $collector = new SecurityDataCollector(null, null, null, null, $firewallMap, new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator())); $collector->collect($request, $response); $this->assertNull($collector->getFirewall()); // Null config $firewallMap = $this ->getMockBuilder(FirewallMap::class) ->disableOriginalConstructor() ->getMock(); $collector = new SecurityDataCollector(null, null, null, null, $firewallMap, new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator())); $collector->collect($request, $response); $this->assertNull($collector->getFirewall()); } /** * @group time-sensitive */ public function testGetListeners() { $request = $this->getRequest(); $event = new GetResponseEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event->setResponse($response = $this->getResponse()); $listener = $this->getMockBuilder(ListenerInterface::class)->getMock(); $listener ->expects($this->once()) ->method('handle') ->with($event); $firewallMap = $this ->getMockBuilder(FirewallMap::class) ->disableOriginalConstructor() ->getMock(); $firewallMap ->expects($this->any()) ->method('getFirewallConfig') ->with($request) ->willReturn(null); $firewallMap ->expects($this->once()) ->method('getListeners') ->with($request) ->willReturn(array(array($listener), null)); $firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()); $firewall->onKernelRequest($event); $collector = new SecurityDataCollector(null, null, null, null, $firewallMap, $firewall); $collector->collect($request, $response); $this->assertNotEmpty($collected = $collector->getListeners()[0]); $collector->lateCollect(); $this->addToAssertionCount(1); } public function provideRoles() { return array( // Basic roles array( array('ROLE_USER'), array('ROLE_USER'), array(), ), array( array(new Role('ROLE_USER')), array('ROLE_USER'), array(), ), // Inherited roles array( array('ROLE_ADMIN'), array('ROLE_ADMIN'), array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), ), array( array(new Role('ROLE_ADMIN')), array('ROLE_ADMIN'), array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), ), array( array('ROLE_ADMIN', 'ROLE_OPERATOR'), array('ROLE_ADMIN', 'ROLE_OPERATOR'), array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), ), ); } private function getRoleHierarchy() { return new RoleHierarchy(array( 'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_OPERATOR' => array('ROLE_USER'), )); } private function getRequest() { return $this ->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() ->getMock(); } private function getResponse() { return $this ->getMockBuilder('Symfony\Component\HttpFoundation\Response') ->disableOriginalConstructor() ->getMock(); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Debug/����������������������������������������0000775�0000000�0000000�00000000000�13247321071�0023765�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php�������0000664�0000000�0000000�00000004613�13247321071�0032420�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Debug; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Http\Firewall\ListenerInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Symfony\Component\VarDumper\Caster\ClassStub; /** * @group time-sensitive */ class TraceableFirewallListenerTest extends TestCase { public function testOnKernelRequestRecordsListeners() { $request = new Request(); $event = new GetResponseEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event->setResponse($response = new Response()); $listener = $this->getMockBuilder(ListenerInterface::class)->getMock(); $listener ->expects($this->once()) ->method('handle') ->with($event); $firewallMap = $this ->getMockBuilder(FirewallMap::class) ->disableOriginalConstructor() ->getMock(); $firewallMap ->expects($this->once()) ->method('getFirewallConfig') ->with($request) ->willReturn(null); $firewallMap ->expects($this->once()) ->method('getListeners') ->with($request) ->willReturn(array(array($listener), null)); $firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()); $firewall->onKernelRequest($event); $listeners = $firewall->getWrappedListeners(); $this->assertCount(1, $listeners); $this->assertSame($response, $listeners[0]['response']); $this->assertInstanceOf(ClassStub::class, $listeners[0]['stub']); $this->assertSame(get_class($listener), (string) $listeners[0]['stub']); } } ���������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/��������������������������0000775�0000000�0000000�00000000000�13247321071�0026660�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/�����������������0000775�0000000�0000000�00000000000�13247321071�0030432�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddSecurityVotersPassTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000011040�13247321071�0036172�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler�������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Tests\Authorization\Stub\VoterWithoutInterface; class AddSecurityVotersPassTest extends TestCase { /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException */ public function testNoVoters() { $container = new ContainerBuilder(); $container ->register('security.access.decision_manager', AccessDecisionManager::class) ->addArgument(array()) ; $compilerPass = new AddSecurityVotersPass(); $compilerPass->process($container); } public function testThatSecurityVotersAreProcessedInPriorityOrder() { $container = new ContainerBuilder(); $container ->register('security.access.decision_manager', AccessDecisionManager::class) ->addArgument(array()) ; $container ->register('no_prio_service', Voter::class) ->addTag('security.voter') ; $container ->register('lowest_prio_service', Voter::class) ->addTag('security.voter', array('priority' => 100)) ; $container ->register('highest_prio_service', Voter::class) ->addTag('security.voter', array('priority' => 200)) ; $container ->register('zero_prio_service', Voter::class) ->addTag('security.voter', array('priority' => 0)) ; $compilerPass = new AddSecurityVotersPass(); $compilerPass->process($container); $argument = $container->getDefinition('security.access.decision_manager')->getArgument(0); $refs = $argument->getValues(); $this->assertEquals(new Reference('highest_prio_service'), $refs[0]); $this->assertEquals(new Reference('lowest_prio_service'), $refs[1]); $this->assertCount(4, $refs); } /** * @group legacy * @expectedDeprecation Using a "security.voter" tag on a class without implementing the "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface" is deprecated as of 3.4 and will throw an exception in 4.0. Implement the interface instead. */ public function testVoterMissingInterface() { $container = new ContainerBuilder(); $container ->register('security.access.decision_manager', AccessDecisionManager::class) ->addArgument(array()) ; $container ->register('without_interface', VoterWithoutInterface::class) ->addTag('security.voter') ; $compilerPass = new AddSecurityVotersPass(); $compilerPass->process($container); $argument = $container->getDefinition('security.access.decision_manager')->getArgument(0); $refs = $argument->getValues(); $this->assertEquals(new Reference('without_interface'), $refs[0]); $this->assertCount(1, $refs); } /** * @group legacy */ public function testVoterMissingInterfaceAndMethod() { $exception = LogicException::class; $message = 'stdClass should implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface interface when used as voter.'; if (method_exists($this, 'expectException')) { $this->expectException($exception); $this->expectExceptionMessage($message); } else { $this->setExpectedException($exception, $message); } $container = new ContainerBuilder(); $container ->register('security.access.decision_manager', AccessDecisionManager::class) ->addArgument(array()) ; $container ->register('without_method', 'stdClass') ->addTag('security.voter') ; $compilerPass = new AddSecurityVotersPass(); $compilerPass->process($container); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AddSessionDomainConstraintPassTest.php��������������������������������������������������������������0000664�0000000�0000000�00000016606�13247321071�0040015�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler�������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSessionDomainConstraintPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; class AddSessionDomainConstraintPassTest extends TestCase { public function testSessionCookie() { $container = $this->createContainer(array('cookie_domain' => '.symfony.com.', 'cookie_secure' => true)); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); $this->assertTrue($utils->createRedirectResponse($request, 'https://symfony.com/blog')->isRedirect('https://symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.symfony.com/blog')->isRedirect('https://www.symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://localhost/foo')->isRedirect('https://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.localhost/foo')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://localhost/')); } public function testSessionNoDomain() { $container = $this->createContainer(array('cookie_secure' => true)); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); $this->assertTrue($utils->createRedirectResponse($request, 'https://symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'https://localhost/foo')->isRedirect('https://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.localhost/foo')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://localhost/')); } public function testSessionNoSecure() { $container = $this->createContainer(array('cookie_domain' => '.symfony.com.')); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); $this->assertTrue($utils->createRedirectResponse($request, 'https://symfony.com/blog')->isRedirect('https://symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.symfony.com/blog')->isRedirect('https://www.symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://localhost/foo')->isRedirect('https://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.localhost/foo')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://symfony.com/blog')->isRedirect('http://symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://localhost/')); } public function testSessionNoSecureAndNoDomain() { $container = $this->createContainer(array()); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); $this->assertTrue($utils->createRedirectResponse($request, 'https://symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'https://localhost/foo')->isRedirect('https://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'http://localhost/foo')->isRedirect('http://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.localhost/foo')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://symfony.com/blog')->isRedirect('http://localhost/')); $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://localhost/')); } public function testNoSession() { $container = $this->createContainer(null); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); $this->assertTrue($utils->createRedirectResponse($request, 'https://symfony.com/blog')->isRedirect('https://symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.symfony.com/blog')->isRedirect('https://www.symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'https://localhost/foo')->isRedirect('https://localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'https://www.localhost/foo')->isRedirect('https://www.localhost/foo')); $this->assertTrue($utils->createRedirectResponse($request, 'http://symfony.com/blog')->isRedirect('http://symfony.com/blog')); $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://pirate.com/foo')); } private function createContainer($sessionStorageOptions) { $container = new ContainerBuilder(); $container->setParameter('kernel.bundles_metadata', array()); $container->setParameter('kernel.cache_dir', __DIR__); $container->setParameter('kernel.charset', 'UTF-8'); $container->setParameter('kernel.container_class', 'cc'); $container->setParameter('kernel.debug', true); $container->setParameter('kernel.project_dir', __DIR__); $container->setParameter('kernel.root_dir', __DIR__); $container->setParameter('kernel.secret', __DIR__); if (null !== $sessionStorageOptions) { $container->setParameter('session.storage.options', $sessionStorageOptions); } $container->setParameter('request_listener.http_port', 80); $container->setParameter('request_listener.https_port', 443); $config = array( 'security' => array( 'providers' => array('some_provider' => array('id' => 'foo')), 'firewalls' => array('some_firewall' => array('security' => false)), ), ); $ext = new FrameworkExtension(); $ext->load(array('framework' => array('csrf_protection' => false)), $container); $ext = new SecurityExtension(); $ext->load($config, $container); $pass = new AddSessionDomainConstraintPass(); $pass->process($container); return $container; } } ��������������������������������������������������������������������������������������������������������������������������CompleteConfigurationTest.php�����������������������������������������������������������������������0000664�0000000�0000000�00000055072�13247321071�0034463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection����������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Reference; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; abstract class CompleteConfigurationTest extends TestCase { abstract protected function getLoader(ContainerBuilder $container); abstract protected function getFileExtension(); public function testRolesHierarchy() { $container = $this->getContainer('container1'); $this->assertEquals(array( 'ROLE_ADMIN' => array('ROLE_USER'), 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_REMOTE' => array('ROLE_USER', 'ROLE_ADMIN'), ), $container->getParameter('security.role_hierarchy.roles')); } /** * @group legacy * @expectedDeprecation The "security.acl" configuration key is deprecated since Symfony 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead. */ public function testRolesHierarchyWithAcl() { $container = $this->getContainer('container1_with_acl'); $this->assertEquals(array( 'ROLE_ADMIN' => array('ROLE_USER'), 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_REMOTE' => array('ROLE_USER', 'ROLE_ADMIN'), ), $container->getParameter('security.role_hierarchy.roles')); } public function testUserProviders() { $container = $this->getContainer('container1'); $providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.user.provider.concrete'); })); $expectedProviders = array( 'security.user.provider.concrete.default', 'security.user.provider.concrete.digest', 'security.user.provider.concrete.basic', 'security.user.provider.concrete.service', 'security.user.provider.concrete.chain', ); $this->assertEquals(array(), array_diff($expectedProviders, $providers)); $this->assertEquals(array(), array_diff($providers, $expectedProviders)); // chain provider $this->assertEquals(array(new IteratorArgument(array( new Reference('security.user.provider.concrete.service'), new Reference('security.user.provider.concrete.basic'), ))), $container->getDefinition('security.user.provider.concrete.chain')->getArguments()); } public function testFirewalls() { $container = $this->getContainer('container1'); $arguments = $container->getDefinition('security.firewall.map')->getArguments(); $listeners = array(); $configs = array(); foreach (array_keys($arguments[1]->getValues()) as $contextId) { $contextDef = $container->getDefinition($contextId); $arguments = $contextDef->getArguments(); $listeners[] = array_map('strval', $arguments['index_0']->getValues()); $configDef = $container->getDefinition((string) $arguments['index_2']); $configs[] = array_values($configDef->getArguments()); } // the IDs of the services are case sensitive or insensitive depending on // the Symfony version. Transform them to lowercase to simplify tests. $configs[0][2] = strtolower($configs[0][2]); $configs[2][2] = strtolower($configs[2][2]); $this->assertEquals(array( array( 'simple', 'security.user_checker', 'security.request_matcher.6tndozi', false, ), array( 'secure', 'security.user_checker', null, true, true, 'security.user.provider.concrete.default', null, 'security.authentication.form_entry_point.secure', null, null, array( 'logout', 'switch_user', 'x509', 'remote_user', 'form_login', 'http_basic', 'remember_me', 'anonymous', ), array( 'parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH', 'stateless' => true, ), ), array( 'host', 'security.user_checker', 'security.request_matcher.and0kk1', true, false, 'security.user.provider.concrete.default', 'host', 'security.authentication.basic_entry_point.host', null, null, array( 'http_basic', 'anonymous', ), null, ), array( 'with_user_checker', 'app.user_checker', null, true, false, 'security.user.provider.concrete.default', 'with_user_checker', 'security.authentication.basic_entry_point.with_user_checker', null, null, array( 'http_basic', 'anonymous', ), null, ), ), $configs); $this->assertEquals(array( array(), array( 'security.channel_listener', 'security.logout_listener.secure', 'security.authentication.listener.x509.secure', 'security.authentication.listener.remote_user.secure', 'security.authentication.listener.form.secure', 'security.authentication.listener.basic.secure', 'security.authentication.listener.rememberme.secure', 'security.authentication.listener.anonymous.secure', 'security.authentication.switchuser_listener.secure', 'security.access_listener', ), array( 'security.channel_listener', 'security.context_listener.0', 'security.authentication.listener.basic.host', 'security.authentication.listener.anonymous.host', 'security.access_listener', ), array( 'security.channel_listener', 'security.context_listener.1', 'security.authentication.listener.basic.with_user_checker', 'security.authentication.listener.anonymous.with_user_checker', 'security.access_listener', ), ), $listeners); $this->assertFalse($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', 'No user checker alias is registered when custom user checker services are registered')); } /** * @group legacy */ public function testFirewallsWithDigest() { $container = $this->getContainer('container1_with_digest'); $arguments = $container->getDefinition('security.firewall.map')->getArguments(); $listeners = array(); $configs = array(); foreach (array_keys($arguments[1]->getValues()) as $contextId) { $contextDef = $container->getDefinition($contextId); $arguments = $contextDef->getArguments(); $listeners[] = array_map('strval', $arguments['index_0']->getValues()); $configDef = $container->getDefinition((string) $arguments['index_2']); $configs[] = array_values($configDef->getArguments()); } // the IDs of the services are case sensitive or insensitive depending on // the Symfony version. Transform them to lowercase to simplify tests. $configs[0][2] = strtolower($configs[0][2]); $configs[2][2] = strtolower($configs[2][2]); $this->assertEquals(array( array( 'simple', 'security.user_checker', 'security.request_matcher.6tndozi', false, ), array( 'secure', 'security.user_checker', null, true, true, 'security.user.provider.concrete.default', null, 'security.authentication.form_entry_point.secure', null, null, array( 'logout', 'switch_user', 'x509', 'remote_user', 'form_login', 'http_basic', 'http_digest', 'remember_me', 'anonymous', ), array( 'parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH', 'stateless' => true, ), ), array( 'host', 'security.user_checker', 'security.request_matcher.and0kk1', true, false, 'security.user.provider.concrete.default', 'host', 'security.authentication.basic_entry_point.host', null, null, array( 'http_basic', 'anonymous', ), null, ), array( 'with_user_checker', 'app.user_checker', null, true, false, 'security.user.provider.concrete.default', 'with_user_checker', 'security.authentication.basic_entry_point.with_user_checker', null, null, array( 'http_basic', 'anonymous', ), null, ), ), $configs); $this->assertEquals(array( array(), array( 'security.channel_listener', 'security.logout_listener.secure', 'security.authentication.listener.x509.secure', 'security.authentication.listener.remote_user.secure', 'security.authentication.listener.form.secure', 'security.authentication.listener.basic.secure', 'security.authentication.listener.digest.secure', 'security.authentication.listener.rememberme.secure', 'security.authentication.listener.anonymous.secure', 'security.authentication.switchuser_listener.secure', 'security.access_listener', ), array( 'security.channel_listener', 'security.context_listener.0', 'security.authentication.listener.basic.host', 'security.authentication.listener.anonymous.host', 'security.access_listener', ), array( 'security.channel_listener', 'security.context_listener.1', 'security.authentication.listener.basic.with_user_checker', 'security.authentication.listener.anonymous.with_user_checker', 'security.access_listener', ), ), $listeners); $this->assertFalse($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', 'No user checker alias is registered when custom user checker services are registered')); } public function testFirewallRequestMatchers() { $container = $this->getContainer('container1'); $arguments = $container->getDefinition('security.firewall.map')->getArguments(); $matchers = array(); foreach ($arguments[1]->getValues() as $reference) { if ($reference instanceof Reference) { $definition = $container->getDefinition((string) $reference); $matchers[] = $definition->getArguments(); } } $this->assertEquals(array( array( '/login', ), array( '/test', 'foo\\.example\\.org', array('GET', 'POST'), ), ), $matchers); } public function testUserCheckerAliasIsRegistered() { $container = $this->getContainer('no_custom_user_checker'); $this->assertTrue($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', 'Alias for user checker is registered when no custom user checker service is registered')); $this->assertFalse($container->getAlias('Symfony\Component\Security\Core\User\UserCheckerInterface')->isPublic()); } public function testAccess() { $container = $this->getContainer('container1'); $rules = array(); foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) { if ('add' == $call[0]) { $rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]); } } $matcherIds = array(); foreach ($rules as list($matcherId, $attributes, $channel)) { $requestMatcher = $container->getDefinition($matcherId); $this->assertArrayNotHasKey($matcherId, $matcherIds); $matcherIds[$matcherId] = true; $i = count($matcherIds); if (1 === $i) { $this->assertEquals(array('ROLE_USER'), $attributes); $this->assertEquals('https', $channel); $this->assertEquals( array('/blog/524', null, array('GET', 'POST')), $requestMatcher->getArguments() ); } elseif (2 === $i) { $this->assertEquals(array('IS_AUTHENTICATED_ANONYMOUSLY'), $attributes); $this->assertNull($channel); $this->assertEquals( array('/blog/.*'), $requestMatcher->getArguments() ); } elseif (3 === $i) { $this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]); $expression = $container->getDefinition((string) $attributes[1])->getArgument(0); $this->assertEquals("token.getUsername() matches '/^admin/'", $expression); } } } public function testMerge() { $container = $this->getContainer('merge'); $this->assertEquals(array( 'FOO' => array('MOO'), 'ADMIN' => array('USER'), ), $container->getParameter('security.role_hierarchy.roles')); } public function testEncoders() { $container = $this->getContainer('container1'); $this->assertEquals(array(array( 'JMS\FooBundle\Entity\User1' => array( 'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', 'arguments' => array(false), ), 'JMS\FooBundle\Entity\User2' => array( 'algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'cost' => 13, ), 'JMS\FooBundle\Entity\User3' => array( 'algorithm' => 'md5', 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'encode_as_base64' => true, 'iterations' => 5000, 'cost' => 13, ), 'JMS\FooBundle\Entity\User4' => new Reference('security.encoder.foo'), 'JMS\FooBundle\Entity\User5' => array( 'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder', 'arguments' => array('sha1', false, 5, 30), ), 'JMS\FooBundle\Entity\User6' => array( 'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', 'arguments' => array(15), ), )), $container->getDefinition('security.encoder_factory.generic')->getArguments()); } public function testArgon2iEncoder() { if (!Argon2iPasswordEncoder::isSupported()) { $this->markTestSkipped('Argon2i algorithm is not supported.'); } $this->assertSame(array(array('JMS\FooBundle\Entity\User7' => array( 'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder', 'arguments' => array(), ))), $this->getContainer('argon2i_encoder')->getDefinition('security.encoder_factory.generic')->getArguments()); } /** * @group legacy * @expectedDeprecation The "security.acl" configuration key is deprecated since Symfony 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead. */ public function testAcl() { $container = $this->getContainer('container1_with_acl'); $this->assertTrue($container->hasDefinition('security.acl.dbal.provider')); $this->assertEquals('security.acl.dbal.provider', (string) $container->getAlias('security.acl.provider')); } /** * @group legacy * @expectedDeprecation The "security.acl" configuration key is deprecated since Symfony 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead. */ public function testCustomAclProvider() { $container = $this->getContainer('custom_acl_provider'); $this->assertFalse($container->hasDefinition('security.acl.dbal.provider')); $this->assertEquals('foo', (string) $container->getAlias('security.acl.provider')); } public function testRememberMeThrowExceptionsDefault() { $container = $this->getContainer('container1'); $this->assertTrue($container->getDefinition('security.authentication.listener.rememberme.secure')->getArgument(5)); } public function testRememberMeThrowExceptions() { $container = $this->getContainer('remember_me_options'); $service = $container->getDefinition('security.authentication.listener.rememberme.main'); $this->assertEquals('security.authentication.rememberme.services.persistent.main', $service->getArgument(1)); $this->assertFalse($service->getArgument(5)); } public function testUserCheckerConfig() { $this->assertEquals('app.user_checker', $this->getContainer('container1')->getAlias('security.user_checker.with_user_checker')); } public function testUserCheckerConfigWithDefaultChecker() { $this->assertEquals('security.user_checker', $this->getContainer('container1')->getAlias('security.user_checker.host')); } public function testUserCheckerConfigWithNoCheckers() { $this->assertEquals('security.user_checker', $this->getContainer('container1')->getAlias('security.user_checker.secure')); } public function testUserPasswordEncoderCommandIsRegistered() { $this->assertTrue($this->getContainer('remember_me_options')->has('security.command.user_password_encoder')); } public function testDefaultAccessDecisionManagerStrategyIsAffirmative() { $container = $this->getContainer('access_decision_manager_default_strategy'); $this->assertSame(AccessDecisionManager::STRATEGY_AFFIRMATIVE, $container->getDefinition('security.access.decision_manager')->getArgument(1), 'Default vote strategy is affirmative'); } public function testCustomAccessDecisionManagerService() { $container = $this->getContainer('access_decision_manager_service'); $this->assertSame('app.access_decision_manager', (string) $container->getAlias('security.access.decision_manager'), 'The custom access decision manager service is aliased'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage "strategy" and "service" cannot be used together. */ public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime() { $container = $this->getContainer('access_decision_manager_service_and_strategy'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Invalid firewall "main": user provider "undefined" not found. */ public function testFirewallUndefinedUserProvider() { $this->getContainer('firewall_undefined_provider'); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Invalid firewall "main": user provider "undefined" not found. */ public function testFirewallListenerUndefinedProvider() { $this->getContainer('listener_undefined_provider'); } public function testFirewallWithUserProvider() { $this->getContainer('firewall_provider'); $this->addToAssertionCount(1); } public function testFirewallListenerWithProvider() { $this->getContainer('listener_provider'); $this->addToAssertionCount(1); } protected function getContainer($file) { $file = $file.'.'.$this->getFileExtension(); $container = new ContainerBuilder(); $security = new SecurityExtension(); $container->registerExtension($security); $bundle = new SecurityBundle(); $bundle->build($container); // Attach all default factories $this->getLoader($container)->load($file); $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); return $container; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/�����������������0000775�0000000�0000000�00000000000�13247321071�0030471�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/UserProvider/����0000775�0000000�0000000�00000000000�13247321071�0033122�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������DummyProvider.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001142�13247321071�0036360�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/UserProvider������������������������������������������������������������������������<?php namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; class DummyProvider implements UserProviderFactoryInterface { public function create(ContainerBuilder $container, $id, $config) { } public function getKey() { return 'foo'; } public function addConfiguration(NodeDefinition $node) { } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/�������������0000775�0000000�0000000�00000000000�13247321071�0031260�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_default_strategy.php��������������������������������������������������������0000664�0000000�0000000�00000000640�13247321071�0042150�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), ), 'firewalls' => array( 'simple' => array('pattern' => '/login', 'security' => false), ), )); ������������������������������������������������������������������������������������������������access_decision_manager_service.php�����������������������������������������������������������������0000664�0000000�0000000�00000001003�13247321071�0040234�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'access_decision_manager' => array( 'service' => 'app.access_decision_manager', ), 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), ), 'firewalls' => array( 'simple' => array('pattern' => '/login', 'security' => false), ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_service_and_strategy.php����������������������������������������������������0000664�0000000�0000000�00000001050�13247321071�0043002�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'access_decision_manager' => array( 'service' => 'app.access_decision_manager', 'strategy' => 'affirmative', ), 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), ), 'firewalls' => array( 'simple' => array('pattern' => '/login', 'security' => false), ), )); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������argon2i_encoder.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000677�13247321071�0034764�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'encoders' => array( 'JMS\FooBundle\Entity\User7' => array( 'algorithm' => 'argon2i', ), ), 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'main' => array( 'form_login' => false, 'http_basic' => null, 'logout_on_user_change' => true, ), ), )); �����������������������������������������������������������������container1.php��������������������������������������������������������������������������������������0000664�0000000�0000000�00000007226�13247321071�0033764�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'encoders' => array( 'JMS\FooBundle\Entity\User1' => 'plaintext', 'JMS\FooBundle\Entity\User2' => array( 'algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, ), 'JMS\FooBundle\Entity\User3' => array( 'algorithm' => 'md5', ), 'JMS\FooBundle\Entity\User4' => array( 'id' => 'security.encoder.foo', ), 'JMS\FooBundle\Entity\User5' => array( 'algorithm' => 'pbkdf2', 'hash_algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, 'key_length' => 30, ), 'JMS\FooBundle\Entity\User6' => array( 'algorithm' => 'bcrypt', 'cost' => 15, ), ), 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), 'digest' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'), ), ), ), 'basic' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'), 'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')), ), ), ), 'service' => array( 'id' => 'user.manager', ), 'chain' => array( 'chain' => array( 'providers' => array('service', 'basic'), ), ), ), 'firewalls' => array( 'simple' => array('provider' => 'default', 'pattern' => '/login', 'security' => false), 'secure' => array('stateless' => true, 'provider' => 'default', 'http_basic' => true, 'form_login' => true, 'anonymous' => true, 'switch_user' => array('stateless' => true), 'x509' => true, 'remote_user' => true, 'logout' => true, 'remember_me' => array('secret' => 'TheSecret'), 'user_checker' => null, 'logout_on_user_change' => true, ), 'host' => array( 'provider' => 'default', 'pattern' => '/test', 'host' => 'foo\\.example\\.org', 'methods' => array('GET', 'POST'), 'anonymous' => true, 'http_basic' => true, 'logout_on_user_change' => true, ), 'with_user_checker' => array( 'provider' => 'default', 'user_checker' => 'app.user_checker', 'anonymous' => true, 'http_basic' => true, 'logout_on_user_change' => true, ), ), 'access_control' => array( array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')), array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), array('path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"), ), 'role_hierarchy' => array( 'ROLE_ADMIN' => 'ROLE_USER', 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN', ), )); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_acl.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000007142�13247321071�0035633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'acl' => array(), 'encoders' => array( 'JMS\FooBundle\Entity\User1' => 'plaintext', 'JMS\FooBundle\Entity\User2' => array( 'algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, ), 'JMS\FooBundle\Entity\User3' => array( 'algorithm' => 'md5', ), 'JMS\FooBundle\Entity\User4' => array( 'id' => 'security.encoder.foo', ), 'JMS\FooBundle\Entity\User5' => array( 'algorithm' => 'pbkdf2', 'hash_algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, 'key_length' => 30, ), 'JMS\FooBundle\Entity\User6' => array( 'algorithm' => 'bcrypt', 'cost' => 15, ), ), 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), 'digest' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'), ), ), ), 'basic' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'), 'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')), ), ), ), 'service' => array( 'id' => 'user.manager', ), 'chain' => array( 'chain' => array( 'providers' => array('service', 'basic'), ), ), ), 'firewalls' => array( 'simple' => array('provider' => 'default', 'pattern' => '/login', 'security' => false), 'secure' => array('stateless' => true, 'provider' => 'default', 'http_basic' => true, 'http_digest' => array('secret' => 'TheSecret'), 'form_login' => true, 'anonymous' => true, 'switch_user' => array('stateless' => true), 'x509' => true, 'remote_user' => true, 'logout' => true, 'remember_me' => array('secret' => 'TheSecret'), 'user_checker' => null, ), 'host' => array( 'provider' => 'default', 'pattern' => '/test', 'host' => 'foo\\.example\\.org', 'methods' => array('GET', 'POST'), 'anonymous' => true, 'http_basic' => true, ), 'with_user_checker' => array( 'provider' => 'default', 'user_checker' => 'app.user_checker', 'anonymous' => true, 'http_basic' => true, ), ), 'access_control' => array( array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')), array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), array('path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"), ), 'role_hierarchy' => array( 'ROLE_ADMIN' => 'ROLE_USER', 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN', ), )); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_digest.php��������������������������������������������������������������������������0000664�0000000�0000000�00000007351�13247321071�0036355�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'acl' => array(), 'encoders' => array( 'JMS\FooBundle\Entity\User1' => 'plaintext', 'JMS\FooBundle\Entity\User2' => array( 'algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, ), 'JMS\FooBundle\Entity\User3' => array( 'algorithm' => 'md5', ), 'JMS\FooBundle\Entity\User4' => array( 'id' => 'security.encoder.foo', ), 'JMS\FooBundle\Entity\User5' => array( 'algorithm' => 'pbkdf2', 'hash_algorithm' => 'sha1', 'encode_as_base64' => false, 'iterations' => 5, 'key_length' => 30, ), 'JMS\FooBundle\Entity\User6' => array( 'algorithm' => 'bcrypt', 'cost' => 15, ), ), 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), 'digest' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'), ), ), ), 'basic' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'), 'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')), ), ), ), 'service' => array( 'id' => 'user.manager', ), 'chain' => array( 'chain' => array( 'providers' => array('service', 'basic'), ), ), ), 'firewalls' => array( 'simple' => array('provider' => 'default', 'pattern' => '/login', 'security' => false), 'secure' => array('stateless' => true, 'provider' => 'default', 'http_basic' => true, 'http_digest' => array('secret' => 'TheSecret'), 'form_login' => true, 'anonymous' => true, 'switch_user' => array('stateless' => true), 'x509' => true, 'remote_user' => true, 'logout' => true, 'remember_me' => array('secret' => 'TheSecret'), 'user_checker' => null, 'logout_on_user_change' => true, ), 'host' => array( 'provider' => 'default', 'pattern' => '/test', 'host' => 'foo\\.example\\.org', 'methods' => array('GET', 'POST'), 'anonymous' => true, 'http_basic' => true, 'logout_on_user_change' => true, ), 'with_user_checker' => array( 'provider' => 'default', 'user_checker' => 'app.user_checker', 'anonymous' => true, 'http_basic' => true, 'logout_on_user_change' => true, ), ), 'access_control' => array( array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')), array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), array('path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"), ), 'role_hierarchy' => array( 'ROLE_ADMIN' => 'ROLE_USER', 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), 'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN', ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������custom_acl_provider.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000000240�13247321071�0035751�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $this->load('container1.php', $container); $container->loadFromExtension('security', array( 'acl' => array( 'provider' => 'foo', ), )); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������firewall_provider.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000001271�13247321071�0035432�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => $memory = array( 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')), ), ), 'with-dash' => array( 'memory' => $memory, ), ), 'firewalls' => array( 'main' => array( 'provider' => 'default', 'form_login' => true, 'logout_on_user_change' => true, ), 'other' => array( 'provider' => 'with-dash', 'form_login' => true, 'logout_on_user_change' => true, ), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������firewall_undefined_provider.php���������������������������������������������������������������������0000664�0000000�0000000�00000000714�13247321071�0037454�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => array( 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')), ), ), ), 'firewalls' => array( 'main' => array( 'provider' => 'undefined', 'form_login' => true, 'logout_on_user_change' => true, ), ), )); ����������������������������������������������������listener_provider.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000000677�13247321071�0035463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => array( 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')), ), ), ), 'firewalls' => array( 'main' => array( 'form_login' => array('provider' => 'default'), 'logout_on_user_change' => true, ), ), )); �����������������������������������������������������������������listener_undefined_provider.php���������������������������������������������������������������������0000664�0000000�0000000�00000000701�13247321071�0037470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => array( 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')), ), ), ), 'firewalls' => array( 'main' => array( 'form_login' => array('provider' => 'undefined'), 'logout_on_user_change' => true, ), ), )); ���������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php����0000664�0000000�0000000�00000000664�13247321071�0033076�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php $this->load('merge_import.php', $container); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'main' => array( 'form_login' => false, 'http_basic' => null, 'logout_on_user_change' => true, ), ), 'role_hierarchy' => array( 'FOO' => array('MOO'), ), )); ����������������������������������������������������������������������������merge_import.php������������������������������������������������������������������������������������0000664�0000000�0000000�00000000537�13247321071�0034410�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'firewalls' => array( 'main' => array( 'form_login' => array( 'login_path' => '/login', ), 'logout_on_user_change' => true, ), ), 'role_hierarchy' => array( 'FOO' => 'BAR', 'ADMIN' => 'USER', ), )); �����������������������������������������������������������������������������������������������������������������������������������������������������������������no_custom_user_checker.php��������������������������������������������������������������������������0000664�0000000�0000000�00000001503�13247321071�0036441�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array( 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), ), ), ), ), 'firewalls' => array( 'simple' => array('pattern' => '/login', 'security' => false), 'secure' => array( 'stateless' => true, 'http_basic' => true, 'form_login' => true, 'anonymous' => true, 'switch_user' => array('stateless' => true), 'x509' => true, 'remote_user' => true, 'logout' => true, 'remember_me' => array('secret' => 'TheSecret'), 'user_checker' => null, ), ), )); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remember_me_options.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000000737�13247321071�0035753�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php���������������������������������������������������������������������������������<?php $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'main' => array( 'form_login' => true, 'remember_me' => array( 'secret' => 'TheSecret', 'catch_exceptions' => false, 'token_provider' => 'token_provider_id', ), 'logout_on_user_change' => true, ), ), )); ���������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/�������������0000775�0000000�0000000�00000000000�13247321071�0031271�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_default_strategy.xml��������������������������������������������������������0000664�0000000�0000000�00000001150�13247321071�0042167�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <firewall name="simple" pattern="/login" security="false" /> </config> </srv:container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_service.xml�����������������������������������������������������������������0000664�0000000�0000000�00000001263�13247321071�0040266�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <access-decision-manager service="app.access_decision_manager" /> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <firewall name="simple" pattern="/login" security="false" /> </config> </srv:container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_service_and_strategy.xml����������������������������������������������������0000664�0000000�0000000�00000001312�13247321071�0043025�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <access-decision-manager service="app.access_decision_manager" strategy="affirmative" /> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <firewall name="simple" pattern="/login" security="false" /> </config> </srv:container> ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������argon2i_encoder.xml���������������������������������������������������������������������������������0000664�0000000�0000000�00000001230�13247321071�0034770�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <encoder class="JMS\FooBundle\Entity\User7" algorithm="argon2i" /> <provider name="default" id="foo" /> <firewall name="main" logout-on-user-change="true"> <form-login login-path="/login" /> </firewall> </config> </srv:container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1.xml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000006127�13247321071�0034005�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <encoder class="JMS\FooBundle\Entity\User1" algorithm="plaintext" /> <encoder class="JMS\FooBundle\Entity\User2" algorithm="sha1" encode-as-base64="false" iterations="5" /> <encoder class="JMS\FooBundle\Entity\User3" algorithm="md5" /> <encoder class="JMS\FooBundle\Entity\User4" id="security.encoder.foo" /> <encoder class="JMS\FooBundle\Entity\User5" algorithm="pbkdf2" hash-algorithm="sha1" encode-as-base64="false" iterations="5" key-length="30" /> <encoder class="JMS\FooBundle\Entity\User6" algorithm="bcrypt" cost="15" /> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <provider name="digest"> <memory> <user name="foo" password="foo" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="basic"> <memory> <user name="foo" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_SUPER_ADMIN" /> <user name="bar" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="service" id="user.manager" /> <provider name="chain"> <chain providers="service, basic" /> </provider> <firewall name="simple" pattern="/login" security="false" provider="default" /> <firewall name="secure" stateless="true" provider="default"> <http-basic /> <form-login /> <anonymous /> <switch-user stateless="true" /> <x509 /> <remote-user /> <user-checker /> <logout /> <remember-me secret="TheSecret"/> </firewall> <firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST" logout-on-user-change="true" provider="default"> <anonymous /> <http-basic /> </firewall> <firewall name="with_user_checker" logout-on-user-change="true" provider="default"> <anonymous /> <http-basic /> <user-checker>app.user_checker</user-checker> </firewall> <role id="ROLE_ADMIN">ROLE_USER</role> <role id="ROLE_SUPER_ADMIN">ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH</role> <role id="ROLE_REMOTE">ROLE_USER,ROLE_ADMIN</role> <rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUsername() matches '/^admin/'" path="/blog/524" /> </config> </srv:container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_acl.xml�����������������������������������������������������������������������������0000664�0000000�0000000�00000006134�13247321071�0035655�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <acl /> <encoder class="JMS\FooBundle\Entity\User1" algorithm="plaintext" /> <encoder class="JMS\FooBundle\Entity\User2" algorithm="sha1" encode-as-base64="false" iterations="5" /> <encoder class="JMS\FooBundle\Entity\User3" algorithm="md5" /> <encoder class="JMS\FooBundle\Entity\User4" id="security.encoder.foo" /> <encoder class="JMS\FooBundle\Entity\User5" algorithm="pbkdf2" hash-algorithm="sha1" encode-as-base64="false" iterations="5" key-length="30" /> <encoder class="JMS\FooBundle\Entity\User6" algorithm="bcrypt" cost="15" /> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <provider name="digest"> <memory> <user name="foo" password="foo" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="basic"> <memory> <user name="foo" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_SUPER_ADMIN" /> <user name="bar" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="service" id="user.manager" /> <provider name="chain"> <chain providers="service, basic" /> </provider> <firewall name="simple" pattern="/login" security="false" provider="default" /> <firewall name="secure" stateless="true" provider="default"> <http-basic /> <http-digest secret="TheSecret" /> <form-login /> <anonymous /> <switch-user stateless="true" /> <x509 /> <remote-user /> <user-checker /> <logout /> <remember-me secret="TheSecret"/> </firewall> <firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST" provider="default"> <anonymous /> <http-basic /> </firewall> <firewall name="with_user_checker" provider="default"> <anonymous /> <http-basic /> <user-checker>app.user_checker</user-checker> </firewall> <role id="ROLE_ADMIN">ROLE_USER</role> <role id="ROLE_SUPER_ADMIN">ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH</role> <role id="ROLE_REMOTE">ROLE_USER,ROLE_ADMIN</role> <rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUsername() matches '/^admin/'" path="/blog/524" /> </config> </srv:container> ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_digest.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000006227�13247321071�0036400�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <acl /> <encoder class="JMS\FooBundle\Entity\User1" algorithm="plaintext" /> <encoder class="JMS\FooBundle\Entity\User2" algorithm="sha1" encode-as-base64="false" iterations="5" /> <encoder class="JMS\FooBundle\Entity\User3" algorithm="md5" /> <encoder class="JMS\FooBundle\Entity\User4" id="security.encoder.foo" /> <encoder class="JMS\FooBundle\Entity\User5" algorithm="pbkdf2" hash-algorithm="sha1" encode-as-base64="false" iterations="5" key-length="30" /> <encoder class="JMS\FooBundle\Entity\User6" algorithm="bcrypt" cost="15" /> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <provider name="digest"> <memory> <user name="foo" password="foo" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="basic"> <memory> <user name="foo" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_SUPER_ADMIN" /> <user name="bar" password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" roles="ROLE_USER, ROLE_ADMIN" /> </memory> </provider> <provider name="service" id="user.manager" /> <provider name="chain"> <chain providers="service, basic" /> </provider> <firewall name="simple" pattern="/login" security="false" provider="default" /> <firewall name="secure" stateless="true" provider="default"> <http-basic /> <http-digest secret="TheSecret" /> <form-login /> <anonymous /> <switch-user stateless="true" /> <x509 /> <remote-user /> <user-checker /> <logout /> <remember-me secret="TheSecret"/> </firewall> <firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST" logout-on-user-change="true" provider="default"> <anonymous /> <http-basic /> </firewall> <firewall name="with_user_checker" logout-on-user-change="true" provider="default"> <anonymous /> <http-basic /> <user-checker>app.user_checker</user-checker> </firewall> <role id="ROLE_ADMIN">ROLE_USER</role> <role id="ROLE_SUPER_ADMIN">ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH</role> <role id="ROLE_REMOTE">ROLE_USER,ROLE_ADMIN</role> <rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" /> <rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUsername() matches '/^admin/'" path="/blog/524" /> </config> </srv:container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������custom_acl_provider.xml�����������������������������������������������������������������������������0000664�0000000�0000000�00000000753�13247321071�0036004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <imports> <import resource="container1.xml"/> </imports> <sec:config> <sec:acl provider="foo" /> </sec:config> </container> ���������������������firewall_provider.xml�������������������������������������������������������������������������������0000664�0000000�0000000�00000001305�13247321071�0035452�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <sec:config> <sec:providers> <sec:provider name="with-dash" id="foo" /> </sec:providers> <sec:firewalls> <sec:firewall name="main" provider="with-dash" logout-on-user-change="true"> <sec:form_login /> </sec:firewall> </sec:firewalls> </sec:config> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������firewall_undefined_provider.xml���������������������������������������������������������������������0000664�0000000�0000000�00000001303�13247321071�0037471�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <sec:config> <sec:providers> <sec:provider name="default" id="foo" /> </sec:providers> <sec:firewalls> <sec:firewall name="main" provider="undefined" logout-on-user-change="true"> <sec:form_login /> </sec:firewall> </sec:firewalls> </sec:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������listener_provider.xml�������������������������������������������������������������������������������0000664�0000000�0000000�00000001301�13247321071�0035466�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <sec:config> <sec:providers> <sec:provider name="default" id="foo" /> </sec:providers> <sec:firewalls> <sec:firewall name="main" logout-on-user-change="true"> <sec:form_login provider="default" /> </sec:firewall> </sec:firewalls> </sec:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������listener_undefined_provider.xml���������������������������������������������������������������������0000664�0000000�0000000�00000001303�13247321071�0037511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <sec:config> <sec:providers> <sec:provider name="default" id="foo" /> </sec:providers> <sec:firewalls> <sec:firewall name="main" logout-on-user-change="true"> <sec:form_login provider="undefined" /> </sec:firewall> </sec:firewalls> </sec:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml����0000664�0000000�0000000�00000001261�13247321071�0033112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <imports> <import resource="merge_import.xml"/> </imports> <sec:config> <sec:provider name="default" id="foo" /> <sec:firewall name="main" form-login="false" logout-on-user-change="true"> <sec:http-basic /> </sec:firewall> <sec:role id="FOO" value="MOO" /> </sec:config> </container> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������merge_import.xml������������������������������������������������������������������������������������0000664�0000000�0000000�00000001115�13247321071�0034423�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <firewall name="main" logout-on-user-change="true"> <form-login login-path="/login" /> </firewall> <role id="FOO" value="BAR" /> <role id="ADMIN" value="USER" /> </config> </srv:container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������no_custom_user_checker.xml��������������������������������������������������������������������������0000664�0000000�0000000�00000001677�13247321071�0036477�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <srv:container xmlns="http://symfony.com/schema/dic/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <config> <provider name="default"> <memory> <user name="foo" password="foo" roles="ROLE_USER" /> </memory> </provider> <firewall name="simple" pattern="/login" security="false" /> <firewall name="secure" stateless="true"> <http-basic /> <form-login /> <anonymous /> <switch-user stateless="true" /> <x509 /> <remote-user /> <user-checker /> <logout /> <remember-me secret="TheSecret"/> </firewall> </config> </srv:container> �����������������������������������������������������������������remember_me_options.xml�����������������������������������������������������������������������������0000664�0000000�0000000�00000001315�13247321071�0035766�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml���������������������������������������������������������������������������������<?xml version="1.0" encoding="UTF-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://symfony.com/schema/dic/security" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <sec:config> <sec:providers> <sec:default id="foo"/> </sec:providers> <sec:firewall name="main" logout-on-user-change="true"> <sec:form-login/> <sec:remember-me secret="TheSecret" catch-exceptions="false" token-provider="token_provider_id" /> </sec:firewall> </sec:config> </container> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/�������������0000775�0000000�0000000�00000000000�13247321071�0031272�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_default_strategy.yml��������������������������������������������������������0000664�0000000�0000000�00000000326�13247321071�0042175�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } firewalls: simple: { pattern: /login, security: false } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_service.yml�����������������������������������������������������������������0000664�0000000�0000000�00000000440�13247321071�0040264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: access_decision_manager: service: app.access_decision_manager providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } firewalls: simple: { pattern: /login, security: false } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������access_decision_manager_service_and_strategy.yml����������������������������������������������������0000664�0000000�0000000�00000000476�13247321071�0043041�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: access_decision_manager: service: app.access_decision_manager strategy: affirmative providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } firewalls: simple: { pattern: /login, security: false } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������argon2i_encoder.yml���������������������������������������������������������������������������������0000664�0000000�0000000�00000000406�13247321071�0034776�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: encoders: JMS\FooBundle\Entity\User7: algorithm: argon2i providers: default: { id: foo } firewalls: main: form_login: false http_basic: ~ logout_on_user_change: true ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1.yml��������������������������������������������������������������������������������������0000664�0000000�0000000�00000005134�13247321071�0034004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: encoders: JMS\FooBundle\Entity\User1: plaintext JMS\FooBundle\Entity\User2: algorithm: sha1 encode_as_base64: false iterations: 5 JMS\FooBundle\Entity\User3: algorithm: md5 JMS\FooBundle\Entity\User4: id: security.encoder.foo JMS\FooBundle\Entity\User5: algorithm: pbkdf2 hash_algorithm: sha1 encode_as_base64: false iterations: 5 key_length: 30 JMS\FooBundle\Entity\User6: algorithm: bcrypt cost: 15 providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } digest: memory: users: foo: { password: foo, roles: 'ROLE_USER, ROLE_ADMIN' } basic: memory: users: foo: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: ROLE_SUPER_ADMIN } bar: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: [ROLE_USER, ROLE_ADMIN] } service: id: user.manager chain: chain: providers: [service, basic] firewalls: simple: { pattern: /login, security: false } secure: provider: default stateless: true http_basic: true form_login: true anonymous: true switch_user: stateless: true x509: true remote_user: true logout: true remember_me: secret: TheSecret user_checker: ~ host: provider: default pattern: /test host: foo\.example\.org methods: [GET,POST] anonymous: true http_basic: true logout_on_user_change: true with_user_checker: provider: default anonymous: ~ http_basic: ~ user_checker: app.user_checker logout_on_user_change: true role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] ROLE_REMOTE: ROLE_USER,ROLE_ADMIN access_control: - { path: /blog/524, role: ROLE_USER, requires_channel: https, methods: [get, POST]} - path: /blog/.* role: IS_AUTHENTICATED_ANONYMOUSLY - { path: /blog/524, role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "token.getUsername() matches '/^admin/'" } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_acl.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000005122�13247321071�0035653�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: acl: ~ encoders: JMS\FooBundle\Entity\User1: plaintext JMS\FooBundle\Entity\User2: algorithm: sha1 encode_as_base64: false iterations: 5 JMS\FooBundle\Entity\User3: algorithm: md5 JMS\FooBundle\Entity\User4: id: security.encoder.foo JMS\FooBundle\Entity\User5: algorithm: pbkdf2 hash_algorithm: sha1 encode_as_base64: false iterations: 5 key_length: 30 JMS\FooBundle\Entity\User6: algorithm: bcrypt cost: 15 providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } digest: memory: users: foo: { password: foo, roles: 'ROLE_USER, ROLE_ADMIN' } basic: memory: users: foo: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: ROLE_SUPER_ADMIN } bar: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: [ROLE_USER, ROLE_ADMIN] } service: id: user.manager chain: chain: providers: [service, basic] firewalls: simple: { pattern: /login, security: false } secure: provider: default stateless: true http_basic: true http_digest: secret: TheSecret form_login: true anonymous: true switch_user: stateless: true x509: true remote_user: true logout: true remember_me: secret: TheSecret user_checker: ~ host: provider: default pattern: /test host: foo\.example\.org methods: [GET,POST] anonymous: true http_basic: true with_user_checker: provider: default anonymous: ~ http_basic: ~ user_checker: app.user_checker role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] ROLE_REMOTE: ROLE_USER,ROLE_ADMIN access_control: - { path: /blog/524, role: ROLE_USER, requires_channel: https, methods: [get, POST]} - path: /blog/.* role: IS_AUTHENTICATED_ANONYMOUSLY - { path: /blog/524, role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "token.getUsername() matches '/^admin/'" } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������container1_with_digest.yml��������������������������������������������������������������������������0000664�0000000�0000000�00000005242�13247321071�0036376�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: acl: ~ encoders: JMS\FooBundle\Entity\User1: plaintext JMS\FooBundle\Entity\User2: algorithm: sha1 encode_as_base64: false iterations: 5 JMS\FooBundle\Entity\User3: algorithm: md5 JMS\FooBundle\Entity\User4: id: security.encoder.foo JMS\FooBundle\Entity\User5: algorithm: pbkdf2 hash_algorithm: sha1 encode_as_base64: false iterations: 5 key_length: 30 JMS\FooBundle\Entity\User6: algorithm: bcrypt cost: 15 providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } digest: memory: users: foo: { password: foo, roles: 'ROLE_USER, ROLE_ADMIN' } basic: memory: users: foo: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: ROLE_SUPER_ADMIN } bar: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: [ROLE_USER, ROLE_ADMIN] } service: id: user.manager chain: chain: providers: [service, basic] firewalls: simple: { pattern: /login, security: false } secure: provider: default stateless: true http_basic: true http_digest: secret: TheSecret form_login: true anonymous: true switch_user: stateless: true x509: true remote_user: true logout: true remember_me: secret: TheSecret user_checker: ~ host: provider: default pattern: /test host: foo\.example\.org methods: [GET,POST] anonymous: true http_basic: true logout_on_user_change: true with_user_checker: provider: default anonymous: ~ http_basic: ~ user_checker: app.user_checker logout_on_user_change: true role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] ROLE_REMOTE: ROLE_USER,ROLE_ADMIN access_control: - { path: /blog/524, role: ROLE_USER, requires_channel: https, methods: [get, POST]} - path: /blog/.* role: IS_AUTHENTICATED_ANONYMOUSLY - { path: /blog/524, role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "token.getUsername() matches '/^admin/'" } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������custom_acl_provider.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000000126�13247321071�0036000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������imports: - { resource: container1.yml } security: acl: provider: foo ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������firewall_provider.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000000742�13247321071�0035460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: { foo: { password: foo, roles: ROLE_USER } } with-dash: memory: users: { foo: { password: foo, roles: ROLE_USER } } firewalls: main: provider: default form_login: true logout_on_user_change: true other: provider: with-dash form_login: true logout_on_user_change: true ������������������������������firewall_undefined_provider.yml���������������������������������������������������������������������0000664�0000000�0000000�00000000405�13247321071�0037475�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: { foo: { password: foo, roles: ROLE_USER } } firewalls: main: provider: undefined form_login: true logout_on_user_change: true �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������listener_provider.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000000402�13247321071�0035471�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: { foo: { password: foo, roles: ROLE_USER } } firewalls: main: form_login: provider: default logout_on_user_change: true ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������listener_undefined_provider.yml���������������������������������������������������������������������0000664�0000000�0000000�00000000404�13247321071�0037514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: { foo: { password: foo, roles: ROLE_USER } } firewalls: main: form_login: provider: undefined logout_on_user_change: true ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/merge.yml����0000664�0000000�0000000�00000000413�13247321071�0033112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: merge_import.yml } security: providers: default: { id: foo } firewalls: main: form_login: false http_basic: ~ logout_on_user_change: true role_hierarchy: FOO: [MOO] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������merge_import.yml������������������������������������������������������������������������������������0000664�0000000�0000000�00000000304�13247321071�0034424�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: firewalls: main: form_login: login_path: /login logout_on_user_change: true role_hierarchy: FOO: BAR ADMIN: USER ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������no_custom_user_checker.yml��������������������������������������������������������������������������0000664�0000000�0000000�00000001067�13247321071�0036472�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: memory: users: foo: { password: foo, roles: ROLE_USER } firewalls: simple: { pattern: /login, security: false } secure: stateless: true http_basic: true form_login: true anonymous: true switch_user: stateless: true x509: true remote_user: true logout: true remember_me: secret: TheSecret user_checker: ~ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remember_me_options.yml�����������������������������������������������������������������������������0000664�0000000�0000000�00000000466�13247321071�0035776�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml���������������������������������������������������������������������������������security: providers: default: id: foo firewalls: main: form_login: true remember_me: secret: TheSecret catch_exceptions: false token_provider: token_provider_id logout_on_user_change: true ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php�0000664�0000000�0000000�00000010047�13247321071�0033647�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration; use Symfony\Component\Config\Definition\Processor; class MainConfigurationTest extends TestCase { /** * The minimal, required config needed to not have any required validation * issues. */ protected static $minimalConfig = array( 'providers' => array( 'stub' => array( 'id' => 'foo', ), ), 'firewalls' => array( 'stub' => array(), 'logout_on_user_change' => true, ), ); /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testNoConfigForProvider() { $config = array( 'providers' => array( 'stub' => array(), ), ); $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processor->processConfiguration($configuration, array($config)); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testManyConfigForProvider() { $config = array( 'providers' => array( 'stub' => array( 'id' => 'foo', 'chain' => array(), ), ), ); $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processor->processConfiguration($configuration, array($config)); } public function testCsrfAliases() { $config = array( 'firewalls' => array( 'stub' => array( 'logout' => array( 'csrf_token_generator' => 'a_token_generator', 'csrf_token_id' => 'a_token_id', ), 'logout_on_user_change' => true, ), ), ); $config = array_merge(static::$minimalConfig, $config); $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processedConfig = $processor->processConfiguration($configuration, array($config)); $this->assertArrayHasKey('csrf_token_generator', $processedConfig['firewalls']['stub']['logout']); $this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']); $this->assertArrayHasKey('csrf_token_id', $processedConfig['firewalls']['stub']['logout']); $this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']); } public function testDefaultUserCheckers() { $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processedConfig = $processor->processConfiguration($configuration, array(static::$minimalConfig)); $this->assertEquals('security.user_checker', $processedConfig['firewalls']['stub']['user_checker']); } public function testUserCheckers() { $config = array( 'firewalls' => array( 'stub' => array( 'user_checker' => 'app.henk_checker', 'logout_on_user_change' => true, ), ), ); $config = array_merge(static::$minimalConfig, $config); $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processedConfig = $processor->processConfiguration($configuration, array($config)); $this->assertEquals('app.henk_checker', $processedConfig['firewalls']['stub']['user_checker']); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������PhpCompleteConfigurationTest.php��������������������������������������������������������������������0000664�0000000�0000000�00000001421�13247321071�0035120�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection����������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\Config\FileLocator; class PhpCompleteConfigurationTest extends CompleteConfigurationTest { protected function getLoader(ContainerBuilder $container) { return new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php')); } protected function getFileExtension() { return 'php'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/�����������������0000775�0000000�0000000�00000000000�13247321071�0030467�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/���������0000775�0000000�0000000�00000000000�13247321071�0032076�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AbstractFactoryTest.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000013242�13247321071�0036465�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory�����������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; class AbstractFactoryTest extends TestCase { public function testCreate() { list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', array( 'use_forward' => true, 'failure_path' => '/foo', 'success_handler' => 'custom_success_handler', 'failure_handler' => 'custom_failure_handler', 'remember_me' => true, ), 'user_provider', 'entry_point'); // auth provider $this->assertEquals('auth_provider', $authProviderId); // listener $this->assertEquals('abstract_listener.foo', $listenerId); $this->assertTrue($container->hasDefinition('abstract_listener.foo')); $definition = $container->getDefinition('abstract_listener.foo'); $this->assertEquals(array( 'index_4' => 'foo', 'index_5' => new Reference('security.authentication.success_handler.foo.abstract_factory'), 'index_6' => new Reference('security.authentication.failure_handler.foo.abstract_factory'), 'index_7' => array( 'use_forward' => true, ), ), $definition->getArguments()); // entry point $this->assertEquals('entry_point', $entryPointId, '->create() does not change the default entry point.'); } /** * @dataProvider getFailureHandlers */ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection) { $options = array( 'remember_me' => true, 'login_path' => '/bar', ); if ($serviceId) { $options['failure_handler'] = $serviceId; } list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point'); $definition = $container->getDefinition('abstract_listener.foo'); $arguments = $definition->getArguments(); $this->assertEquals(new Reference('security.authentication.failure_handler.foo.abstract_factory'), $arguments['index_6']); $failureHandler = $container->findDefinition((string) $arguments['index_6']); $methodCalls = $failureHandler->getMethodCalls(); if ($defaultHandlerInjection) { $this->assertEquals('setOptions', $methodCalls[0][0]); $this->assertEquals(array('login_path' => '/bar'), $methodCalls[0][1][0]); } else { $this->assertCount(0, $methodCalls); } } public function getFailureHandlers() { return array( array(null, true), array('custom_failure_handler', false), ); } /** * @dataProvider getSuccessHandlers */ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection) { $options = array( 'remember_me' => true, 'default_target_path' => '/bar', ); if ($serviceId) { $options['success_handler'] = $serviceId; } list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point'); $definition = $container->getDefinition('abstract_listener.foo'); $arguments = $definition->getArguments(); $this->assertEquals(new Reference('security.authentication.success_handler.foo.abstract_factory'), $arguments['index_5']); $successHandler = $container->findDefinition((string) $arguments['index_5']); $methodCalls = $successHandler->getMethodCalls(); if ($defaultHandlerInjection) { $this->assertEquals('setOptions', $methodCalls[0][0]); $this->assertEquals(array('default_target_path' => '/bar'), $methodCalls[0][1][0]); $this->assertEquals('setProviderKey', $methodCalls[1][0]); $this->assertEquals(array('foo'), $methodCalls[1][1]); } else { $this->assertCount(0, $methodCalls); } } public function getSuccessHandlers() { return array( array(null, true), array('custom_success_handler', false), ); } protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId) { $factory = $this->getMockForAbstractClass('Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory', array()); $factory ->expects($this->once()) ->method('createAuthProvider') ->will($this->returnValue('auth_provider')) ; $factory ->expects($this->atLeastOnce()) ->method('getListenerId') ->will($this->returnValue('abstract_listener')) ; $factory ->expects($this->any()) ->method('getKey') ->will($this->returnValue('abstract_factory')) ; $container = new ContainerBuilder(); $container->register('auth_provider'); $container->register('custom_success_handler'); $container->register('custom_failure_handler'); list($authProviderId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId); return array($container, $authProviderId, $listenerId, $entryPointId); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GuardAuthenticationFactoryTest.php������������������������������������������������������������������0000664�0000000�0000000�00000014526�13247321071�0040672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory�����������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class GuardAuthenticationFactoryTest extends TestCase { /** * @dataProvider getValidConfigurationTests */ public function testAddValidConfiguration(array $inputConfig, array $expectedConfig) { $factory = new GuardAuthenticationFactory(); $nodeDefinition = new ArrayNodeDefinition('guard'); $factory->addConfiguration($nodeDefinition); $node = $nodeDefinition->getNode(); $normalizedConfig = $node->normalize($inputConfig); $finalizedConfig = $node->finalize($normalizedConfig); $this->assertEquals($expectedConfig, $finalizedConfig); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @dataProvider getInvalidConfigurationTests */ public function testAddInvalidConfiguration(array $inputConfig) { $factory = new GuardAuthenticationFactory(); $nodeDefinition = new ArrayNodeDefinition('guard'); $factory->addConfiguration($nodeDefinition); $node = $nodeDefinition->getNode(); $normalizedConfig = $node->normalize($inputConfig); // will validate and throw an exception on invalid $node->finalize($normalizedConfig); } public function getValidConfigurationTests() { $tests = array(); // completely basic $tests[] = array( array( 'authenticators' => array('authenticator1', 'authenticator2'), 'provider' => 'some_provider', 'entry_point' => 'the_entry_point', ), array( 'authenticators' => array('authenticator1', 'authenticator2'), 'provider' => 'some_provider', 'entry_point' => 'the_entry_point', ), ); // testing xml config fix: authenticator -> authenticators $tests[] = array( array( 'authenticator' => array('authenticator1', 'authenticator2'), ), array( 'authenticators' => array('authenticator1', 'authenticator2'), 'entry_point' => null, ), ); return $tests; } public function getInvalidConfigurationTests() { $tests = array(); // testing not empty $tests[] = array( array('authenticators' => array()), ); return $tests; } public function testBasicCreate() { // simple configuration $config = array( 'authenticators' => array('authenticator123'), 'entry_point' => null, ); list($container, $entryPointId) = $this->executeCreate($config, null); $this->assertEquals('authenticator123', $entryPointId); $providerDefinition = $container->getDefinition('security.authentication.provider.guard.my_firewall'); $this->assertEquals(array( 'index_0' => new IteratorArgument(array(new Reference('authenticator123'))), 'index_1' => new Reference('my_user_provider'), 'index_2' => 'my_firewall', 'index_3' => new Reference('security.user_checker.my_firewall'), ), $providerDefinition->getArguments()); $listenerDefinition = $container->getDefinition('security.authentication.listener.guard.my_firewall'); $this->assertEquals('my_firewall', $listenerDefinition->getArgument(2)); $this->assertEquals(array(new Reference('authenticator123')), $listenerDefinition->getArgument(3)->getValues()); } public function testExistingDefaultEntryPointUsed() { // any existing default entry point is used $config = array( 'authenticators' => array('authenticator123'), 'entry_point' => null, ); list(, $entryPointId) = $this->executeCreate($config, 'some_default_entry_point'); $this->assertEquals('some_default_entry_point', $entryPointId); } /** * @expectedException \LogicException */ public function testCannotOverrideDefaultEntryPoint() { // any existing default entry point is used $config = array( 'authenticators' => array('authenticator123'), 'entry_point' => 'authenticator123', ); $this->executeCreate($config, 'some_default_entry_point'); } /** * @expectedException \LogicException */ public function testMultipleAuthenticatorsRequiresEntryPoint() { // any existing default entry point is used $config = array( 'authenticators' => array('authenticator123', 'authenticatorABC'), 'entry_point' => null, ); $this->executeCreate($config, null); } public function testCreateWithEntryPoint() { // any existing default entry point is used $config = array( 'authenticators' => array('authenticator123', 'authenticatorABC'), 'entry_point' => 'authenticatorABC', ); list($container, $entryPointId) = $this->executeCreate($config, null); $this->assertEquals('authenticatorABC', $entryPointId); } private function executeCreate(array $config, $defaultEntryPointId) { $container = new ContainerBuilder(); $container->register('security.authentication.provider.guard'); $container->register('security.authentication.listener.guard'); $id = 'my_firewall'; $userProviderId = 'my_user_provider'; $factory = new GuardAuthenticationFactory(); list($providerId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId); return array($container, $entryPointId); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php�0000664�0000000�0000000�00000024030�13247321071�0033734�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider; use Symfony\Component\DependencyInjection\ContainerBuilder; class SecurityExtensionTest extends TestCase { /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*". */ public function testInvalidCheckPath() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/secured_area/.*', 'form_login' => array( 'check_path' => '/some_area/login_check', ), 'logout_on_user_change' => true, ), ), )); $container->compile(); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage No authentication listener registered for firewall "some_firewall" */ public function testFirewallWithoutAuthenticationListener() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', 'logout_on_user_change' => true, ), ), )); $container->compile(); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider */ public function testFirewallWithInvalidUserProvider() { $container = $this->getRawContainer(); $extension = $container->getExtension('security'); $extension->addUserProviderFactory(new DummyProvider()); $container->loadFromExtension('security', array( 'providers' => array( 'my_foo' => array('foo' => array()), ), 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', 'http_basic' => array(), 'logout_on_user_change' => true, ), ), )); $container->compile(); } public function testDisableRoleHierarchyVoter() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'role_hierarchy' => null, 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', 'http_basic' => null, 'logout_on_user_change' => true, ), ), )); $container->compile(); $this->assertFalse($container->hasDefinition('security.access.role_hierarchy_voter')); } /** * @group legacy * @expectedDeprecation Not setting "logout_on_user_change" to true on firewall "some_firewall" is deprecated as of 3.4, it will always be true in 4.0. */ public function testConfiguresLogoutOnUserChangeForContextListenersCorrectly() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', 'http_basic' => null, 'logout_on_user_change' => false, ), 'some_other_firewall' => array( 'pattern' => '/.*', 'http_basic' => null, 'logout_on_user_change' => true, ), ), )); $container->compile(); $this->assertEquals(array(array('setLogoutOnUserChange', array(false))), $container->getDefinition('security.context_listener.0')->getMethodCalls()); $this->assertEquals(array(array('setLogoutOnUserChange', array(true))), $container->getDefinition('security.context_listener.1')->getMethodCalls()); } /** * @group legacy * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Firewalls "some_firewall" and "some_other_firewall" need to have the same value for option "logout_on_user_change" as they are sharing the context "my_context" */ public function testThrowsIfLogoutOnUserChangeDifferentForSharedContext() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', 'http_basic' => null, 'context' => 'my_context', 'logout_on_user_change' => false, ), 'some_other_firewall' => array( 'pattern' => '/.*', 'http_basic' => null, 'context' => 'my_context', 'logout_on_user_change' => true, ), ), )); $container->compile(); } /** * @group legacy * @expectedDeprecation Firewall "some_firewall" is configured as "stateless" but the "switch_user.stateless" key is set to false. Both should have the same value, the firewall's "stateless" value will be used as default value for the "switch_user.stateless" key in 4.0. */ public function testSwitchUserNotStatelessOnStatelessFirewall() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'default' => array('id' => 'foo'), ), 'firewalls' => array( 'some_firewall' => array( 'stateless' => true, 'http_basic' => null, 'switch_user' => array('stateless' => false), 'logout_on_user_change' => true, ), ), )); $container->compile(); } /** * @group legacy * @expectedDeprecation Listener "http_basic" on firewall "default" has no "provider" set but multiple providers exist. Using the first configured provider (first) is deprecated since Symfony 3.4 and will throw an exception in 4.0, set the "provider" key on the firewall instead. */ public function testDeprecationForAmbiguousProvider() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'first' => array('id' => 'foo'), 'second' => array('id' => 'bar'), ), 'firewalls' => array( 'default' => array( 'http_basic' => null, 'logout_on_user_change' => true, ), ), )); $container->compile(); } public function testPerListenerProvider() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'first' => array('id' => 'foo'), 'second' => array('id' => 'bar'), ), 'firewalls' => array( 'default' => array( 'http_basic' => array('provider' => 'second'), 'logout_on_user_change' => true, ), ), )); $container->compile(); $this->addToAssertionCount(1); } public function testPerListenerProviderWithRememberMe() { $container = $this->getRawContainer(); $container->loadFromExtension('security', array( 'providers' => array( 'first' => array('id' => 'foo'), 'second' => array('id' => 'bar'), ), 'firewalls' => array( 'default' => array( 'form_login' => array('provider' => 'second'), 'logout_on_user_change' => true, 'remember_me' => array('secret' => 'baz'), ), ), )); $container->compile(); $this->addToAssertionCount(1); } protected function getRawContainer() { $container = new ContainerBuilder(); $security = new SecurityExtension(); $container->registerExtension($security); $bundle = new SecurityBundle(); $bundle->build($container); $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); return $container; } protected function getContainer() { $container = $this->getRawContainer(); $container->compile(); return $container; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������XmlCompleteConfigurationTest.php��������������������������������������������������������������������0000664�0000000�0000000�00000001421�13247321071�0035131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection����������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; class XmlCompleteConfigurationTest extends CompleteConfigurationTest { protected function getLoader(ContainerBuilder $container) { return new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')); } protected function getFileExtension() { return 'xml'; } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������YamlCompleteConfigurationTest.php�������������������������������������������������������������������0000664�0000000�0000000�00000001424�13247321071�0035276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection����������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator; class YamlCompleteConfigurationTest extends CompleteConfigurationTest { protected function getLoader(ContainerBuilder $container) { return new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml')); } protected function getFileExtension() { return 'yml'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/�����������������������������������0000775�0000000�0000000�00000000000�13247321071�0025041�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php���0000664�0000000�0000000�00000001306�13247321071�0033371�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; class AuthenticationCommencingTest extends WebTestCase { public function testAuthenticationIsCommencingIfAccessDeniedExceptionIsWrapped() { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'config.yml')); $client->request('GET', '/secure-but-not-covered-by-access-control'); $this->assertRedirect($client->getResponse(), '/login'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php������������0000664�0000000�0000000�00000003007�13247321071�0031567�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; class AutowiringTypesTest extends WebTestCase { public function testAccessDecisionManagerAutowiring() { static::bootKernel(array('debug' => false)); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode'); static::bootKernel(array('debug' => true)); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode'); } protected static function createKernel(array $options = array()) { return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/����������������������������0000775�0000000�0000000�00000000000�13247321071�0026252�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AclBundle/������������������0000775�0000000�0000000�00000000000�13247321071�0030103�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AclBundle/AclBundle.php�����0000664�0000000�0000000�00000000712�13247321071�0032445�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AclBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * @author Kévin Dunglas <kevin@les-tilleuls.coop> */ class AclBundle extends Bundle { } ������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AclBundle/Entity/�����������0000775�0000000�0000000�00000000000�13247321071�0031357�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AclBundle/Entity/Car.php����0000664�0000000�0000000�00000000646�13247321071�0032603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AclBundle\Entity; /** * Car. * * @author Kévin Dunglas <kevin@les-tilleuls.coop> */ class Car { public $id; } ������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AutowiringBundle/�����������0000775�0000000�0000000�00000000000�13247321071�0031534�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AutowiredServices.php�������������������������������������������������������������������������������0000664�0000000�0000000�00000001340�13247321071�0035633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AutowiringBundle�������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; class AutowiredServices { private $accessDecisionManager; public function __construct(AccessDecisionManagerInterface $accessDecisionManager) { $this->accessDecisionManager = $accessDecisionManager; } public function getAccessDecisionManager() { return $this->accessDecisionManager; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������AutowiringBundle.php��������������������������������������������������������������������������������0000664�0000000�0000000�00000000634�13247321071�0035453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AutowiringBundle�������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class AutowiringBundle extends Bundle { } ����������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/��������0000775�0000000�0000000�00000000000�13247321071�0032116�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Controller/�����������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034162�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle����������������������������������������������������������������������������LoginController.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000002667�13247321071�0040022�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller�����������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AccessDeniedException; class LoginController implements ContainerAwareInterface { use ContainerAwareTrait; public function loginAction() { $form = $this->container->get('form.factory')->create('Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType'); return new Response($this->container->get('twig')->render('@CsrfFormLogin/Login/login.html.twig', array( 'form' => $form->createView(), ))); } public function afterLoginAction() { return new Response($this->container->get('twig')->render('@CsrfFormLogin/Login/after_login.html.twig')); } public function loginCheckAction() { return new Response('', 400); } public function secureAction() { throw new \Exception('Wrapper', 0, new \Exception('Another Wrapper', 0, new AccessDeniedException())); } } �������������������������������������������������������������������������CsrfFormLoginBundle.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000000642�13247321071�0036416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle����������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class CsrfFormLoginBundle extends Bundle { } ����������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/���0000775�0000000�0000000�00000000000�13247321071�0033021�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������UserLoginType.php�����������������������������������������������������������������������������������0000664�0000000�0000000�00000005604�13247321071�0036231�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form�����������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Security; /** * Form type for use with the Security component's form-based authentication * listener. * * @author Henrik Bjornskov <henrik@bjrnskov.dk> * @author Jeremy Mikola <jmikola@gmail.com> */ class UserLoginType extends AbstractType { private $requestStack; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('username', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->add('password', 'Symfony\Component\Form\Extension\Core\Type\PasswordType') ->add('_target_path', 'Symfony\Component\Form\Extension\Core\Type\HiddenType') ; $request = $this->requestStack->getCurrentRequest(); /* Note: since the Security component's form login listener intercepts * the POST request, this form will never really be bound to the * request; however, we can match the expected behavior by checking the * session for an authentication error and last username. */ $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($request) { if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $error = $request->attributes->get(Security::AUTHENTICATION_ERROR); } else { $error = $request->getSession()->get(Security::AUTHENTICATION_ERROR); } if ($error) { $event->getForm()->addError(new FormError($error->getMessage())); } $event->setData(array_replace((array) $event->getData(), array( 'username' => $request->getSession()->get(Security::LAST_USERNAME), ))); }); } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { /* Note: the form's csrf_token_id must correspond to that for the form login * listener in order for the CSRF token to validate successfully. */ $resolver->setDefaults(array( 'csrf_token_id' => 'authenticate', )); } } ����������������������������������������������������������������������������������������������������������������������������Resources/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034011�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle����������������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035256�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources������������������������������������������������������������������routing.yml�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000001603�13247321071�0037470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/config�����������������������������������������������������������form_login: path: /login defaults: { _controller: CsrfFormLoginBundle:Login:login } form_login_check: path: /login_check defaults: { _controller: CsrfFormLoginBundle:Login:loginCheck } form_login_homepage: path: / defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_custom_target_path: path: /foo defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_default_target_path: path: /profile defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_redirect_to_protected_resource_after_login: path: /protected-resource defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_logout: path: /logout_path form_secure_action: path: /secure-but-not-covered-by-access-control defaults: { _controller: CsrfFormLoginBundle:Login:secure } �����������������������������������������������������������������������������������������������������������������������������views/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035146�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources������������������������������������������������������������������Login/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0036216�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/views������������������������������������������������������������after_login.html.twig�������������������������������������������������������������������������������0000664�0000000�0000000�00000000444�13247321071�0042350�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/views/Login������������������������������������������������������{% extends "base.html.twig" %} {% block body %} Hello {{ app.user.username }}!<br /><br /> You're browsing to path "{{ app.request.pathInfo }}".<br /><br /> <a href="{{ logout_path('default') }}">Log out</a>. <a href="{{ logout_url('default') }}">Log out</a>. {% endblock %} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������login.html.twig�������������������������������������������������������������������������������������0000664�0000000�0000000�00000000514�13247321071�0041165�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/views/Login������������������������������������������������������{% extends "base.html.twig" %} {% block body %} <form action="{{ path('form_login_check') }}" method="post"> {{ form_widget(form) }} {# Note: ensure the submit name does not conflict with the form's name or it may clobber field data #} <input type="submit" name="login" /> </form> {% endblock %} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/���0000775�0000000�0000000�00000000000�13247321071�0033205�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������DependencyInjection/��������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0037047�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle�����������������������������������������������������������������������FirewallEntryPointExtension.php���������������������������������������������������������������������0000664�0000000�0000000�00000001526�13247321071�0045262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection���������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; class FirewallEntryPointExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������FirewallEntryPointBundle.php������������������������������������������������������������������������0000664�0000000�0000000�00000000654�13247321071�0040577�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle�����������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class FirewallEntryPointBundle extends Bundle { } ������������������������������������������������������������������������������������Resources/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035100�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle�����������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0036345�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources�������������������������������������������������������������services.xml����������������������������������������������������������������������������������������0000664�0000000�0000000�00000001005�13247321071�0040706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources/config������������������������������������������������������<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <service id="firewall_entry_point.entry_point.stub" class="Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub" /> </services> </container> ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Security/�������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034735�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle�����������������������������������������������������������������������EntryPointStub.php����������������������������������������������������������������������������������0000664�0000000�0000000�00000001557�13247321071�0040427�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security��������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; class EntryPointStub implements AuthenticationEntryPointInterface { const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741'; public function start(Request $request, AuthenticationException $authException = null) { return new Response(self::RESPONSE_TEXT); } } �������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/������������0000775�0000000�0000000�00000000000�13247321071�0031300�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/�0000775�0000000�0000000�00000000000�13247321071�0033423�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������LocalizedController.php�����������������������������������������������������������������������������0000664�0000000�0000000�00000003610�13247321071�0040027�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller���������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Security\Core\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class LocalizedController implements ContainerAwareInterface { use ContainerAwareTrait; public function loginAction(Request $request) { // get the login error if there is one if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $error = $request->attributes->get(Security::AUTHENTICATION_ERROR); } else { $error = $request->getSession()->get(Security::AUTHENTICATION_ERROR); } return new Response($this->container->get('twig')->render('@FormLogin/Localized/login.html.twig', array( // last username entered by the user 'last_username' => $request->getSession()->get(Security::LAST_USERNAME), 'error' => $error, ))); } public function loginCheckAction() { throw new \RuntimeException('loginCheckAction() should never be called.'); } public function logoutAction() { throw new \RuntimeException('logoutAction() should never be called.'); } public function secureAction() { throw new \RuntimeException('secureAction() should never be called.'); } public function profileAction() { return new Response('Profile'); } public function homepageAction() { return new Response('Homepage'); } } ������������������������������������������������������������������������������������������������������������������������LoginController.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000003646�13247321071�0037202�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller���������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\User\UserInterface; class LoginController implements ContainerAwareInterface { use ContainerAwareTrait; public function loginAction(Request $request, UserInterface $user = null) { // get the login error if there is one if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $error = $request->attributes->get(Security::AUTHENTICATION_ERROR); } else { $error = $request->getSession()->get(Security::AUTHENTICATION_ERROR); } return new Response($this->container->get('twig')->render('@FormLogin/Login/login.html.twig', array( // last username entered by the user 'last_username' => $request->getSession()->get(Security::LAST_USERNAME), 'error' => $error, ))); } public function afterLoginAction(UserInterface $user) { return new Response($this->container->get('twig')->render('@FormLogin/Login/after_login.html.twig', array('user' => $user))); } public function loginCheckAction() { return new Response('', 400); } public function secureAction() { throw new \Exception('Wrapper', 0, new \Exception('Another Wrapper', 0, new AccessDeniedException())); } } ������������������������������������������������������������������������������������������DependencyInjection/��������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035142�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle��������������������������������������������������������������������������������FormLoginExtension.php������������������������������������������������������������������������������0000664�0000000�0000000�00000001575�13247321071�0041454�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/DependencyInjection������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; class FormLoginExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { $container ->register('localized_form_failure_handler', 'Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Security\LocalizedFormFailureHandler') ->addArgument(new Reference('router')) ; } } �����������������������������������������������������������������������������������������������������������������������������������FormLoginBundle.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000632�13247321071�0034761�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle��������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class FormLoginBundle extends Bundle { } ������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/��0000775�0000000�0000000�00000000000�13247321071�0033252�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������config/���������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034440�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources����������������������������������������������������������������������localized_routing.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000001752�13247321071�0040705�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config���������������������������������������������������������������localized_login_path: path: /{_locale}/login defaults: { _controller: FormLoginBundle:Localized:login } requirements: { _locale: "^[a-z]{2}$" } localized_check_path: path: /{_locale}/login_check defaults: { _controller: FormLoginBundle:Localized:loginCheck } requirements: { _locale: "^[a-z]{2}$" } localized_default_target_path: path: /{_locale}/profile defaults: { _controller: FormLoginBundle:Localized:profile } requirements: { _locale: "^[a-z]{2}$" } localized_logout_path: path: /{_locale}/logout defaults: { _controller: FormLoginBundle:Localized:logout } requirements: { _locale: "^[a-z]{2}$" } localized_logout_target_path: path: /{_locale}/ defaults: { _controller: FormLoginBundle:Localized:homepage } requirements: { _locale: "^[a-z]{2}$" } localized_secure_path: path: /{_locale}/secure/ defaults: { _controller: FormLoginBundle:Localized:secure } requirements: { _locale: "^[a-z]{2}$" } ����������������������routing.yml�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000002133�13247321071�0036651�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config���������������������������������������������������������������form_login: path: /login defaults: { _controller: FormLoginBundle:Login:login } form_login_check: path: /login_check defaults: { _controller: FormLoginBundle:Login:loginCheck } form_login_homepage: path: / defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_custom_target_path: path: /foo defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_default_target_path: path: /profile defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_redirect_to_protected_resource_after_login: path: /protected_resource defaults: { _controller: FormLoginBundle:Login:afterLogin } highly_protected_resource: path: /highly_protected_resource secured-by-one-ip: path: /secured-by-one-ip secured-by-two-ips: path: /secured-by-two-ips form_logout: path: /logout_path form_secure_action: path: /secure-but-not-covered-by-access-control defaults: { _controller: FormLoginBundle:Login:secure } protected-via-expression: path: /protected-via-expression �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������views/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0034330�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources����������������������������������������������������������������������Localized/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0036236�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/views����������������������������������������������������������������login.html.twig�������������������������������������������������������������������������������������0000664�0000000�0000000�00000001105�13247321071�0041202�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/views/Localized������������������������������������������������������{% extends "base.html.twig" %} {% block body %} {% if error %} <div>{{ error.message }}</div> {% endif %} <form action="{{ path('localized_check_path') }}" method="post"> <label for="username">Username:</label> <input type="text" id="username" name="_username" value="{{ last_username }}" /> <label for="password">Password:</label> <input type="password" id="password" name="_password" /> <input type="hidden" name="_target_path" value="" /> <input type="submit" name="login" /> </form> {% endblock %} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Login/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0035400�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/views����������������������������������������������������������������after_login.html.twig�������������������������������������������������������������������������������0000664�0000000�0000000�00000000754�13247321071�0041536�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/views/Login����������������������������������������������������������{% extends "base.html.twig" %} {% block body %} Hello {{ user.username }}!<br /><br /> You're browsing to path "{{ app.request.pathInfo }}". <a href="{{ logout_path('default') }}">Log out</a>. <a href="{{ logout_url('default') }}">Log out</a>. <a href="{{ logout_path('second_area') }}">Log out</a>. <a href="{{ logout_url('second_area') }}">Log out</a>. <a href="{{ logout_path() }}">Log out</a>. <a href="{{ logout_url() }}">Log out</a>. {% endblock %} ��������������������login.html.twig�������������������������������������������������������������������������������������0000664�0000000�0000000�00000001101�13247321071�0040340�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/views/Login����������������������������������������������������������{% extends "base.html.twig" %} {% block body %} {% if error %} <div>{{ error.message }}</div> {% endif %} <form action="{{ path('form_login_check') }}" method="post"> <label for="username">Username:</label> <input type="text" id="username" name="_username" value="{{ last_username }}" /> <label for="password">Password:</label> <input type="password" id="password" name="_password" /> <input type="hidden" name="_target_path" value="" /> <input type="submit" name="login" /> </form> {% endblock %} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/���0000775�0000000�0000000�00000000000�13247321071�0033107�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������LocalizedFormFailureHandler.php���������������������������������������������������������������������0000664�0000000�0000000�00000002204�13247321071�0041077�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security�����������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Security; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; class LocalizedFormFailureHandler implements AuthenticationFailureHandlerInterface { private $router; public function __construct(RouterInterface $router) { $this->router = $router; } public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { return new RedirectResponse($this->router->generate('localized_login_path', array(), UrlGeneratorInterface::ABSOLUTE_URL)); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/������������0000775�0000000�0000000�00000000000�13247321071�0031306�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller/�0000775�0000000�0000000�00000000000�13247321071�0033431�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������TestController.php����������������������������������������������������������������������������������0000664�0000000�0000000�00000001260�13247321071�0037045�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller���������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\Controller; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Security\Core\User\UserInterface; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class TestController { public function loginCheckAction(UserInterface $user) { return new JsonResponse(array('message' => sprintf('Welcome @%s!', $user->getUsername()))); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������JsonLoginBundle.php���������������������������������������������������������������������������������0000664�0000000�0000000�00000000720�13247321071�0034773�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle��������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class JsonLoginBundle extends Bundle { } ������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/���0000775�0000000�0000000�00000000000�13247321071�0033115�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Http/�����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13247321071�0033755�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security�����������������������������������������������������������������������JsonAuthenticationFailureHandler.php����������������������������������������������������������������0000664�0000000�0000000�00000001555�13247321071�0043113�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\Security\Http; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; class JsonAuthenticationFailureHandler implements AuthenticationFailureHandlerInterface { public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { return new JsonResponse(array('message' => 'Something went wrong'), 500); } } ���������������������������������������������������������������������������������������������������������������������������������������������������JsonAuthenticationSuccessHandler.php����������������������������������������������������������������0000664�0000000�0000000�00000001567�13247321071�0043137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\Security\Http; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; class JsonAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface { public function onAuthenticationSuccess(Request $request, TokenInterface $token) { return new JsonResponse(array('message' => sprintf('Good game @%s!', $token->getUsername()))); } } �����������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php��������������0000664�0000000�0000000�00000007252�13247321071�0031132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; class CsrfFormLoginTest extends WebTestCase { /** * @dataProvider getConfigs */ public function testFormLoginAndLogoutWithCsrfTokens($config) { $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[username]'] = 'johannes'; $form['user_login[password]'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/profile'); $crawler = $client->followRedirect(); $text = $crawler->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/profile".', $text); $logoutLinks = $crawler->selectLink('Log out')->links(); $this->assertCount(2, $logoutLinks); $this->assertContains('_csrf_token=', $logoutLinks[0]->getUri()); $this->assertSame($logoutLinks[0]->getUri(), $logoutLinks[1]->getUri()); $client->click($logoutLinks[0]); $this->assertRedirect($client->getResponse(), '/'); } /** * @dataProvider getConfigs */ public function testFormLoginWithInvalidCsrfToken($config) { $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[_token]'] = ''; $client->submit($form); $this->assertRedirect($client->getResponse(), '/login'); $text = $client->followRedirect()->text(); $this->assertContains('Invalid CSRF token.', $text); } /** * @dataProvider getConfigs */ public function testFormLoginWithCustomTargetPath($config) { $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[username]'] = 'johannes'; $form['user_login[password]'] = 'test'; $form['user_login[_target_path]'] = '/foo'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/foo'); $text = $client->followRedirect()->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/foo".', $text); } /** * @dataProvider getConfigs */ public function testFormLoginRedirectsToProtectedResourceAfterLogin($config) { $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); $client->request('GET', '/protected-resource'); $this->assertRedirect($client->getResponse(), '/login'); $form = $client->followRedirect()->selectButton('login')->form(); $form['user_login[username]'] = 'johannes'; $form['user_login[password]'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/protected-resource'); $text = $client->followRedirect()->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/protected-resource".', $text); } public function getConfigs() { return array( array('config.yml'), array('routes_as_path.yml'), ); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php���������0000664�0000000�0000000�00000002706�13247321071�0032220�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub; class FirewallEntryPointTest extends WebTestCase { public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials() { $client = $this->createClient(array('test_case' => 'FirewallEntryPoint')); $client->request('GET', '/secure/resource', array(), array(), array( 'PHP_AUTH_USER' => 'unknown', 'PHP_AUTH_PW' => 'credentials', )); $this->assertEquals( EntryPointStub::RESPONSE_TEXT, $client->getResponse()->getContent(), "Custom entry point wasn't started" ); } public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFormLoginAndNoCredentials() { $client = $this->createClient(array('test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml')); $client->request('GET', '/secure/resource'); $this->assertEquals( EntryPointStub::RESPONSE_TEXT, $client->getResponse()->getContent(), "Custom entry point wasn't started" ); } } ����������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php������������������0000664�0000000�0000000�00000007753�13247321071�0030322�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; class FormLoginTest extends WebTestCase { /** * @dataProvider getConfigs */ public function testFormLogin($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/profile'); $text = $client->followRedirect()->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/profile".', $text); } /** * @dataProvider getConfigs */ public function testFormLogout($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/profile'); $crawler = $client->followRedirect(); $text = $crawler->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/profile".', $text); $logoutLinks = $crawler->selectLink('Log out')->links(); $this->assertCount(6, $logoutLinks); $this->assertSame($logoutLinks[0]->getUri(), $logoutLinks[1]->getUri()); $this->assertSame($logoutLinks[2]->getUri(), $logoutLinks[3]->getUri()); $this->assertSame($logoutLinks[4]->getUri(), $logoutLinks[5]->getUri()); $this->assertNotSame($logoutLinks[0]->getUri(), $logoutLinks[2]->getUri()); $this->assertNotSame($logoutLinks[1]->getUri(), $logoutLinks[3]->getUri()); $this->assertSame($logoutLinks[0]->getUri(), $logoutLinks[4]->getUri()); $this->assertSame($logoutLinks[1]->getUri(), $logoutLinks[5]->getUri()); } /** * @dataProvider getConfigs */ public function testFormLoginWithCustomTargetPath($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $form['_target_path'] = '/foo'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/foo'); $text = $client->followRedirect()->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/foo".', $text); } /** * @dataProvider getConfigs */ public function testFormLoginRedirectsToProtectedResourceAfterLogin($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->request('GET', '/protected_resource'); $this->assertRedirect($client->getResponse(), '/login'); $form = $client->followRedirect()->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/protected_resource'); $text = $client->followRedirect()->text(); $this->assertContains('Hello johannes!', $text); $this->assertContains('You\'re browsing to path "/protected_resource".', $text); } public function getConfigs() { return array( array('config.yml'), array('routes_as_path.yml'), ); } } ���������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php������������������0000664�0000000�0000000�00000006721�13247321071�0030322�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Component\HttpFoundation\JsonResponse; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class JsonLoginTest extends WebTestCase { public function testDefaultJsonLoginSuccess() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "foo"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); $this->assertSame(array('message' => 'Welcome @dunglas!'), json_decode($response->getContent(), true)); } public function testDefaultJsonLoginFailure() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "bad"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(401, $response->getStatusCode()); $this->assertSame(array('error' => 'Invalid credentials.'), json_decode($response->getContent(), true)); } public function testCustomJsonLoginSuccess() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml')); $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "foo"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); $this->assertSame(array('message' => 'Good game @dunglas!'), json_decode($response->getContent(), true)); } public function testCustomJsonLoginFailure() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml')); $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "bad"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(500, $response->getStatusCode()); $this->assertSame(array('message' => 'Something went wrong'), json_decode($response->getContent(), true)); } public function testDefaultJsonLoginBadRequest() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), 'Not a json content'); $response = $client->getResponse(); $this->assertSame(400, $response->getStatusCode()); $this->assertSame('application/json', $response->headers->get('Content-Type')); $this->assertArraySubset(array('error' => array('code' => 400, 'message' => 'Bad Request')), json_decode($response->getContent(), true)); } } �����������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php������0000664�0000000�0000000�00000005155�13247321071�0032631�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; class LocalizedRoutesAsPathTest extends WebTestCase { /** * @dataProvider getLocales */ public function testLoginLogoutProcedure($locale) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); $crawler = $client->request('GET', '/'.$locale.'/login'); $form = $crawler->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/'.$locale.'/profile'); $this->assertEquals('Profile', $client->followRedirect()->text()); $client->request('GET', '/'.$locale.'/logout'); $this->assertRedirect($client->getResponse(), '/'.$locale.'/'); $this->assertEquals('Homepage', $client->followRedirect()->text()); } /** * @dataProvider getLocales */ public function testLoginFailureWithLocalizedFailurePath($locale) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_form_failure_handler.yml')); $crawler = $client->request('GET', '/'.$locale.'/login'); $form = $crawler->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'foobar'; $client->submit($form); $this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); } /** * @dataProvider getLocales */ public function testAccessRestrictedResource($locale) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); $client->request('GET', '/'.$locale.'/secure/'); $this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); } /** * @dataProvider getLocales */ public function testAccessRestrictedResourceWithForward($locale) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml')); $crawler = $client->request('GET', '/'.$locale.'/secure/'); $this->assertCount(1, $crawler->selectButton('login'), (string) $client->getResponse()); } public function getLocales() { return array(array('en'), array('de')); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php�0000664�0000000�0000000�00000011215�13247321071�0033775�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; class SecurityRoutingIntegrationTest extends WebTestCase { /** * @dataProvider getConfigs */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->request('GET', '/protected_resource'); $this->assertRedirect($client->getResponse(), '/login'); } /** * @dataProvider getConfigs */ public function testRoutingErrorIsExposedWhenNotProtected($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->request('GET', '/unprotected_resource'); $this->assertEquals(404, $client->getResponse()->getStatusCode(), (string) $client->getResponse()); } /** * @dataProvider getConfigs */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $client->submit($form); $client->request('GET', '/highly_protected_resource'); $this->assertNotEquals(404, $client->getResponse()->getStatusCode()); } /** * @dataProvider getConfigs */ public function testSecurityConfigurationForSingleIPAddress($config) { $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.10.10')); $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.20.10')); $this->assertAllowed($allowedClient, '/secured-by-one-ip'); $this->assertRestricted($barredClient, '/secured-by-one-ip'); } /** * @dataProvider getConfigs */ public function testSecurityConfigurationForMultipleIPAddresses($config) { $allowedClientA = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '1.1.1.1')); $allowedClientB = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '2.2.2.2')); $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '192.168.1.1')); $this->assertAllowed($allowedClientA, '/secured-by-two-ips'); $this->assertAllowed($allowedClientB, '/secured-by-two-ips'); $this->assertRestricted($barredClient, '/secured-by-two-ips'); } /** * @dataProvider getConfigs */ public function testSecurityConfigurationForExpression($config) { $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('HTTP_USER_AGENT' => 'Firefox 1.0')); $this->assertAllowed($allowedClient, '/protected-via-expression'); $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array()); $this->assertRestricted($barredClient, '/protected-via-expression'); $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array()); $allowedClient->request('GET', '/protected-via-expression'); $form = $allowedClient->followRedirect()->selectButton('login')->form(); $form['_username'] = 'johannes'; $form['_password'] = 'test'; $allowedClient->submit($form); $this->assertRedirect($allowedClient->getResponse(), '/protected-via-expression'); $this->assertAllowed($allowedClient, '/protected-via-expression'); } private function assertAllowed($client, $path) { $client->request('GET', $path); $this->assertEquals(404, $client->getResponse()->getStatusCode()); } private function assertRestricted($client, $path) { $client->request('GET', $path); $this->assertEquals(302, $client->getResponse()->getStatusCode()); } public function getConfigs() { return array(array('config.yml'), array('routes_as_path.yml')); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php�������������������0000664�0000000�0000000�00000002221�13247321071�0030216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\User\User; class SecurityTest extends WebTestCase { public function testServiceIsFunctional() { $kernel = self::createKernel(array('test_case' => 'SecurityHelper', 'root_config' => 'config.yml')); $kernel->boot(); $container = $kernel->getContainer(); // put a token into the storage so the final calls can function $user = new User('foo', 'pass'); $token = new UsernamePasswordToken($user, '', 'provider', array('ROLE_USER')); $container->get('security.token_storage')->setToken($token); $security = $container->get('functional_test.security.helper'); $this->assertTrue($security->isGranted('ROLE_USER')); $this->assertSame($token, $security->getToken()); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php��������������0000664�0000000�0000000�00000016733�13247321071�0031076�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\SecurityBundle\Command\SetAclCommand; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Security\Acl\Domain\ObjectIdentity; use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; use Symfony\Component\Security\Acl\Exception\NoAceFoundException; use Symfony\Component\Security\Acl\Permission\BasicPermissionMap; /** * Tests SetAclCommand. * * @author Kévin Dunglas <kevin@les-tilleuls.coop> * @requires extension pdo_sqlite * @group legacy */ class SetAclCommandTest extends WebTestCase { const OBJECT_CLASS = 'Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AclBundle\Entity\Car'; const SECURITY_CLASS = 'Symfony\Component\Security\Core\User\User'; public function testSetAclUser() { $objectId = 1; $securityUsername1 = 'kevin'; $securityUsername2 = 'anne'; $grantedPermission1 = 'VIEW'; $grantedPermission2 = 'EDIT'; $application = $this->getApplication(); $application->add(new SetAclCommand()); $setAclCommand = $application->find('acl:set'); $setAclCommandTester = new CommandTester($setAclCommand); $setAclCommandTester->execute(array( 'command' => 'acl:set', 'arguments' => array($grantedPermission1, $grantedPermission2, sprintf('%s:%s', self::OBJECT_CLASS, $objectId)), '--user' => array(sprintf('%s:%s', self::SECURITY_CLASS, $securityUsername1), sprintf('%s:%s', self::SECURITY_CLASS, $securityUsername2)), )); $objectIdentity = new ObjectIdentity($objectId, self::OBJECT_CLASS); $securityIdentity1 = new UserSecurityIdentity($securityUsername1, self::SECURITY_CLASS); $securityIdentity2 = new UserSecurityIdentity($securityUsername2, self::SECURITY_CLASS); $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl = $aclProvider->findAcl($objectIdentity, array($securityIdentity1)); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission1, null), array($securityIdentity1))); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission1, null), array($securityIdentity2))); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission2, null), array($securityIdentity2))); try { $acl->isGranted($permissionMap->getMasks('OWNER', null), array($securityIdentity1)); $this->fail('NoAceFoundException not throwed'); } catch (NoAceFoundException $e) { } try { $acl->isGranted($permissionMap->getMasks('OPERATOR', null), array($securityIdentity2)); $this->fail('NoAceFoundException not throwed'); } catch (NoAceFoundException $e) { } } public function testSetAclRole() { $objectId = 1; $securityUsername = 'kevin'; $grantedPermission = 'VIEW'; $role = 'ROLE_ADMIN'; $application = $this->getApplication(); $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('test.security.acl.provider'))); $setAclCommand = $application->find('acl:set'); $setAclCommandTester = new CommandTester($setAclCommand); $setAclCommandTester->execute(array( 'command' => 'acl:set', 'arguments' => array($grantedPermission, sprintf('%s:%s', str_replace('\\', '/', self::OBJECT_CLASS), $objectId)), '--role' => array($role), )); $objectIdentity = new ObjectIdentity($objectId, self::OBJECT_CLASS); $userSecurityIdentity = new UserSecurityIdentity($securityUsername, self::SECURITY_CLASS); $roleSecurityIdentity = new RoleSecurityIdentity($role); $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl = $aclProvider->findAcl($objectIdentity, array($roleSecurityIdentity, $userSecurityIdentity)); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); try { $acl->isGranted($permissionMap->getMasks('VIEW', null), array($userSecurityIdentity)); $this->fail('NoAceFoundException not throwed'); } catch (NoAceFoundException $e) { } try { $acl->isGranted($permissionMap->getMasks('OPERATOR', null), array($userSecurityIdentity)); $this->fail('NoAceFoundException not throwed'); } catch (NoAceFoundException $e) { } } public function testSetAclClassScope() { $objectId = 1; $grantedPermission = 'VIEW'; $role = 'ROLE_USER'; $application = $this->getApplication(); $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('test.security.acl.provider'))); $setAclCommand = $application->find('acl:set'); $setAclCommandTester = new CommandTester($setAclCommand); $setAclCommandTester->execute(array( 'command' => 'acl:set', 'arguments' => array($grantedPermission, sprintf('%s:%s', self::OBJECT_CLASS, $objectId)), '--class-scope' => true, '--role' => array($role), )); $objectIdentity1 = new ObjectIdentity($objectId, self::OBJECT_CLASS); $objectIdentity2 = new ObjectIdentity(2, self::OBJECT_CLASS); $roleSecurityIdentity = new RoleSecurityIdentity($role); $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl1 = $aclProvider->findAcl($objectIdentity1, array($roleSecurityIdentity)); $this->assertTrue($acl1->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); $acl2 = $aclProvider->createAcl($objectIdentity2); $this->assertTrue($acl2->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); } private function getApplication() { $kernel = $this->createKernel(array('test_case' => 'Acl')); $kernel->boot(); $application = new Application($kernel); $initAclCommand = $application->find('init:acl'); $initAclCommandTester = new CommandTester($initAclCommand); $initAclCommandTester->execute(array('command' => 'init:acl')); return $application; } } �������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php�����������������0000664�0000000�0000000�00000007224�13247321071�0030517�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Security\Http\Firewall\SwitchUserListener; class SwitchUserTest extends WebTestCase { /** * @dataProvider getTestParameters */ public function testSwitchUser($originalUser, $targetUser, $expectedUser, $expectedStatus) { $client = $this->createAuthenticatedClient($originalUser); $client->request('GET', '/profile?_switch_user='.$targetUser); $this->assertEquals($expectedStatus, $client->getResponse()->getStatusCode()); $this->assertEquals($expectedUser, $client->getProfile()->getCollector('security')->getUser()); } public function testSwitchedUserCannotSwitchToOther() { $client = $this->createAuthenticatedClient('user_can_switch'); $client->request('GET', '/profile?_switch_user=user_cannot_switch_1'); $client->request('GET', '/profile?_switch_user=user_cannot_switch_2'); $this->assertEquals(500, $client->getResponse()->getStatusCode()); $this->assertEquals('user_cannot_switch_1', $client->getProfile()->getCollector('security')->getUser()); } public function testSwitchedUserExit() { $client = $this->createAuthenticatedClient('user_can_switch'); $client->request('GET', '/profile?_switch_user=user_cannot_switch_1'); $client->request('GET', '/profile?_switch_user='.SwitchUserListener::EXIT_VALUE); $this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals('user_can_switch', $client->getProfile()->getCollector('security')->getUser()); } public function testSwitchUserStateless() { $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'switchuser_stateless.yml')); $client->request('POST', '/chk', array(), array(), array('HTTP_X_SWITCH_USER' => 'dunglas', 'CONTENT_TYPE' => 'application/json'), '{"user": {"login": "user_can_switch", "password": "test"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); $this->assertSame(array('message' => 'Welcome @dunglas!'), json_decode($response->getContent(), true)); $this->assertSame('dunglas', $client->getProfile()->getCollector('security')->getUser()); } public function getTestParameters() { return array( 'unauthorized_user_cannot_switch' => array('user_cannot_switch_1', 'user_cannot_switch_1', 'user_cannot_switch_1', 403), 'authorized_user_can_switch' => array('user_can_switch', 'user_cannot_switch_1', 'user_cannot_switch_1', 200), 'authorized_user_cannot_switch_to_non_existent' => array('user_can_switch', 'user_does_not_exist', 'user_can_switch', 500), 'authorized_user_can_switch_to_himself' => array('user_can_switch', 'user_can_switch', 'user_can_switch', 200), ); } protected function createAuthenticatedClient($username) { $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'switchuser.yml')); $client->followRedirects(true); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = $username; $form['_password'] = 'test'; $client->submit($form); return $client; } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php�0000664�0000000�0000000�00000026210�13247321071�0033653�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand; use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder; /** * Tests UserPasswordEncoderCommand. * * @author Sarah Khalil <mkhalil.sarah@gmail.com> */ class UserPasswordEncoderCommandTest extends WebTestCase { /** @var CommandTester */ private $passwordEncoderCommandTester; public function testEncodePasswordEmptySalt() { $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Symfony\Component\Security\Core\User\User', '--empty-salt' => true, ), array('decorated' => false)); $expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt')); $this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay()); } public function testEncodeNoPasswordNoInteraction() { $statusCode = $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', ), array('interactive' => false)); $this->assertContains('[ERROR] The password must not be empty.', $this->passwordEncoderCommandTester->getDisplay()); $this->assertEquals($statusCode, 1); } public function testEncodePasswordBcrypt() { $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Custom\Class\Bcrypt\User', ), array('interactive' => false)); $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertContains('Password encoding succeeded', $output); $encoder = new BCryptPasswordEncoder(17); preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); } public function testEncodePasswordArgon2i() { if (!Argon2iPasswordEncoder::isSupported()) { $this->markTestSkipped('Argon2i algorithm not available.'); } $this->setupArgon2i(); $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Custom\Class\Argon2i\User', ), array('interactive' => false)); $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertContains('Password encoding succeeded', $output); $encoder = new Argon2iPasswordEncoder(); preg_match('# Encoded password\s+(\$argon2id\$[\w\d,=\$+\/]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); } public function testEncodePasswordPbkdf2() { $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Custom\Class\Pbkdf2\User', ), array('interactive' => false)); $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertContains('Password encoding succeeded', $output); $encoder = new Pbkdf2PasswordEncoder('sha512', true, 1000); preg_match('# Encoded password\s{1,}([\w+\/]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; preg_match('# Generated salt\s{1,}([\w+\/]+={0,2})\s+#', $output, $matches); $salt = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', $salt)); } public function testEncodePasswordOutput() { $this->passwordEncoderCommandTester->execute( array( 'command' => 'security:encode-password', 'password' => 'p@ssw0rd', ), array('interactive' => false) ); $this->assertContains('Password encoding succeeded', $this->passwordEncoderCommandTester->getDisplay()); $this->assertContains(' Encoded password p@ssw0rd', $this->passwordEncoderCommandTester->getDisplay()); $this->assertContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } public function testEncodePasswordEmptySaltOutput() { $this->passwordEncoderCommandTester->execute( array( 'command' => 'security:encode-password', 'password' => 'p@ssw0rd', 'user-class' => 'Symfony\Component\Security\Core\User\User', '--empty-salt' => true, ) ); $this->assertContains('Password encoding succeeded', $this->passwordEncoderCommandTester->getDisplay()); $this->assertContains(' Encoded password p@ssw0rd', $this->passwordEncoderCommandTester->getDisplay()); $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } public function testEncodePasswordBcryptOutput() { $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'p@ssw0rd', 'user-class' => 'Custom\Class\Bcrypt\User', ), array('interactive' => false)); $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } public function testEncodePasswordArgon2iOutput() { if (!Argon2iPasswordEncoder::isSupported()) { $this->markTestSkipped('Argon2i algorithm not available.'); } $this->setupArgon2i(); $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'p@ssw0rd', 'user-class' => 'Custom\Class\Argon2i\User', ), array('interactive' => false)); $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } public function testEncodePasswordNoConfigForGivenUserClass() { if (method_exists($this, 'expectException')) { $this->expectException('\RuntimeException'); $this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".'); } else { $this->setExpectedException('\RuntimeException', 'No encoder has been configured for account "Foo\Bar\User".'); } $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Foo\Bar\User', ), array('interactive' => false)); } public function testEncodePasswordAsksNonProvidedUserClass() { $this->passwordEncoderCommandTester->setInputs(array('Custom\Class\Pbkdf2\User', "\n")); $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', ), array('decorated' => false)); $this->assertContains(<<<EOTXT For which user class would you like to encode a password? [Custom\Class\Bcrypt\User]: [0] Custom\Class\Bcrypt\User [1] Custom\Class\Pbkdf2\User [2] Custom\Class\Test\User [3] Symfony\Component\Security\Core\User\User EOTXT , $this->passwordEncoderCommandTester->getDisplay(true)); } public function testNonInteractiveEncodePasswordUsesFirstUserClass() { $this->passwordEncoderCommandTester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', ), array('interactive' => false)); $this->assertContains('Encoder used Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', $this->passwordEncoderCommandTester->getDisplay()); } /** * @expectedException \RuntimeException * @expectedExceptionMessage There are no configured encoders for the "security" extension. */ public function testThrowsExceptionOnNoConfiguredEncoders() { $application = new ConsoleApplication(); $application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), array())); $passwordEncoderCommand = $application->find('security:encode-password'); $tester = new CommandTester($passwordEncoderCommand); $tester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', ), array('interactive' => false)); } /** * @group legacy * @expectedDeprecation Passing null as the first argument of "Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand::__construct" is deprecated since Symfony 3.3 and will be removed in 4.0. If the command was registered by convention, make it a service instead. */ public function testLegacy() { $application = new ConsoleApplication(); $application->add(new UserPasswordEncoderCommand()); $passwordEncoderCommand = $application->find('security:encode-password'); self::bootKernel(array('test_case' => 'PasswordEncode')); $passwordEncoderCommand->setContainer(self::$kernel->getContainer()); $tester = new CommandTester($passwordEncoderCommand); $tester->execute(array( 'command' => 'security:encode-password', 'password' => 'password', ), array('interactive' => false)); $this->assertContains('Encoder used Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', $tester->getDisplay()); } protected function setUp() { putenv('COLUMNS='.(119 + strlen(PHP_EOL))); $kernel = $this->createKernel(array('test_case' => 'PasswordEncode')); $kernel->boot(); $application = new Application($kernel); $passwordEncoderCommand = $application->get('security:encode-password'); $this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand); } protected function tearDown() { $this->passwordEncoderCommandTester = null; } private function setupArgon2i() { putenv('COLUMNS='.(119 + strlen(PHP_EOL))); $kernel = $this->createKernel(array('test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml')); $kernel->boot(); $application = new Application($kernel); $passwordEncoderCommand = $application->get('security:encode-password'); $this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php��������������������0000664�0000000�0000000�00000004123�13247321071�0027723�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase; use Symfony\Component\Filesystem\Filesystem; class WebTestCase extends BaseWebTestCase { public static function assertRedirect($response, $location) { self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.substr($response, 0, 2000)); self::assertEquals('http://localhost'.$location, $response->headers->get('Location')); } public static function setUpBeforeClass() { static::deleteTmpDir(); } public static function tearDownAfterClass() { static::deleteTmpDir(); } protected static function deleteTmpDir() { if (!file_exists($dir = sys_get_temp_dir().'/'.static::getVarDir())) { return; } $fs = new Filesystem(); $fs->remove($dir); } protected static function getKernelClass() { require_once __DIR__.'/app/AppKernel.php'; return 'Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel'; } protected static function createKernel(array $options = array()) { $class = self::getKernelClass(); if (!isset($options['test_case'])) { throw new \InvalidArgumentException('The option "test_case" must be set.'); } return new $class( static::getVarDir(), $options['test_case'], isset($options['root_config']) ? $options['root_config'] : 'config.yml', isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']), isset($options['debug']) ? $options['debug'] : true ); } protected static function getVarDir() { return 'SB'.substr(strrchr(get_called_class(), '\\'), 1); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/�������������������������������0000775�0000000�0000000�00000000000�13247321071�0025621�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/���������������������������0000775�0000000�0000000�00000000000�13247321071�0026320�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/bundles.php����������������0000664�0000000�0000000�00000000777�13247321071�0030500�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AclBundle\AclBundle(), ); �symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/config.yml�����������������0000664�0000000�0000000�00000001231�13247321071�0030305�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/framework.yml } services: _defaults: { public: true } test.security.acl.provider: '@security.acl.provider' doctrine: dbal: driver: pdo_sqlite memory: true charset: UTF8 security: firewalls: test: pattern: ^/ security: false acl: connection: default encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: kevin: { password: test, roles: [ROLE_USER] } anne: { password: test, roles: [ROLE_ADMIN]} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/doctrine.yml���������������0000664�0000000�0000000�00000000330�13247321071�0030646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged services: Doctrine\Bundle\DoctrineBundle\Command\: resource: "@DoctrineBundle/Command/*" tags: [console.command] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php������������������0000664�0000000�0000000�00000006062�13247321071�0030217�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app; use Doctrine\ORM\Version; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; /** * App Test Kernel for functional tests. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class AppKernel extends Kernel { private $varDir; private $testCase; private $rootConfig; public function __construct($varDir, $testCase, $rootConfig, $environment, $debug) { if (!is_dir(__DIR__.'/'.$testCase)) { throw new \InvalidArgumentException(sprintf('The test case "%s" does not exist.', $testCase)); } $this->varDir = $varDir; $this->testCase = $testCase; $fs = new Filesystem(); if (!$fs->isAbsolutePath($rootConfig) && !is_file($rootConfig = __DIR__.'/'.$testCase.'/'.$rootConfig)) { throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig)); } $this->rootConfig = $rootConfig; parent::__construct($environment, $debug); } /** * {@inheritdoc} */ public function getName() { if (null === $this->name) { $this->name = parent::getName().substr(md5($this->rootConfig), -16); } return $this->name; } public function registerBundles() { if (!is_file($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) { throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename)); } return include $filename; } public function getRootDir() { return __DIR__; } public function getCacheDir() { return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/cache/'.$this->environment; } public function getLogDir() { return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/logs'; } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load($this->rootConfig); // to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged if ('Acl' === $this->testCase && class_exists(Version::class)) { $loader->load(__DIR__.'/Acl/doctrine.yml'); } } public function serialize() { return serialize(array($this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug())); } public function unserialize($str) { $a = unserialize($str); $this->__construct($a[0], $a[1], $a[2], $a[3], $a[4]); } protected function getKernelParameters() { $parameters = parent::getKernelParameters(); $parameters['kernel.test_case'] = $this->testCase; return $parameters; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/���������������0000775�0000000�0000000�00000000000�13247321071�0030776�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/bundles.php����0000664�0000000�0000000�00000000724�13247321071�0033146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiringBundle(), ); ��������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/config.yml�����0000664�0000000�0000000�00000000605�13247321071�0032767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ../config/framework.yml } services: _defaults: { public: true } test.autowiring_types.autowired_services: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiredServices autowire: true security: providers: dummy: memory: ~ firewalls: dummy: security: false ���������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/�����������������0000775�0000000�0000000�00000000000�13247321071�0030333�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/bundles.php������0000664�0000000�0000000�00000001012�13247321071�0032472�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\CsrfFormLoginBundle(), ); ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml�������0000664�0000000�0000000�00000003130�13247321071�0032320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/default.yml } services: csrf_form_login.form.type: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType arguments: - '@request_stack' tags: - { name: form.type } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: johannes: { password: test, roles: [ROLE_USER] } firewalls: # This firewall doesn't make sense in combination with the rest of the # configuration file, but it's here for testing purposes (do not use # this file in a real world scenario though) login_form: pattern: ^/login$ security: false default: logout_on_user_change: true form_login: check_path: /login_check default_target_path: /profile target_path_parameter: "user_login[_target_path]" failure_path_parameter: "user_login[_failure_path]" username_parameter: "user_login[username]" password_parameter: "user_login[password]" csrf_parameter: "user_login[_token]" csrf_token_generator: security.csrf.token_manager anonymous: ~ logout: path: /logout_path target: / csrf_token_generator: security.csrf.token_manager access_control: - { path: .*, roles: IS_AUTHENTICATED_FULLY } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������routes_as_path.yml����������������������������������������������������������������������������������0000664�0000000�0000000�00000000547�13247321071�0034025�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin�������������������������������������������������������������������������������������imports: - { resource: ./config.yml } security: firewalls: default: form_login: login_path: form_login check_path: form_login_check default_target_path: form_login_default_target_path logout: path: form_logout target: form_login_homepage ���������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/routing.yml������0000664�0000000�0000000�00000000133�13247321071�0032542�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������_csrf_form_login_bundle: resource: '@CsrfFormLoginBundle/Resources/config/routing.yml' �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/������������0000775�0000000�0000000�00000000000�13247321071�0031422�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php�0000664�0000000�0000000�00000000744�13247321071�0033574�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\FirewallEntryPointBundle(), ); ����������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml��0000664�0000000�0000000�00000001750�13247321071�0033415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������framework: secret: test router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } csrf_protection: true form: true test: ~ default_locale: en session: storage_id: session.storage.mock_file profiler: { only_exceptions: false } services: logger: { class: Psr\Log\NullLogger } security: firewalls: secure: logout_on_user_change: true pattern: ^/secure/ http_basic: { realm: "Secure Gateway API" } entry_point: firewall_entry_point.entry_point.stub default: logout_on_user_change: true anonymous: ~ access_control: - { path: ^/secure/, roles: ROLE_SECURE } providers: in_memory: memory: users: john: { password: doe, roles: [ROLE_SECURE] } encoders: Symfony\Component\Security\Core\User\User: plaintext ������������������������config_form_login.yml�������������������������������������������������������������������������������0000664�0000000�0000000�00000000255�13247321071�0035550�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint��������������������������������������������������������������������������������imports: - { resource: ./config.yml } security: firewalls: secure: pattern: ^/ form_login: check_path: /login_check ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/routing.yml�0000664�0000000�0000000�00000000054�13247321071�0033633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������secure_resource: path: /secure/resource ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/���������������������0000775�0000000�0000000�00000000000�13247321071�0027523�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/bundles.php����������0000664�0000000�0000000�00000001002�13247321071�0031661�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\JsonLoginBundle(), ); ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml�����������0000664�0000000�0000000�00000001151�13247321071�0031511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/framework.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: dunglas: { password: foo, roles: [ROLE_USER] } firewalls: main: logout_on_user_change: true pattern: ^/ anonymous: true json_login: check_path: /chk username_path: user.login password_path: user.password access_control: - { path: ^/foo, roles: ROLE_USER } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml��0000664�0000000�0000000�00000002062�13247321071�0033440�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/framework.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: dunglas: { password: foo, roles: [ROLE_USER] } firewalls: main: logout_on_user_change: true pattern: ^/ anonymous: true json_login: check_path: /chk username_path: user.login password_path: user.password success_handler: json_login.success_handler failure_handler: json_login.failure_handler access_control: - { path: ^/foo, roles: ROLE_USER } services: json_login.success_handler: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\Security\Http\JsonAuthenticationSuccessHandler json_login.failure_handler: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\Security\Http\JsonAuthenticationFailureHandler ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/routing.yml����������0000664�0000000�0000000�00000000133�13247321071�0031732�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������login_check: path: /chk defaults: { _controller: JsonLoginBundle:Test:loginCheck } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������switchuser_stateless.yml����������������������������������������������������������������������������0000664�0000000�0000000�00000000545�13247321071�0034462�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000�symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin�����������������������������������������������������������������������������������������imports: - { resource: ./config.yml } security: providers: in_memory: memory: users: user_can_switch: { password: test, roles: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH] } firewalls: main: switch_user: parameter: X-Switch-User stateless: true �����������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/����������������0000775�0000000�0000000�00000000000�13247321071�0030541�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/argon2i.yml�����0000664�0000000�0000000�00000000203�13247321071�0032620�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: config.yml } security: encoders: Custom\Class\Argon2i\User: algorithm: argon2i ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bundles.php�����0000664�0000000�0000000�00000000561�13247321071�0032710�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return array( new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), ); �����������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/config.yml������0000664�0000000�0000000�00000001372�13247321071�0032534�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imports: - { resource: ./../config/framework.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext Custom\Class\Bcrypt\User: algorithm: bcrypt cost: 10 Custom\Class\Pbkdf2\User: algorithm: pbkdf2 hash_algorithm: sha512 encode_as_base64: true iterations: 1000 Custom\Class\Test\User: test providers: in_memory: memory: users: user: { password: userpass, roles: [ 'ROLE_USER' ] } admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] } firewalls: test: pattern: ^/ security: false ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/emptysalt.txt���0000664�0000000�0000000�00000001317�13247321071�0033326�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ Symfony Password Encoder Utility ================================ ------------------ ------------------------------------------------------------------ Key Value ------------------ ------------------------------------------------------------------ Encoder used Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder Encoded password password ------------------ ------------------------------------------------------------------ [OK] Password encoding succeeded �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Resources/���������������������0000775�0000000�0000000�00000000000�13247321071�0027573�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Resources/views/���������������0000775�0000000�0000000�00000000000�13247321071�0030730�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Resources/views/base.html.twig�0000664�0000000�0000000�00000000471�13247321071�0033503�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE html> <html> <head> <meta charset="{{ _charset }}" /> <title>{% block title %}Welcome!{% endblock %} {% block stylesheets %}{% endblock %} {% block body %}{% endblock %} {% block javascripts %}{% endblock %} symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/000077500000000000000000000000001324732107100305705ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/bundles.php000066400000000000000000000007331324732107100327400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new SecurityBundle(), new TwigBundle(), ); symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/config.yml000066400000000000000000000006171324732107100325640ustar00rootroot00000000000000imports: - { resource: ./../config/default.yml } services: # alias the service so we can access it in the tests functional_test.security.helper: alias: security.helper public: true security: providers: in_memory: memory: users: [] firewalls: default: logout_on_user_change: true anonymous: ~ symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/000077500000000000000000000000001324732107100311765ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/bundles.php000066400000000000000000000011211324732107100333360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\FormLoginBundle; use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return array( new FrameworkBundle(), new SecurityBundle(), new TwigBundle(), new FormLoginBundle(), ); symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/config.yml000066400000000000000000000033551324732107100331740ustar00rootroot00000000000000imports: - { resource: ./../config/default.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: johannes: { password: test, roles: [ROLE_USER] } firewalls: # This firewall doesn't make sense in combination with the rest of the # configuration file, but it's here for testing purposes (do not use # this file in a real world scenario though) login_form: pattern: ^/login$ security: false default: logout_on_user_change: true form_login: check_path: /login_check default_target_path: /profile logout: ~ anonymous: ~ # This firewall is here just to check its the logout functionality second_area: logout_on_user_change: true http_basic: ~ anonymous: ~ logout: target: /second/target path: /second/logout access_control: - { path: ^/unprotected_resource$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/secure-but-not-covered-by-access-control$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/secured-by-one-ip$, ip: 10.10.10.10, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/secured-by-two-ips$, ips: [1.1.1.1, 2.2.2.2], roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/highly_protected_resource$, roles: IS_ADMIN } - { path: ^/protected-via-expression$, allow_if: "(is_anonymous() and request.headers.get('user-agent') matches '/Firefox/i') or has_role('ROLE_USER')" } - { path: .*, roles: IS_AUTHENTICATED_FULLY } localized_form_failure_handler.yml000066400000000000000000000010721324732107100400370ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLoginimports: - { resource: ./../config/default.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: johannes: { password: test, roles: [ROLE_USER] } firewalls: default: logout_on_user_change: true form_login: login_path: localized_login_path check_path: localized_check_path failure_handler: localized_form_failure_handler anonymous: ~ localized_routes.yml000066400000000000000000000014101324732107100352050ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLoginimports: - { resource: ./../config/default.yml } security: encoders: Symfony\Component\Security\Core\User\User: plaintext providers: in_memory: memory: users: johannes: { password: test, roles: [ROLE_USER] } firewalls: default: logout_on_user_change: true form_login: login_path: localized_login_path check_path: localized_check_path default_target_path: localized_default_target_path logout: path: localized_logout_path target: localized_logout_target_path anonymous: ~ access_control: - { path: '^/(?:[a-z]{2})/secure/.*', roles: ROLE_USER } localized_routes_with_forward.yml000066400000000000000000000002771324732107100377760ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLoginimports: - { resource: ./localized_routes.yml } security: firewalls: default: form_login: use_forward: true failure_forward: true routes_as_path.yml000066400000000000000000000005471324732107100346700ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLoginimports: - { resource: ./config.yml } security: firewalls: default: form_login: login_path: form_login check_path: form_login_check default_target_path: form_login_default_target_path logout: path: form_logout target: form_login_homepage symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/routing.yml000066400000000000000000000002621324732107100334100ustar00rootroot00000000000000_form_login_bundle: resource: '@FormLoginBundle/Resources/config/routing.yml' _form_login_localized: resource: '@FormLoginBundle/Resources/config/localized_routing.yml' switchuser.yml000066400000000000000000000007131324732107100340430ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLoginimports: - { resource: ./config.yml } security: providers: in_memory: memory: users: user_can_switch: { password: test, roles: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH] } user_cannot_switch_1: { password: test, roles: [ROLE_USER] } user_cannot_switch_2: { password: test, roles: [ROLE_USER] } firewalls: default: switch_user: true symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/000077500000000000000000000000001324732107100270665ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/default.yml000066400000000000000000000001101324732107100312250ustar00rootroot00000000000000imports: - { resource: framework.yml } - { resource: twig.yml } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml000066400000000000000000000006301324732107100316050ustar00rootroot00000000000000framework: secret: test router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } assets: ~ csrf_protection: true form: true test: ~ default_locale: en session: storage_id: session.storage.mock_file profiler: { only_exceptions: false } services: logger: { class: Psr\Log\NullLogger } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml000066400000000000000000000001511324732107100305600ustar00rootroot00000000000000# Twig Configuration twig: debug: '%kernel.debug%' strict_variables: '%kernel.debug%' symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Security/000077500000000000000000000000001324732107100245465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php000066400000000000000000000050541324732107100310160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Security; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; class FirewallConfigTest extends TestCase { public function testGetters() { $listeners = array('logout', 'remember_me', 'anonymous'); $options = array( 'request_matcher' => 'foo_request_matcher', 'security' => false, 'stateless' => false, 'provider' => 'foo_provider', 'context' => 'foo_context', 'entry_point' => 'foo_entry_point', 'access_denied_url' => 'foo_access_denied_url', 'access_denied_handler' => 'foo_access_denied_handler', 'user_checker' => 'foo_user_checker', 'switch_user' => array('provider' => null, 'parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH'), ); $config = new FirewallConfig( 'foo_firewall', $options['user_checker'], $options['request_matcher'], $options['security'], $options['stateless'], $options['provider'], $options['context'], $options['entry_point'], $options['access_denied_handler'], $options['access_denied_url'], $listeners, $options['switch_user'] ); $this->assertSame('foo_firewall', $config->getName()); $this->assertSame($options['request_matcher'], $config->getRequestMatcher()); $this->assertSame($options['security'], $config->isSecurityEnabled()); $this->assertSame($options['stateless'], $config->isStateless()); $this->assertSame($options['provider'], $config->getProvider()); $this->assertSame($options['context'], $config->getContext()); $this->assertSame($options['entry_point'], $config->getEntryPoint()); $this->assertSame($options['access_denied_handler'], $config->getAccessDeniedHandler()); $this->assertSame($options['access_denied_url'], $config->getAccessDeniedUrl()); $this->assertSame($options['user_checker'], $config->getUserChecker()); $this->assertTrue($config->allowsAnonymous()); $this->assertSame($listeners, $config->getListeners()); $this->assertSame($options['switch_user'], $config->getSwitchUser()); } } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php000066400000000000000000000041451324732107100312350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Security; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; use Symfony\Bundle\SecurityBundle\Security\FirewallContext; use Symfony\Component\Security\Http\Firewall\ExceptionListener; use Symfony\Component\Security\Http\Firewall\ListenerInterface; class FirewallContextTest extends TestCase { public function testGetters() { $config = new FirewallConfig('main', 'user_checker', 'request_matcher'); $exceptionListener = $this->getExceptionListenerMock(); $listeners = array( $this ->getMockBuilder(ListenerInterface::class) ->disableOriginalConstructor() ->getMock(), ); $context = new FirewallContext($listeners, $exceptionListener, $config); $this->assertEquals($listeners, $context->getListeners()); $this->assertEquals($exceptionListener, $context->getExceptionListener()); $this->assertEquals($config, $context->getConfig()); } /** * @expectedDeprecation Method Symfony\Bundle\SecurityBundle\Security\FirewallContext::getContext() is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Bundle\SecurityBundle\Security\FirewallContext::getListeners/getExceptionListener() instead. * @group legacy */ public function testGetContext() { $context = (new FirewallContext($listeners = array(), $exceptionListener = $this->getExceptionListenerMock(), new FirewallConfig('main', 'request_matcher', 'user_checker'))) ->getContext(); $this->assertEquals(array($listeners, $exceptionListener), $context); } private function getExceptionListenerMock() { return $this ->getMockBuilder(ExceptionListener::class) ->disableOriginalConstructor() ->getMock(); } } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php000066400000000000000000000073721324732107100303330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests\Security; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; use Symfony\Bundle\SecurityBundle\Security\FirewallContext; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestMatcherInterface; use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Http\Firewall\ExceptionListener; use Symfony\Component\Security\Http\Firewall\ListenerInterface; class FirewallMapTest extends TestCase { const ATTRIBUTE_FIREWALL_CONTEXT = '_firewall_context'; public function testGetListenersWithEmptyMap() { $request = new Request(); $map = array(); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->never())->method('get'); $firewallMap = new FirewallMap($container, $map); $this->assertEquals(array(array(), null), $firewallMap->getListeners($request)); $this->assertNull($firewallMap->getFirewallConfig($request)); $this->assertFalse($request->attributes->has(self::ATTRIBUTE_FIREWALL_CONTEXT)); } public function testGetListenersWithInvalidParameter() { $request = new Request(); $request->attributes->set(self::ATTRIBUTE_FIREWALL_CONTEXT, 'foo'); $map = array(); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->never())->method('get'); $firewallMap = new FirewallMap($container, $map); $this->assertEquals(array(array(), null), $firewallMap->getListeners($request)); $this->assertNull($firewallMap->getFirewallConfig($request)); $this->assertFalse($request->attributes->has(self::ATTRIBUTE_FIREWALL_CONTEXT)); } public function testGetListeners() { $request = new Request(); $firewallContext = $this->getMockBuilder(FirewallContext::class)->disableOriginalConstructor()->getMock(); $firewallConfig = new FirewallConfig('main', $this->getMockBuilder(UserCheckerInterface::class)->getMock()); $firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig); $listener = $this->getMockBuilder(ListenerInterface::class)->getMock(); $firewallContext->expects($this->once())->method('getListeners')->willReturn(array($listener)); $exceptionListener = $this->getMockBuilder(ExceptionListener::class)->disableOriginalConstructor()->getMock(); $firewallContext->expects($this->once())->method('getExceptionListener')->willReturn($exceptionListener); $matcher = $this->getMockBuilder(RequestMatcherInterface::class)->getMock(); $matcher->expects($this->once()) ->method('matches') ->with($request) ->willReturn(true); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->exactly(2))->method('get')->willReturn($firewallContext); $firewallMap = new FirewallMap($container, array('security.firewall.map.context.foo' => $matcher)); $this->assertEquals(array(array($listener), $exceptionListener), $firewallMap->getListeners($request)); $this->assertEquals($firewallConfig, $firewallMap->getFirewallConfig($request)); $this->assertEquals('security.firewall.map.context.foo', $request->attributes->get(self::ATTRIBUTE_FIREWALL_CONTEXT)); } } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php000066400000000000000000000076311324732107100315040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\Tests; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\SecurityUserValueResolver; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; class SecurityUserValueResolverTest extends TestCase { public function testResolveNoToken() { $tokenStorage = new TokenStorage(); $resolver = new SecurityUserValueResolver($tokenStorage); $metadata = new ArgumentMetadata('foo', UserInterface::class, false, false, null); $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); } public function testResolveNoUser() { $mock = $this->getMockBuilder(UserInterface::class)->getMock(); $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); $resolver = new SecurityUserValueResolver($tokenStorage); $metadata = new ArgumentMetadata('foo', get_class($mock), false, false, null); $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); } public function testResolveWrongType() { $tokenStorage = new TokenStorage(); $resolver = new SecurityUserValueResolver($tokenStorage); $metadata = new ArgumentMetadata('foo', null, false, false, null); $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); } public function testResolve() { $user = $this->getMockBuilder(UserInterface::class)->getMock(); $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $token->expects($this->any())->method('getUser')->willReturn($user); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); $resolver = new SecurityUserValueResolver($tokenStorage); $metadata = new ArgumentMetadata('foo', UserInterface::class, false, false, null); $this->assertTrue($resolver->supports(Request::create('/'), $metadata)); $this->assertSame(array($user), iterator_to_array($resolver->resolve(Request::create('/'), $metadata))); } public function testIntegration() { $user = $this->getMockBuilder(UserInterface::class)->getMock(); $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $token->expects($this->any())->method('getUser')->willReturn($user); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); $argumentResolver = new ArgumentResolver(null, array(new SecurityUserValueResolver($tokenStorage))); $this->assertSame(array($user), $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user) {})); } public function testIntegrationNoUser() { $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); $argumentResolver = new ArgumentResolver(null, array(new SecurityUserValueResolver($tokenStorage), new DefaultValueResolver())); $this->assertSame(array(null), $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user = null) {})); } } abstract class DummyUser implements UserInterface { } abstract class DummySubUser extends DummyUser { } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/composer.json000066400000000000000000000042231324732107100243600ustar00rootroot00000000000000{ "name": "symfony/security-bundle", "type": "symfony-bundle", "description": "Symfony SecurityBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "ext-xml": "*", "symfony/security": "~3.4|~4.0", "symfony/dependency-injection": "^3.4.3|^4.0.3", "symfony/http-kernel": "~3.4|~4.0", "symfony/polyfill-php70": "~1.0" }, "require-dev": { "symfony/asset": "~2.8|~3.0|~4.0", "symfony/browser-kit": "~2.8|~3.0|~4.0", "symfony/console": "~3.4|~4.0", "symfony/css-selector": "~2.8|~3.0|~4.0", "symfony/dom-crawler": "~2.8|~3.0|~4.0", "symfony/event-dispatcher": "~3.4|~4.0", "symfony/form": "^3.4|~4.0", "symfony/framework-bundle": "~3.4|~4.0", "symfony/http-foundation": "~3.3|~4.0", "symfony/security-acl": "~2.8|~3.0", "symfony/translation": "~3.4|~4.0", "symfony/twig-bundle": "~3.4|~4.0", "symfony/twig-bridge": "~3.4|~4.0", "symfony/process": "~3.3|~4.0", "symfony/validator": "^3.4|~4.0", "symfony/var-dumper": "~3.3|~4.0", "symfony/yaml": "~3.4|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "doctrine/doctrine-bundle": "~1.5", "twig/twig": "~1.34|~2.4" }, "conflict": { "symfony/var-dumper": "<3.3", "symfony/event-dispatcher": "<3.4", "symfony/framework-bundle": "<3.4", "symfony/console": "<3.4" }, "suggest": { "symfony/security-acl": "For using the ACL functionality of this bundle" }, "autoload": { "psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist000066400000000000000000000015621324732107100250140ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Bundle/TwigBundle/000077500000000000000000000000001324732107100207405ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/.gitignore000066400000000000000000000000421324732107100227240ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Bundle/TwigBundle/CHANGELOG.md000066400000000000000000000034131324732107100225520ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added exclusive Twig namespace only for root bundles * deprecated `Symfony\Bundle\TwigBundle\Command\DebugCommand`, use `Symfony\Bridge\Twig\Command\DebugCommand` instead * deprecated relying on the `ContainerAwareInterface` implementation for `Symfony\Bundle\TwigBundle\Command\LintCommand` * added option to configure default path templates (via `default_path`) 3.3.0 ----- * Deprecated `ContainerAwareRuntimeLoader` 2.7.0 ----- * made it possible to configure the default formats for both the `date` and the `number_format` filter * added support for the new Asset component (from Twig bridge) * deprecated the assets extension (use the one from the Twig bridge instead) 2.6.0 ----- * [BC BREAK] changed exception.json.twig to match same structure as error.json.twig making clients independent of runtime environment. 2.3.0 ----- * added option to configure a custom template escaping guesser (via `autoescape_service` and `autoescape_service_method`) 2.2.0 ----- * moved the exception controller to be a service (`twig.controller.exception:showAction` vs `Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController::showAction`) * added support for multiple loaders via the "twig.loader" tag. * added automatic registration of namespaced paths for registered bundles * added support for namespaced paths 2.1.0 ----- * added a new setting ("paths") to configure more paths for the Twig filesystem loader * added contextual escaping based on the template file name (disabled if you explicitly pass an autoescape option) * added a command that extracts translation messages from templates * added the real template name when an error occurs in a Twig template * added the twig:lint command that will validate a Twig template syntax. symfony-3.4.6/src/Symfony/Bundle/TwigBundle/CacheWarmer/000077500000000000000000000000001324732107100231215ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php000066400000000000000000000071651324732107100304440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\CacheWarmer; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; use Symfony\Component\Templating\TemplateReference; use Twig\Environment; use Twig\Error\Error; /** * Generates the Twig cache for all templates. * * This warmer must be registered after TemplatePathsCacheWarmer, * as the Twig loader will need the cache generated by it. * * @author Fabien Potencier */ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { protected $container; protected $finder; private $paths; /** * @param array $paths Additional twig paths to warm */ public function __construct(ContainerInterface $container, TemplateFinderInterface $finder = null, array $paths = array()) { // We don't inject the Twig environment directly as it depends on the // template locator (via the loader) which might be a cached one. // The cached template locator is available once the TemplatePathsCacheWarmer // has been warmed up. // But it can also be null if templating has been disabled. $this->container = $container; $this->finder = $finder; $this->paths = $paths; } /** * Warms up the cache. * * @param string $cacheDir The cache directory */ public function warmUp($cacheDir) { if (null === $this->finder) { return; } $twig = $this->container->get('twig'); $templates = $this->finder->findAllTemplates(); foreach ($this->paths as $path => $namespace) { $templates = array_merge($templates, $this->findTemplatesInFolder($namespace, $path)); } foreach ($templates as $template) { if ('twig' !== $template->get('engine')) { continue; } try { $twig->loadTemplate($template); } catch (Error $e) { // problem during compilation, give up } } } /** * Checks whether this warmer is optional or not. * * @return bool always true */ public function isOptional() { return true; } /** * {@inheritdoc} */ public static function getSubscribedServices() { return array( 'twig' => Environment::class, ); } /** * Find templates in the given directory. * * @param string $namespace The namespace for these templates * @param string $dir The folder where to look for templates * * @return array An array of templates of type TemplateReferenceInterface */ private function findTemplatesInFolder($namespace, $dir) { if (!is_dir($dir)) { return array(); } $templates = array(); $finder = new Finder(); foreach ($finder->files()->followLinks()->in($dir) as $file) { $name = $file->getRelativePathname(); $templates[] = new TemplateReference( $namespace ? sprintf('@%s/%s', $namespace, $name) : $name, 'twig' ); } return $templates; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php000066400000000000000000000047661324732107100275240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\CacheWarmer; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Twig\Environment; use Twig\Error\Error; /** * Generates the Twig cache for all templates. * * @author Fabien Potencier */ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { private $container; private $twig; private $iterator; /** * TemplateCacheWarmer constructor. * * @param ContainerInterface $container * @param \Traversable $iterator */ public function __construct($container, \Traversable $iterator) { // As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected. if ($container instanceof ContainerInterface) { $this->container = $container; } elseif ($container instanceof Environment) { $this->twig = $container; @trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since Symfony 3.4 and will be unsupported in version 4.0. Use a %s instead.', Environment::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED); } else { throw new \InvalidArgumentException(sprintf('%s only accepts instance of Psr\Container\ContainerInterface as first argument.', __CLASS__)); } $this->iterator = $iterator; } /** * {@inheritdoc} */ public function warmUp($cacheDir) { if (null === $this->twig) { $this->twig = $this->container->get('twig'); } foreach ($this->iterator as $template) { try { $this->twig->loadTemplate($template); } catch (Error $e) { // problem during compilation, give up // might be a syntax error or a non-Twig template } } } /** * {@inheritdoc} */ public function isOptional() { return true; } /** * {@inheritdoc} */ public static function getSubscribedServices() { return array( 'twig' => Environment::class, ); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Command/000077500000000000000000000000001324732107100223165ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php000066400000000000000000000021601324732107100253530ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Command; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bridge\Twig\Command\DebugCommand instead.', DebugCommand::class), E_USER_DEPRECATED); use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Lists twig functions, filters, globals and tests present in the current project. * * @author Jordi Boggiano * * @deprecated since version 3.4, to be removed in 4.0. */ final class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface { use ContainerAwareTrait; /** * {@inheritdoc} */ protected function getTwigEnvironment() { return $this->container->get('twig'); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php000066400000000000000000000027301324732107100252360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Command; use Symfony\Bridge\Twig\Command\LintCommand as BaseLintCommand; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Finder\Finder; /** * Command that will validate your template syntax and output encountered errors. * * @author Marc Weistroff * @author Jérôme Tamarelle */ final class LintCommand extends BaseLintCommand implements ContainerAwareInterface { // BC to be removed in 4.0 use ContainerAwareTrait; /** * {@inheritdoc} */ protected function configure() { parent::configure(); $this ->setHelp( $this->getHelp().<<<'EOF' Or all template files in a bundle: php %command.full_name% @AcmeDemoBundle EOF ) ; } protected function findFiles($filename) { if (0 === strpos($filename, '@')) { $dir = $this->getApplication()->getKernel()->locateResource($filename); return Finder::create()->files()->in($dir)->name('*.twig'); } return parent::findFiles($filename); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php000066400000000000000000000031761324732107100270550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Twig\RuntimeLoader\ContainerRuntimeLoader class instead.', ContainerAwareRuntimeLoader::class), E_USER_DEPRECATED); use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Twig\RuntimeLoader\RuntimeLoaderInterface; /** * Loads Twig extension runtimes via the service container. * * @author Fabien Potencier * * @deprecated since version 3.3, will be removed in 4.0. Use \Twig\Loader\ContainerRuntimeLoader instead. */ class ContainerAwareRuntimeLoader implements RuntimeLoaderInterface { private $container; private $mapping; private $logger; public function __construct(ContainerInterface $container, array $mapping, LoggerInterface $logger = null) { $this->container = $container; $this->mapping = $mapping; $this->logger = $logger; } /** * {@inheritdoc} */ public function load($class) { if (isset($this->mapping[$class])) { return $this->container->get($this->mapping[$class]); } if (null !== $this->logger) { $this->logger->warning(sprintf('Class "%s" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.', $class)); } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Controller/000077500000000000000000000000001324732107100230635ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php000066400000000000000000000110211324732107100275710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Controller; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; use Twig\Error\LoaderError; use Twig\Loader\ExistsLoaderInterface; /** * ExceptionController renders error or exception pages for a given * FlattenException. * * @author Fabien Potencier * @author Matthias Pigulla */ class ExceptionController { protected $twig; protected $debug; /** * @param Environment $twig * @param bool $debug Show error (false) or exception (true) pages by default */ public function __construct(Environment $twig, $debug) { $this->twig = $twig; $this->debug = $debug; } /** * Converts an Exception to a Response. * * A "showException" request parameter can be used to force display of an error page (when set to false) or * the exception page (when true). If it is not present, the "debug" value passed into the constructor will * be used. * * @return Response * * @throws \InvalidArgumentException When the exception template does not exist */ public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null) { $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $showException = $request->attributes->get('showException', $this->debug); // As opposed to an additional parameter, this maintains BC $code = $exception->getStatusCode(); return new Response($this->twig->render( (string) $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, ) ), 200, array('Content-Type' => $request->getMimeType($request->getRequestFormat()) ?: 'text/html')); } /** * @param int $startObLevel * * @return string */ protected function getAndCleanOutputBuffering($startObLevel) { if (ob_get_level() <= $startObLevel) { return ''; } Response::closeOutputBuffers($startObLevel + 1, true); return ob_get_clean(); } /** * @param Request $request * @param string $format * @param int $code An HTTP response status code * @param bool $showException * * @return string */ protected function findTemplate(Request $request, $format, $code, $showException) { $name = $showException ? 'exception' : 'error'; if ($showException && 'html' == $format) { $name = 'exception_full'; } // For error pages, try to find a template for the specific HTTP status code and format if (!$showException) { $template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $code, $format); if ($this->templateExists($template)) { return $template; } } // try to find a template for the given format $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format); if ($this->templateExists($template)) { return $template; } // default to a generic HTML exception $request->setRequestFormat('html'); return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); } // to be removed when the minimum required version of Twig is >= 3.0 protected function templateExists($template) { $template = (string) $template; $loader = $this->twig->getLoader(); if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) { return $loader->exists($template); } try { $loader->getSourceContext($template)->getCode(); return true; } catch (LoaderError $e) { } return false; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php000066400000000000000000000032021324732107100302700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Controller; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; /** * PreviewErrorController can be used to test error pages. * * It will create a test exception and forward it to another controller. * * @author Matthias Pigulla */ class PreviewErrorController { protected $kernel; protected $controller; public function __construct(HttpKernelInterface $kernel, $controller) { $this->kernel = $kernel; $this->controller = $controller; } public function previewErrorPageAction(Request $request, $code) { $exception = FlattenException::create(new \Exception('Something has intentionally gone wrong.'), $code); /* * This Request mimics the parameters set by * \Symfony\Component\HttpKernel\EventListener\ExceptionListener::duplicateRequest, with * the additional "showException" flag. */ $subRequest = $request->duplicate(null, null, array( '_controller' => $this->controller, 'exception' => $exception, 'logger' => null, 'format' => $request->getRequestFormat(), 'showException' => false, )); return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/000077500000000000000000000000001324732107100246615ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/000077500000000000000000000000001324732107100264335ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php000066400000000000000000000026311324732107100334410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Registers the Twig exception listener if Twig is registered as a templating engine. * * @author Fabien Potencier */ class ExceptionListenerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (false === $container->hasDefinition('twig')) { return; } // register the exception controller only if Twig is enabled and required dependencies do exist if (!class_exists('Symfony\Component\Debug\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) { $container->removeDefinition('twig.exception_listener'); } elseif ($container->hasParameter('templating.engines')) { $engines = $container->getParameter('templating.engines'); if (!in_array('twig', $engines)) { $container->removeDefinition('twig.exception_listener'); } } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php000066400000000000000000000117561324732107100317610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Workflow\Workflow; /** * @author Jean-François Simon */ class ExtensionPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!class_exists('Symfony\Component\Asset\Packages')) { $container->removeDefinition('twig.extension.assets'); } if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) { $container->removeDefinition('twig.extension.expression'); } if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) { $container->removeDefinition('twig.extension.routing'); } if (!class_exists('Symfony\Component\Yaml\Yaml')) { $container->removeDefinition('twig.extension.yaml'); } if ($container->has('form.extension')) { $container->getDefinition('twig.extension.form')->addTag('twig.extension'); $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); $coreThemePath = dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'; $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath)); $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2); $paths[$coreThemePath] = null; $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths); $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths); } if ($container->has('router')) { $container->getDefinition('twig.extension.routing')->addTag('twig.extension'); } if ($container->has('fragment.handler')) { $container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension'); // inject Twig in the hinclude service if Twig is the only registered templating engine if ((!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) { $container->getDefinition('fragment.renderer.hinclude') ->addTag('kernel.fragment_renderer', array('alias' => 'hinclude')) ->replaceArgument(0, new Reference('twig')) ; } } if ($container->has('request_stack')) { $container->getDefinition('twig.extension.httpfoundation')->addTag('twig.extension'); } if ($container->getParameter('kernel.debug')) { $container->getDefinition('twig.extension.profiler')->addTag('twig.extension'); // only register if the improved version from DebugBundle is *not* present if (!$container->has('twig.extension.dump')) { $container->getDefinition('twig.extension.debug')->addTag('twig.extension'); } } $twigLoader = $container->getDefinition('twig.loader.native_filesystem'); if ($container->has('templating')) { $loader = $container->getDefinition('twig.loader.filesystem'); $loader->setMethodCalls(array_merge($twigLoader->getMethodCalls(), $loader->getMethodCalls())); $twigLoader->clearTag('twig.loader'); } else { $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); $container->removeDefinition('templating.engine.twig'); } if ($container->has('assets.packages')) { $container->getDefinition('twig.extension.assets')->addTag('twig.extension'); } if ($container->hasDefinition('twig.extension.yaml')) { $container->getDefinition('twig.extension.yaml')->addTag('twig.extension'); } if (class_exists('Symfony\Component\Stopwatch\Stopwatch')) { $container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension'); } if ($container->hasDefinition('twig.extension.expression')) { $container->getDefinition('twig.extension.expression')->addTag('twig.extension'); } if (!class_exists(Workflow::class) || !$container->has('workflow.registry')) { $container->removeDefinition('workflow.twig_extension'); } else { $container->getDefinition('workflow.twig_extension')->addTag('twig.extension'); } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php000066400000000000000000000023451324732107100325510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\Reference; /** * Registers Twig runtime services. */ class RuntimeLoaderPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->hasDefinition('twig.runtime_loader')) { return; } $definition = $container->getDefinition('twig.runtime_loader'); $mapping = array(); foreach ($container->findTaggedServiceIds('twig.runtime', true) as $id => $attributes) { $def = $container->getDefinition($id); $mapping[$def->getClass()] = new Reference($id); } $definition->replaceArgument(0, ServiceLocatorTagPass::register($container, $mapping)); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigEnvironmentPass.php000066400000000000000000000040321324732107100331310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Adds tagged twig.extension services to twig service. * * @author Fabien Potencier */ class TwigEnvironmentPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (false === $container->hasDefinition('twig')) { return; } $definition = $container->getDefinition('twig'); // Extensions must always be registered before everything else. // For instance, global variable definitions must be registered // afterward. If not, the globals from the extensions will never // be registered. $currentMethodCalls = $definition->getMethodCalls(); $twigBridgeExtensionsMethodCalls = array(); $othersExtensionsMethodCalls = array(); foreach ($container->findTaggedServiceIds('twig.extension', true) as $id => $attributes) { $methodCall = array('addExtension', array(new Reference($id))); $extensionClass = $container->getDefinition($id)->getClass(); if (is_string($extensionClass) && 0 === strpos($extensionClass, 'Symfony\Bridge\Twig\Extension')) { $twigBridgeExtensionsMethodCalls[] = $methodCall; } else { $othersExtensionsMethodCalls[] = $methodCall; } } if (!empty($twigBridgeExtensionsMethodCalls) || !empty($othersExtensionsMethodCalls)) { $definition->setMethodCalls(array_merge($twigBridgeExtensionsMethodCalls, $othersExtensionsMethodCalls, $currentMethodCalls)); } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php000066400000000000000000000036211324732107100320360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\LogicException; /** * Adds services tagged twig.loader as Twig loaders. * * @author Daniel Leech */ class TwigLoaderPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (false === $container->hasDefinition('twig')) { return; } $prioritizedLoaders = array(); $found = 0; foreach ($container->findTaggedServiceIds('twig.loader', true) as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $prioritizedLoaders[$priority][] = $id; ++$found; } if (!$found) { throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader"'); } if (1 === $found) { $container->setAlias('twig.loader', $id)->setPrivate(true); } else { $chainLoader = $container->getDefinition('twig.loader.chain'); krsort($prioritizedLoaders); foreach ($prioritizedLoaders as $loaders) { foreach ($loaders as $loader) { $chainLoader->addMethodCall('addLoader', array(new Reference($loader))); } } $container->setAlias('twig.loader', 'twig.loader.chain')->setPrivate(true); } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php000066400000000000000000000173511324732107100302100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; /** * TwigExtension configuration structure. * * @author Jeremy Mikola */ class Configuration implements ConfigurationInterface { /** * Generates the configuration tree builder. * * @return TreeBuilder The tree builder */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('twig'); $rootNode ->children() ->scalarNode('exception_controller')->defaultValue('twig.controller.exception:showAction')->end() ->end() ; $this->addFormThemesSection($rootNode); $this->addGlobalsSection($rootNode); $this->addTwigOptions($rootNode); $this->addTwigFormatOptions($rootNode); return $treeBuilder; } private function addFormThemesSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('form_theme') ->children() ->arrayNode('form_themes') ->addDefaultChildrenIfNoneSet() ->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end() ->example(array('MyBundle::form.html.twig')) ->validate() ->ifTrue(function ($v) { return !in_array('form_div_layout.html.twig', $v); }) ->then(function ($v) { return array_merge(array('form_div_layout.html.twig'), $v); }) ->end() ->end() ->end() ; } private function addGlobalsSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('global') ->children() ->arrayNode('globals') ->normalizeKeys(false) ->useAttributeAsKey('key') ->example(array('foo' => '"@bar"', 'pi' => 3.14)) ->prototype('array') ->beforeNormalization() ->ifTrue(function ($v) { return is_string($v) && 0 === strpos($v, '@'); }) ->then(function ($v) { if (0 === strpos($v, '@@')) { return substr($v, 1); } return array('id' => substr($v, 1), 'type' => 'service'); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { if (is_array($v)) { $keys = array_keys($v); sort($keys); return $keys !== array('id', 'type') && $keys !== array('value'); } return true; }) ->then(function ($v) { return array('value' => $v); }) ->end() ->children() ->scalarNode('id')->end() ->scalarNode('type') ->validate() ->ifNotInArray(array('service')) ->thenInvalid('The %s type is not supported') ->end() ->end() ->variableNode('value')->end() ->end() ->end() ->end() ->end() ; } private function addTwigOptions(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('path') ->children() ->variableNode('autoescape')->defaultValue('name')->end() ->scalarNode('autoescape_service')->defaultNull()->end() ->scalarNode('autoescape_service_method')->defaultNull()->end() ->scalarNode('base_template_class')->example('Twig\Template')->cannotBeEmpty()->end() ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end() ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() ->booleanNode('strict_variables')->end() ->scalarNode('auto_reload')->end() ->integerNode('optimizations')->min(-1)->end() ->scalarNode('default_path') ->info('The default path used to load templates') ->defaultValue('%kernel.project_dir%/templates') ->end() ->arrayNode('paths') ->normalizeKeys(false) ->useAttributeAsKey('paths') ->beforeNormalization() ->always() ->then(function ($paths) { $normalized = array(); foreach ($paths as $path => $namespace) { if (is_array($namespace)) { // xml $path = $namespace['value']; $namespace = $namespace['namespace']; } // path within the default namespace if (ctype_digit((string) $path)) { $path = $namespace; $namespace = null; } $normalized[$path] = $namespace; } return $normalized; }) ->end() ->prototype('variable')->end() ->end() ->end() ; } private function addTwigFormatOptions(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('date') ->info('The default format options used by the date filter') ->addDefaultsIfNotSet() ->children() ->scalarNode('format')->defaultValue('F j, Y H:i')->end() ->scalarNode('interval_format')->defaultValue('%d days')->end() ->scalarNode('timezone') ->info('The timezone used when formatting dates, when set to null, the timezone returned by date_default_timezone_get() is used') ->defaultNull() ->end() ->end() ->end() ->arrayNode('number_format') ->info('The default format options for the number_format filter') ->addDefaultsIfNotSet() ->children() ->integerNode('decimals')->defaultValue(0)->end() ->scalarNode('decimal_point')->defaultValue('.')->end() ->scalarNode('thousands_separator')->defaultValue(',')->end() ->end() ->end() ->end() ; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/000077500000000000000000000000001324732107100273235ustar00rootroot00000000000000EnvironmentConfigurator.php000066400000000000000000000037151324732107100346520ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Configurator; use Symfony\Bridge\Twig\UndefinedCallableHandler; use Twig\Environment; // BC/FC with namespaced Twig class_exists('Twig\Environment'); /** * Twig environment configurator. * * @author Christian Flothmann */ class EnvironmentConfigurator { private $dateFormat; private $intervalFormat; private $timezone; private $decimals; private $decimalPoint; private $thousandsSeparator; public function __construct($dateFormat, $intervalFormat, $timezone, $decimals, $decimalPoint, $thousandsSeparator) { $this->dateFormat = $dateFormat; $this->intervalFormat = $intervalFormat; $this->timezone = $timezone; $this->decimals = $decimals; $this->decimalPoint = $decimalPoint; $this->thousandsSeparator = $thousandsSeparator; } public function configure(Environment $environment) { $environment->getExtension('Twig\Extension\CoreExtension')->setDateFormat($this->dateFormat, $this->intervalFormat); if (null !== $this->timezone) { $environment->getExtension('Twig\Extension\CoreExtension')->setTimezone($this->timezone); } $environment->getExtension('Twig\Extension\CoreExtension')->setNumberFormat($this->decimals, $this->decimalPoint, $this->thousandsSeparator); // wrap UndefinedCallableHandler in closures for lazy-autoloading $environment->registerUndefinedFilterCallback(function ($name) { return UndefinedCallableHandler::onUndefinedFilter($name); }); $environment->registerUndefinedFunctionCallback(function ($name) { return UndefinedCallableHandler::onUndefinedFunction($name); }); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php000066400000000000000000000261731324732107100302120ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\DependencyInjection; use Symfony\Bridge\Twig\Extension\WebLinkExtension; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Resource\FileExistenceResource; use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\WebLink\HttpHeaderSerializer; use Twig\Extension\ExtensionInterface; use Twig\Extension\RuntimeExtensionInterface; use Twig\Loader\LoaderInterface; /** * TwigExtension. * * @author Fabien Potencier * @author Jeremy Mikola */ class TwigExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('twig.xml'); $container->getDefinition('twig.profile')->setPrivate(true); $container->getDefinition('twig.runtime.httpkernel')->setPrivate(true); $container->getDefinition('twig.translation.extractor')->setPrivate(true); $container->getDefinition('workflow.twig_extension')->setPrivate(true); $container->getDefinition('twig.exception_listener')->setPrivate(true); if (class_exists('Symfony\Component\Form\Form')) { $loader->load('form.xml'); $container->getDefinition('twig.form.renderer')->setPrivate(true); } if (interface_exists('Symfony\Component\Templating\EngineInterface')) { $loader->load('templating.xml'); } if (class_exists(Application::class)) { $loader->load('console.xml'); } if (!interface_exists('Symfony\Component\Translation\TranslatorInterface')) { $container->removeDefinition('twig.translation.extractor'); } if (class_exists(HttpHeaderSerializer::class)) { $definition = $container->register('twig.extension.weblink', WebLinkExtension::class); $definition->setPublic(false); $definition->addArgument(new Reference('request_stack')); $definition->addTag('twig.extension'); } foreach ($configs as $key => $config) { if (isset($config['globals'])) { foreach ($config['globals'] as $name => $value) { if (is_array($value) && isset($value['key'])) { $configs[$key]['globals'][$name] = array( 'key' => $name, 'value' => $value, ); } } } } $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $container->setParameter('twig.exception_listener.controller', $config['exception_controller']); $container->setParameter('twig.form.resources', $config['form_themes']); $container->setParameter('twig.default_path', $config['default_path']); $envConfiguratorDefinition = $container->getDefinition('twig.configurator.environment'); $envConfiguratorDefinition->replaceArgument(0, $config['date']['format']); $envConfiguratorDefinition->replaceArgument(1, $config['date']['interval_format']); $envConfiguratorDefinition->replaceArgument(2, $config['date']['timezone']); $envConfiguratorDefinition->replaceArgument(3, $config['number_format']['decimals']); $envConfiguratorDefinition->replaceArgument(4, $config['number_format']['decimal_point']); $envConfiguratorDefinition->replaceArgument(5, $config['number_format']['thousands_separator']); $twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.native_filesystem'); // register user-configured paths foreach ($config['paths'] as $path => $namespace) { if (!$namespace) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path)); } else { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace)); } } // paths are modified in ExtensionPass if forms are enabled $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $config['paths']); $container->getDefinition('twig.template_iterator')->replaceArgument(2, $config['paths']); $bundleHierarchy = $this->getBundleHierarchy($container, $config); foreach ($bundleHierarchy as $name => $bundle) { $namespace = $this->normalizeBundleName($name); foreach ($bundle['children'] as $child) { foreach ($bundleHierarchy[$child]['paths'] as $path) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace)); } } foreach ($bundle['paths'] as $path) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace)); } // add exclusive namespace for root bundles only // to override a bundle template that also extends itself if (count($bundle['paths']) > 0 && 0 === count($bundle['parents'])) { // the last path must be the bundle views directory $twigFilesystemLoaderDefinition->addMethodCall('addPath', array(end($bundle['paths']), '!'.$namespace)); } } if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir)); } $container->addResource(new FileExistenceResource($dir)); if (file_exists($dir = $container->getParameterBag()->resolveValue($config['default_path']))) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir)); } $container->addResource(new FileExistenceResource($dir)); if (!empty($config['globals'])) { $def = $container->getDefinition('twig'); foreach ($config['globals'] as $key => $global) { if (isset($global['type']) && 'service' === $global['type']) { $def->addMethodCall('addGlobal', array($key, new Reference($global['id']))); } else { $def->addMethodCall('addGlobal', array($key, $global['value'])); } } } unset( $config['form'], $config['globals'], $config['extensions'] ); if (isset($config['autoescape_service']) && isset($config['autoescape_service_method'])) { $config['autoescape'] = array(new Reference($config['autoescape_service']), $config['autoescape_service_method']); } unset($config['autoescape_service'], $config['autoescape_service_method']); $container->getDefinition('twig')->replaceArgument(1, $config); $container->registerForAutoconfiguration(\Twig_ExtensionInterface::class)->addTag('twig.extension'); $container->registerForAutoconfiguration(\Twig_LoaderInterface::class)->addTag('twig.loader'); $container->registerForAutoconfiguration(ExtensionInterface::class)->addTag('twig.extension'); $container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader'); $container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime'); if (\PHP_VERSION_ID < 70000) { $this->addClassesToCompile(array( 'Twig_Environment', 'Twig_Extension', 'Twig_Extension_Core', 'Twig_Extension_Escaper', 'Twig_Extension_Optimizer', 'Twig_LoaderInterface', 'Twig_Markup', 'Twig_Template', )); } } private function getBundleHierarchy(ContainerBuilder $container, array $config) { $bundleHierarchy = array(); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { if (!array_key_exists($name, $bundleHierarchy)) { $bundleHierarchy[$name] = array( 'paths' => array(), 'parents' => array(), 'children' => array(), ); } if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) { $bundleHierarchy[$name]['paths'][] = $dir; } $container->addResource(new FileExistenceResource($dir)); if (file_exists($dir = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name)) { $bundleHierarchy[$name]['paths'][] = $dir; } $container->addResource(new FileExistenceResource($dir)); if (file_exists($dir = $bundle['path'].'/Resources/views')) { $bundleHierarchy[$name]['paths'][] = $dir; } $container->addResource(new FileExistenceResource($dir)); if (!isset($bundle['parent']) || null === $bundle['parent']) { continue; } $bundleHierarchy[$name]['parents'][] = $bundle['parent']; if (!array_key_exists($bundle['parent'], $bundleHierarchy)) { $bundleHierarchy[$bundle['parent']] = array( 'paths' => array(), 'parents' => array(), 'children' => array(), ); } $bundleHierarchy[$bundle['parent']]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$bundle['parent']]['children']); foreach ($bundleHierarchy[$bundle['parent']]['parents'] as $parent) { $bundleHierarchy[$name]['parents'][] = $parent; $bundleHierarchy[$parent]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$parent]['children']); } foreach ($bundleHierarchy[$name]['children'] as $child) { $bundleHierarchy[$child]['parents'] = array_merge($bundleHierarchy[$child]['parents'], $bundleHierarchy[$name]['parents']); } } return $bundleHierarchy; } private function normalizeBundleName($name) { if ('Bundle' === substr($name, -6)) { $name = substr($name, 0, -6); } return $name; } /** * Returns the base path for the XSD files. * * @return string The XSD base path */ public function getXsdValidationBasePath() { return __DIR__.'/../Resources/config/schema'; } public function getNamespace() { return 'http://symfony.com/schema/dic/twig'; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/LICENSE000066400000000000000000000020511324732107100217430ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Loader/000077500000000000000000000000001324732107100221465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php000066400000000000000000000054741324732107100261440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Loader; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; use Twig\Error\LoaderError; use Twig\Loader\FilesystemLoader as BaseFilesystemLoader; /** * FilesystemLoader extends the default Twig filesystem loader * to work with the Symfony paths and template references. * * @author Fabien Potencier */ class FilesystemLoader extends BaseFilesystemLoader { protected $locator; protected $parser; /** * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) */ public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, $rootPath = null) { parent::__construct(array(), $rootPath); $this->locator = $locator; $this->parser = $parser; } /** * {@inheritdoc} * * The name parameter might also be a TemplateReferenceInterface. */ public function exists($name) { return parent::exists((string) $name); } /** * Returns the path to the template file. * * The file locator is used to locate the template when the naming convention * is the symfony one (i.e. the name can be parsed). * Otherwise the template is located using the locator from the twig library. * * @param string|TemplateReferenceInterface $template The template * @param bool $throw When true, a LoaderError exception will be thrown if a template could not be found * * @return string The path to the template file * * @throws LoaderError if the template could not be found */ protected function findTemplate($template, $throw = true) { $logicalName = (string) $template; if (isset($this->cache[$logicalName])) { return $this->cache[$logicalName]; } $file = null; try { $file = parent::findTemplate($logicalName); } catch (LoaderError $e) { $twigLoaderException = $e; // for BC try { $template = $this->parser->parse($template); $file = $this->locator->locate($template); } catch (\Exception $e) { } } if (false === $file || null === $file) { if ($throw) { throw $twigLoaderException; } return false; } return $this->cache[$logicalName] = $file; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/README.md000066400000000000000000000005071324732107100222210ustar00rootroot00000000000000TwigBundle ========== Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/000077500000000000000000000000001324732107100227125ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/000077500000000000000000000000001324732107100241575ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml000066400000000000000000000015211324732107100263420ustar00rootroot00000000000000 %kernel.project_dir% symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml000066400000000000000000000022101324732107100256370ustar00rootroot00000000000000 twig.form.renderer %twig.form.resources% symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/routing/000077500000000000000000000000001324732107100256465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml000066400000000000000000000010301324732107100276760ustar00rootroot00000000000000 twig.controller.preview_error:previewErrorPageAction html \d+ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/schema/000077500000000000000000000000001324732107100254175ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd000066400000000000000000000051461324732107100274130ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml000066400000000000000000000017261324732107100270530ustar00rootroot00000000000000 %kernel.project_dir% symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml000066400000000000000000000174061324732107100256630ustar00rootroot00000000000000 app %kernel.environment% %kernel.debug% %kernel.root_dir% %kernel.project_dir% %kernel.root_dir% %kernel.charset% %kernel.debug% %twig.exception_listener.controller% %kernel.debug% %kernel.debug% %twig.exception_listener.controller% symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/000077500000000000000000000000001324732107100240475ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/000077500000000000000000000000001324732107100260055ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.atom.twig000066400000000000000000000000601324732107100307650ustar00rootroot00000000000000{{ include('@Twig/Exception/error.xml.twig') }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.css.twig000066400000000000000000000000531324732107100306170ustar00rootroot00000000000000/* {{ status_code }} {{ status_text }} */ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.html.twig000066400000000000000000000007761324732107100310070ustar00rootroot00000000000000 An Error Occurred: {{ status_text }}

Oops! An Error Occurred

The server returned a "{{ status_code }} {{ status_text }}".

Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.js.twig000066400000000000000000000000531324732107100304430ustar00rootroot00000000000000/* {{ status_code }} {{ status_text }} */ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.json.twig000066400000000000000000000001231324732107100307760ustar00rootroot00000000000000{{ { 'error': { 'code': status_code, 'message': status_text } }|json_encode|raw }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.rdf.twig000066400000000000000000000000601324732107100306000ustar00rootroot00000000000000{{ include('@Twig/Exception/error.xml.twig') }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.txt.twig000066400000000000000000000004151324732107100306500ustar00rootroot00000000000000Oops! An Error Occurred ======================= The server returned a "{{ status_code }} {{ status_text }}". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused. symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.xml.twig000066400000000000000000000001611324732107100306270ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.atom.twig000066400000000000000000000001161324732107100316340ustar00rootroot00000000000000{{ include('@Twig/Exception/exception.xml.twig', { exception: exception }) }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.css.twig000066400000000000000000000001241324732107100314630ustar00rootroot00000000000000/* {{ include('@Twig/Exception/exception.txt.twig', { exception: exception }) }} */ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig000066400000000000000000000077031324732107100316510ustar00rootroot00000000000000

{{- exception.message|nl2br|format_file_from_text -}}

{{ include('@Twig/images/symfony-ghost.svg') }}
{% set exception_as_array = exception.toarray %} {% set _exceptions_with_user_code = [] %} {% for i, e in exception_as_array %} {% for trace in e.trace %} {% if (trace.file is not empty) and ('/vendor/' not in trace.file) and ('/var/cache/' not in trace.file) and not loop.last %} {% set _exceptions_with_user_code = _exceptions_with_user_code|merge([i]) %} {% endif %} {% endfor %} {% endfor %}

{% if exception_as_array|length > 1 %} Exceptions {{ exception_as_array|length }} {% else %} Exception {% endif %}

{% for i, e in exception_as_array %} {{ include('@Twig/Exception/traces.html.twig', { exception: e, index: loop.index, expand: i in _exceptions_with_user_code or (_exceptions_with_user_code is empty and loop.first) }, with_context = false) }} {% endfor %}
{% if logger %}

Logs {% if logger.counterrors ?? false %}{{ logger.counterrors }}{% endif %}

{% if logger.logs %} {{ include('@Twig/Exception/logs.html.twig', { logs: logger.logs }, with_context = false) }} {% else %}

No log messages

{% endif %}
{% endif %}

{% if exception_as_array|length > 1 %} Stack Traces {{ exception_as_array|length }} {% else %} Stack Trace {% endif %}

{% for e in exception_as_array %} {{ include('@Twig/Exception/traces_text.html.twig', { exception: e, index: loop.index, num_exceptions: loop.length }, with_context = false) }} {% endfor %}
{% if currentContent is not empty %}

Output content

{{ currentContent }}
{% endif %}
symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.js.twig000066400000000000000000000001241324732107100313070ustar00rootroot00000000000000/* {{ include('@Twig/Exception/exception.txt.twig', { exception: exception }) }} */ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.json.twig000066400000000000000000000001631324732107100316470ustar00rootroot00000000000000{{ { 'error': { 'code': status_code, 'message': status_text, 'exception': exception.toarray } }|json_encode|raw }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.rdf.twig000066400000000000000000000001161324732107100314470ustar00rootroot00000000000000{{ include('@Twig/Exception/exception.xml.twig', { exception: exception }) }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.txt.twig000066400000000000000000000004501324732107100315140ustar00rootroot00000000000000[exception] {{ status_code ~ ' | ' ~ status_text ~ ' | ' ~ exception.class }} [message] {{ exception.message }} {% for i, e in exception.toarray %} [{{ i + 1 }}] {{ e.class }}: {{ e.message }} {{ include('@Twig/Exception/traces.txt.twig', { exception: e }, with_context = false) }} {% endfor %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.xml.twig000066400000000000000000000005201324732107100314730ustar00rootroot00000000000000 {% for e in exception.toarray %} {{ include('@Twig/Exception/traces.xml.twig', { exception: e }, with_context = false) }} {% endfor %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig000066400000000000000000000077301324732107100326730ustar00rootroot00000000000000{% extends '@Twig/layout.html.twig' %} {% block head %} {% endblock %} {% block title %} {{ exception.message }} ({{ status_code }} {{ status_text }}) {% endblock %} {% block body %} {% include '@Twig/Exception/exception.html.twig' %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/logs.html.twig000066400000000000000000000024311324732107100306100ustar00rootroot00000000000000{% set channel_is_defined = (logs|first).channel is defined %} {% if channel_is_defined %}{% endif %} {% for log in logs %} {% if log.priority >= 400 %} {% set status = 'error' %} {% elseif log.priority >= 300 %} {% set status = 'warning' %} {% else %} {% set severity = log.context.exception.severity|default(false) %} {% set status = severity is constant('E_DEPRECATED') or severity is constant('E_USER_DEPRECATED') ? 'warning' : 'normal' %} {% endif %} {% if channel_is_defined %} {% endif %} {% endfor %}
LevelChannelMessage
{{ log.priorityName }} {{ log.timestamp|date('H:i:s') }} {{ log.channel }} {{ log.message|format_log_message(log.context) }}
symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig000066400000000000000000000034501324732107100307440ustar00rootroot00000000000000
{% if trace.file|default(false) %} {{ include('@Twig/images/icon-minus-square.svg') }} {{ include('@Twig/images/icon-plus-square.svg') }} {% endif %} {% if trace.function %} {{ trace.class|abbr_class }}{% if trace.type is not empty %}{{ trace.type }}{% endif %}{{ trace.function }}({{ trace.args|format_args }}) {% endif %} {% if trace.file|default(false) %} {% set line_number = trace.line|default(1) %} {% set file_link = trace.file|file_link(line_number) %} {% set file_path = trace.file|format_file(line_number)|striptags|replace({ (' at line ' ~ line_number): '' }) %} {% set file_path_parts = file_path|split(constant('DIRECTORY_SEPARATOR')) %} in {{ file_path_parts[:-1]|join(constant('DIRECTORY_SEPARATOR')) }}{{ constant('DIRECTORY_SEPARATOR') }}{{ file_path_parts|last }} (line {{ line_number }}) {% endif %}
{% if trace.file|default(false) %}
{{ trace.file|file_excerpt(trace.line, 5)|replace({ '#DD0000': '#183691', '#007700': '#a71d5d', '#0000BB': '#222222', '#FF8000': '#969896' })|raw }}
{% endif %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.txt.twig000066400000000000000000000006161324732107100306200ustar00rootroot00000000000000{% if trace.function %} at {{ trace.class ~ trace.type ~ trace.function }}({{ trace.args|format_args }}) {%- endif -%} {% if trace.file|default('') is not empty and trace.line|default('') is not empty %} {{- trace.function ? '\n (' : 'at '}}{{ trace.file|format_file(trace.line)|striptags|replace({ (' at line ' ~ trace.line): '' }) }}:{{ trace.line }}{{ trace.function ? ')' }} {%- endif %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig000066400000000000000000000033111324732107100311230ustar00rootroot00000000000000

{{ exception.class|split('\\')|slice(0, -1)|join('\\') }} {{- exception.class|split('\\')|length > 1 ? '\\' }} {{ exception.class|split('\\')|last }} {{ include('@Twig/images/icon-minus-square-o.svg') }} {{ include('@Twig/images/icon-plus-square-o.svg') }}

{% if exception.message is not empty and index > 1 %}

{{ exception.message }}

{% endif %}
{% set _is_first_user_code = true %} {% for i, trace in exception.trace %} {% set _display_code_snippet = _is_first_user_code and ('/vendor/' not in trace.file) and ('/var/cache/' not in trace.file) and (trace.file is not empty) %} {% if _display_code_snippet %}{% set _is_first_user_code = false %}{% endif %}
{{ include('@Twig/Exception/trace.html.twig', { prefix: index, i: i, trace: trace, _display_code_snippet: _display_code_snippet }, with_context = false) }}
{% endfor %}
symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.txt.twig000066400000000000000000000004771324732107100310100ustar00rootroot00000000000000{% if exception.trace|length %}
{{ exception.class }}:
{% if exception.message is not empty %}
    {{- exception.message }}
{% endif %}

{% for trace in exception.trace %}
  {{ include('@Twig/Exception/trace.txt.twig', { trace: trace }, with_context = false) }}
{% endfor %}
{% endif %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.xml.twig000066400000000000000000000003251324732107100307610ustar00rootroot00000000000000 {% for trace in exception.trace %} {{ include('@Twig/Exception/trace.txt.twig', { trace: trace }, with_context = false) }} {% endfor %} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces_text.html.twig000066400000000000000000000020061324732107100321670ustar00rootroot00000000000000

{% if num_exceptions > 1 %} [{{ num_exceptions - index + 1 }}/{{ num_exceptions }}] {% endif %} {{ exception.class|split('\\')|last }} {{ include('@Twig/images/icon-minus-square-o.svg') }} {{ include('@Twig/images/icon-plus-square-o.svg') }}

{{ include('@Twig/Exception/traces.txt.twig', { exception: exception }, with_context = false) }}
symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig000066400000000000000000000217531324732107100273240ustar00rootroot00000000000000{# This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig. If you make any change in this file, verify the same change is needed in the other file. #} /*' element */ while (activeTab.tagName.toLowerCase() !== 'li') { activeTab = activeTab.parentNode; } /* get the full list of tabs through the parent of the active tab element */ var tabNavigation = activeTab.parentNode.children; for (var k = 0; k < tabNavigation.length; k++) { var tabId = tabNavigation[k].getAttribute('data-tab-id'); document.getElementById(tabId).className = 'hidden'; removeClass(tabNavigation[k], 'active'); } addClass(activeTab, 'active'); var activeTabId = activeTab.getAttribute('data-tab-id'); document.getElementById(activeTabId).className = 'block'; }); } tabGroups[i].setAttribute('data-processed', 'true'); } }, createToggles: function() { var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])'); for (var i = 0; i < toggles.length; i++) { var elementSelector = toggles[i].getAttribute('data-toggle-selector'); var element = document.querySelector(elementSelector); addClass(element, 'sf-toggle-content'); if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') { addClass(toggles[i], 'sf-toggle-on'); addClass(element, 'sf-toggle-visible'); } else { addClass(toggles[i], 'sf-toggle-off'); addClass(element, 'sf-toggle-hidden'); } addEventListener(toggles[i], 'click', function(e) { e.preventDefault(); if ('' !== window.getSelection().toString()) { /* Don't do anything on text selection */ return; } var toggle = e.target || e.srcElement; /* needed because when the toggle contains HTML contents, user can click */ /* on any of those elements instead of their parent '.sf-toggle' element */ while (!hasClass(toggle, 'sf-toggle')) { toggle = toggle.parentNode; } var element = document.querySelector(toggle.getAttribute('data-toggle-selector')); toggleClass(toggle, 'sf-toggle-on'); toggleClass(toggle, 'sf-toggle-off'); toggleClass(element, 'sf-toggle-hidden'); toggleClass(element, 'sf-toggle-visible'); /* the toggle doesn't change its contents when clicking on it */ if (!toggle.hasAttribute('data-toggle-alt-content')) { return; } if (!toggle.hasAttribute('data-toggle-original-content')) { toggle.setAttribute('data-toggle-original-content', toggle.innerHTML); } var currentContent = toggle.innerHTML; var originalContent = toggle.getAttribute('data-toggle-original-content'); var altContent = toggle.getAttribute('data-toggle-alt-content'); toggle.innerHTML = currentContent !== altContent ? altContent : originalContent; }); /* Prevents from disallowing clicks on links inside toggles */ var toggleLinks = toggles[i].querySelectorAll('a'); for (var j = 0; j < toggleLinks.length; j++) { addEventListener(toggleLinks[j], 'click', function(e) { e.stopPropagation(); }); } toggles[i].setAttribute('data-processed', 'true'); } } }; })(); Sfjs.addEventListener(document, 'DOMContentLoaded', function() { Sfjs.createTabs(); Sfjs.createToggles(); }); /*]]>*/ symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig000066400000000000000000000222621324732107100275340ustar00rootroot00000000000000html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0} html { /* always display the vertical scrollbar to avoid jumps when toggling contents */ overflow-y: scroll; } body { background-color: #F9F9F9; color: #222; font: 14px/1.4 Helvetica, Arial, sans-serif; padding-bottom: 45px; } a { cursor: pointer; text-decoration: none; } a:hover { text-decoration: underline; } abbr[title] { border-bottom: none; cursor: help; text-decoration: none; } code, pre { font: 13px/1.5 Consolas, Monaco, Menlo, "Ubuntu Mono", "Liberation Mono", monospace; } table, tr, th, td { background: #FFF; border-collapse: collapse; vertical-align: top; } table { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; width: 100%; } table th, table td { border: solid #E0E0E0; border-width: 1px 0; padding: 8px 10px; } table th { background-color: #E0E0E0; font-weight: bold; text-align: left; } .hidden-xs-down { display: none; } .block { display: block; } .hidden { display: none; } .nowrap { white-space: nowrap; } .newline { display: block; } .break-long-words { word-wrap: break-word; overflow-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; min-width: 0; } .text-small { font-size: 12px !important; } .text-muted { color: #999; } .text-bold { font-weight: bold; } .empty { border: 4px dashed #E0E0E0; color: #999; margin: 1em 0; padding: .5em 2em; } .status-success { background: rgba(94, 151, 110, 0.3); } .status-warning { background: rgba(240, 181, 24, 0.3); } .status-error { background: rgba(176, 65, 62, 0.2); } .status-success td, .status-warning td, .status-error td { background: transparent; } tr.status-error td, tr.status-warning td { border-bottom: 1px solid #FAFAFA; border-top: 1px solid #FAFAFA; } .status-warning .colored { color: #A46A1F; } .status-error .colored { color: #B0413E; } .sf-toggle { cursor: pointer; } .sf-toggle-content { -moz-transition: display .25s ease; -webkit-transition: display .25s ease; transition: display .25s ease; } .sf-toggle-content.sf-toggle-hidden { display: none; } .sf-toggle-content.sf-toggle-visible { display: block; } thead.sf-toggle-content.sf-toggle-visible, tbody.sf-toggle-content.sf-toggle-visible { display: table-row-group; } .sf-toggle-off .icon-close, .sf-toggle-on .icon-open { display: none; } .sf-toggle-off .icon-open, .sf-toggle-on .icon-close { display: block; } .tab-navigation { margin: 0 0 1em 0; padding: 0; } .tab-navigation li { background: #FFF; border: 1px solid #DDD; color: #444; cursor: pointer; display: inline-block; font-size: 16px; margin: 0 0 0 -1px; padding: .5em .75em; z-index: 1; } .tab-navigation li:hover { background: #EEE; } .tab-navigation li.disabled { background: #F5F5F5; color: #999; } .tab-navigation li.active { background: #666; border-color: #666; color: #FAFAFA; z-index: 1100; } .tab-navigation li .badge { background-color: #F5F5F5; color: #777; display: inline-block; font-size: 14px; font-weight: bold; margin-left: 8px; min-width: 10px; padding: 1px 6px; text-align: center; } .tab-navigation li:hover .badge { background: #FAFAFA; color: #777; } .tab-navigation li.active .badge { background-color: #444; color: #FFF; } .tab-navigation li .badge.status-warning { background: #A46A1F; color: #FFF; } .tab-navigation li .badge.status-error { background: #B0413E; color: #FFF; } .tab-content > *:first-child { margin-top: 0; } .container { max-width: 1024px; margin: 0 auto; padding: 0 15px; } .container::after { content: ""; display: table; clear: both; } header { background-color: #222; color: rgba(255, 255, 255, 0.75); font-size: 13px; height: 33px; line-height: 33px; padding: 0; } header .container { display: flex; justify-content: space-between; } .logo { flex: 1; font-size: 13px; font-weight: normal; margin: 0; padding: 0; } .logo svg { height: 18px; width: 18px; opacity: .8; vertical-align: -5px; } .help-link { margin-left: 15px; } .help-link a { color: inherit; } .help-link .icon svg { height: 15px; width: 15px; opacity: .7; vertical-align: -2px; } .help-link a:hover { color: #EEE; text-decoration: none; } .help-link a:hover svg { opacity: .9; } .exception-summary { background: #B0413E; border-bottom: 2px solid rgba(0, 0, 0, 0.1); border-top: 1px solid rgba(0, 0, 0, .3); flex: 0 0 auto; margin-bottom: 15px; } .exception-metadata { background: rgba(0, 0, 0, 0.1); padding: 7px 0; } .exception-metadata .container { display: flex; flex-direction: row; justify-content: space-between; } .exception-metadata h2 { color: rgba(255, 255, 255, 0.8); font-size: 13px; font-weight: 400; margin: 0; } .exception-http small { font-size: 13px; opacity: .7; } .exception-hierarchy { flex: 1; } .exception-hierarchy .icon { margin: 0 3px; opacity: .7; } .exception-hierarchy .icon svg { height: 13px; width: 13px; vertical-align: -2px; } .exception-without-message .exception-message-wrapper { display: none; } .exception-message-wrapper .container { display: flex; align-items: flex-start; min-height: 70px; padding: 10px 15px 8px; } .exception-message { flex-grow: 1; } .exception-message, .exception-message a { color: #FFF; font-size: 21px; font-weight: 400; margin: 0; } .exception-message.long { font-size: 18px; } .exception-message a { border-bottom: 1px solid rgba(255, 255, 255, 0.5); font-size: inherit; text-decoration: none; } .exception-message a:hover { border-bottom-color: #ffffff; } .exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; } .trace + .trace { margin-top: 30px; } .trace-head { background-color: #e0e0e0; padding: 10px; } .trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; } .trace-head .trace-namespace { color: #999; display: block; font-size: 13px; } .trace-head .icon { position: absolute; right: 0; top: 0; } .trace-head .icon svg { height: 24px; width: 24px; } .trace-details { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; } .trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; } .trace-details { table-layout: fixed; } .trace-line { position: relative; padding-top: 8px; padding-bottom: 8px; } .trace-line:hover { background: #F5F5F5; } .trace-line a { color: #222; } .trace-line .icon { opacity: .4; position: absolute; left: 10px; top: 11px; } .trace-line .icon svg { height: 16px; width: 16px; } .trace-line-header { padding-left: 36px; padding-right: 10px; } .trace-file-path, .trace-file-path a { color: #222; font-size: 13px; } .trace-class { color: #B0413E; } .trace-type { padding: 0 2px; } .trace-method { color: #B0413E; font-weight: bold; } .trace-arguments { color: #777; font-weight: normal; padding-left: 2px; } .trace-code { background: #FFF; font-size: 12px; margin: 10px 10px 2px 10px; padding: 10px; overflow-x: auto; white-space: nowrap; } .trace-code ol { margin: 0; float: left; } .trace-code li { color: #969896; margin: 0; padding-left: 10px; float: left; width: 100%; } .trace-code li + li { margin-top: 5px; } .trace-code li.selected { background: #F7E5A1; margin-top: 2px; } .trace-code li code { color: #222; white-space: nowrap; } .trace-as-text .stacktrace { line-height: 1.8; margin: 0 0 15px; white-space: pre-wrap; } @media (min-width: 575px) { .hidden-xs-down { display: initial; } .help-link { margin-left: 30px; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/000077500000000000000000000000001324732107100253145ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/chevron-right.svg000066400000000000000000000004251324732107100306150ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/favicon.png.base64000066400000000000000000000023271324732107100305360ustar00rootroot00000000000000data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAADVUlEQVRIx82XX0jTURTHLYPyqZdefQx66CEo80+aYpoIkqzUikz6Z5klQoWUWYRIJYEUGpQ+lIr9U5dOTLdCtkmWZis3rbnC5fw/neYW002307mX/cZvP3/7o1PwwOdh95x7vnf39zvnd29AgBer2xO6DclAXiMqZAqxIiNIN/IYSUS2BPhjmGATchUxI+ADWiRhpWK7HKuHFVBFdmU5YvnI4grFGCaReF/EBH4KsZlGgj2JBTuCYBWRIYF8YoEOJ6wBt/gEs7mBbyOjQXruPLSdOgPCiEiPSUUHDoL8Ug5IUo9B/d5wrt+G7OAKNrODPuVdB6vRCIzN6SdBlpW9RIgk/1FeAXabzRlrUPVCS/JhbmwudztnGeeH9AyXBIwtmM3wLinZJZHifjHw2V+NBoRh+9ixQrbgbnaSIcl7cGea6hoXQbNe7za241oeO5Z0p42M4BV2EqP2D50wo+6HzvwC6C4sApNOR8cmOrtcnhtj2kYRyC9eBvXzKrBZrXSs72kFd1t3MoKVbMekQkEnSNKOO8fac3LpmK6l1TlGtsxmsdKFsecPYgwxst0cwROMYDXboSotg0WLBRqjY51jLYcENElXwW2XJKPydvoI2GN9T8rBtrAArYIUruBJXkFheCQYlCpQP6uk5dAQFQNaUROMSGVQFxLmkoQsxDJrhLbTZ+nvVsERME9MgPJRKV/58AsyomTSzE813WLFvWK++qI0xSfQl8k8Pg46sYRuv5t6dS+4RqxDwaa4BGjYH+NTQvKScIp9+YL/hoZh3jDtLRHtt2C3g6bmhX+CpsFBWg7ilDSPgj0lD2ncr5ev/BP8VvyAJhqVyZeUhPOrEhEFxgEtjft846Z/guQTNT89Q5P9flMLoth4F7808wKtWWKzAwNQHxrh/1vaid2F+XpYTSbQf1XA2McOmOpROnvpvMEA4tSjq1cW0sws2gCYxswY6TKkvzYnJq1NHZLnRU4BX+4U0uburvusu8Kv8iHY7qefkM4IFngJHEOUXmLEPgiGsI8YnlZILit3vSSLRTQe/MPIZva5pshNIEmyFQlCvruJKXPkCEfmePzkphXHdzZNQdoRI9KPlBAxlj/I8U97ERPS5bjGbWDFbEdqHVe5caTBeZZx2H/IMvzeN15yoQAAAABJRU5ErkJggg== symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-book.svg000066400000000000000000000016211324732107100277150ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-minus-square-o.svg000066400000000000000000000006601324732107100316520ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-minus-square.svg000066400000000000000000000005211324732107100314120ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-plus-square-o.svg000066400000000000000000000010161324732107100314760ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-plus-square.svg000066400000000000000000000007121324732107100312440ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-support.svg000066400000000000000000000011721324732107100305000ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/symfony-ghost.svg000066400000000000000000000414501324732107100306670ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/images/symfony-logo.svg000066400000000000000000000017401324732107100305010ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig000066400000000000000000000026231324732107100272260ustar00rootroot00000000000000 {% block title %}{% endblock %} {% block head %}{% endblock %}
{% block body %}{% endblock %} {{ include('@Twig/base_js.html.twig') }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/TemplateIterator.php000066400000000000000000000053671324732107100247510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Finder\Finder; /** * Iterator for all templates in bundles and in the application Resources directory. * * @author Fabien Potencier */ class TemplateIterator implements \IteratorAggregate { private $kernel; private $rootDir; private $templates; private $paths; /** * @param KernelInterface $kernel A KernelInterface instance * @param string $rootDir The directory where global templates can be stored * @param array $paths Additional Twig paths to warm */ public function __construct(KernelInterface $kernel, $rootDir, array $paths = array()) { $this->kernel = $kernel; $this->rootDir = $rootDir; $this->paths = $paths; } /** * {@inheritdoc} */ public function getIterator() { if (null !== $this->templates) { return $this->templates; } $this->templates = $this->findTemplatesInDirectory($this->rootDir.'/Resources/views'); foreach ($this->kernel->getBundles() as $bundle) { $name = $bundle->getName(); if ('Bundle' === substr($name, -6)) { $name = substr($name, 0, -6); } $this->templates = array_merge( $this->templates, $this->findTemplatesInDirectory($bundle->getPath().'/Resources/views', $name), $this->findTemplatesInDirectory($this->rootDir.'/'.$bundle->getName().'/views', $name) ); } foreach ($this->paths as $dir => $namespace) { $this->templates = array_merge($this->templates, $this->findTemplatesInDirectory($dir, $namespace)); } return $this->templates = new \ArrayIterator(array_unique($this->templates)); } /** * Find templates in the given directory. * * @param string $dir The directory where to look for templates * @param string|null $namespace The template namespace * * @return array */ private function findTemplatesInDirectory($dir, $namespace = null) { if (!is_dir($dir)) { return array(); } $templates = array(); foreach (Finder::create()->files()->followLinks()->in($dir) as $file) { $templates[] = (null !== $namespace ? '@'.$namespace.'/' : '').str_replace('\\', '/', $file->getRelativePathname()); } return $templates; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/000077500000000000000000000000001324732107100220425ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/ContainerAwareRuntimeLoaderTest.php000066400000000000000000000025341324732107100310140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader; /** * @group legacy */ class ContainerAwareRuntimeLoaderTest extends TestCase { public function testLoad() { $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); $container->expects($this->once())->method('get')->with('foo'); $loader = new ContainerAwareRuntimeLoader($container, array( 'FooClass' => 'foo', )); $loader->load('FooClass'); } public function testLoadWithoutAMatch() { $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $logger->expects($this->once())->method('warning')->with('Class "BarClass" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.'); $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), array(), $logger); $this->assertNull($loader->load('BarClass')); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Controller/000077500000000000000000000000001324732107100241655ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php000066400000000000000000000063711324732107100315470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\Controller; use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Bundle\TwigBundle\Controller\ExceptionController; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpFoundation\Request; use Twig\Environment; use Twig\Loader\ArrayLoader; class ExceptionControllerTest extends TestCase { public function testShowActionCanBeForcedToShowErrorPage() { $twig = $this->createTwigEnv(array('@Twig/Exception/error404.html.twig' => 'not found')); $request = $this->createRequest('html'); $request->attributes->set('showException', false); $exception = FlattenException::create(new \Exception(), 404); $controller = new ExceptionController($twig, /* "showException" defaults to --> */ true); $response = $controller->showAction($request, $exception, null); $this->assertEquals(200, $response->getStatusCode()); // successful request $this->assertEquals('not found', $response->getContent()); } public function testFallbackToHtmlIfNoTemplateForRequestedFormat() { $twig = $this->createTwigEnv(array('@Twig/Exception/error.html.twig' => '')); $request = $this->createRequest('txt'); $exception = FlattenException::create(new \Exception()); $controller = new ExceptionController($twig, false); $controller->showAction($request, $exception); $this->assertEquals('html', $request->getRequestFormat()); } public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown() { $twig = $this->createTwigEnv(array('@Twig/Exception/exception_full.html.twig' => '')); $request = $this->createRequest('txt'); $request->attributes->set('showException', true); $exception = FlattenException::create(new \Exception()); $controller = new ExceptionController($twig, false); $controller->showAction($request, $exception); $this->assertEquals('html', $request->getRequestFormat()); } public function testResponseHasRequestedMimeType() { $twig = $this->createTwigEnv(array('@Twig/Exception/error.json.twig' => '{}')); $request = $this->createRequest('json'); $exception = FlattenException::create(new \Exception()); $controller = new ExceptionController($twig, false); $response = $controller->showAction($request, $exception); $this->assertEquals('json', $request->getRequestFormat()); $this->assertEquals($request->getMimeType('json'), $response->headers->get('Content-Type')); } private function createRequest($requestFormat) { $request = Request::create('whatever'); $request->headers->set('X-Php-Ob-Level', 1); $request->setRequestFormat($requestFormat); return $request; } private function createTwigEnv(array $templates) { return new Environment(new ArrayLoader($templates)); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php000066400000000000000000000037011324732107100322360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\Controller; use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController; use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; class PreviewErrorControllerTest extends TestCase { public function testForwardRequestToConfiguredController() { $request = Request::create('whatever'); $response = new Response(''); $code = 123; $logicalControllerName = 'foo:bar:baz'; $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel ->expects($this->once()) ->method('handle') ->with( $this->callback(function (Request $request) use ($logicalControllerName, $code) { $this->assertEquals($logicalControllerName, $request->attributes->get('_controller')); $exception = $request->attributes->get('exception'); $this->assertInstanceOf(FlattenException::class, $exception); $this->assertEquals($code, $exception->getStatusCode()); $this->assertFalse($request->attributes->get('showException')); return true; }), $this->equalTo(HttpKernelInterface::SUB_REQUEST) ) ->will($this->returnValue($response)); $controller = new PreviewErrorController($kernel, $logicalControllerName); $this->assertSame($response, $controller->previewErrorPageAction($request, $code)); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/000077500000000000000000000000001324732107100257635ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/000077500000000000000000000000001324732107100275355ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php000066400000000000000000000034211324732107100337110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; class ExtensionPassTest extends TestCase { public function testProcessDoesNotDropExistingFileLoaderMethodCalls() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); $container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable'); $container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine'); $container->register('twig.extension.yaml'); $container->register('twig.extension.debug.stopwatch'); $container->register('twig.extension.expression'); $nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader'); $nativeTwigLoader->addMethodCall('addPath', array()); $container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader); $filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader'); $filesystemLoader->setArguments(array(null, null, null)); $filesystemLoader->addMethodCall('addPath', array()); $container->setDefinition('twig.loader.filesystem', $filesystemLoader); $extensionPass = new ExtensionPass(); $extensionPass->process($container); $this->assertCount(2, $filesystemLoader->getMethodCalls()); } } TwigEnvironmentPassTest.php000066400000000000000000000032431324732107100350170ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class TwigEnvironmentPassTest extends TestCase { public function testTwigBridgeExtensionsAreRegisteredFirst() { $container = new ContainerBuilder(); $twigDefinition = $container->register('twig'); $container->register('other_extension', 'Foo\Bar') ->addTag('twig.extension'); $container->register('twig_bridge_extension', FormExtension::class) ->addTag('twig.extension'); $twigEnvironmentPass = new TwigEnvironmentPass(); $twigEnvironmentPass->process($container); $methodCalls = $twigDefinition->getMethodCalls(); $this->assertCount(2, $methodCalls); $twigBridgeExtensionReference = $methodCalls[0][1][0]; $this->assertInstanceOf(Reference::class, $twigBridgeExtensionReference); $this->assertSame('twig_bridge_extension', (string) $twigBridgeExtensionReference); $otherExtensionReference = $methodCalls[1][1][0]; $this->assertInstanceOf(Reference::class, $otherExtensionReference); $this->assertSame('other_extension', (string) $otherExtensionReference); } } TwigLoaderPassTest.php000066400000000000000000000062401324732107100337210ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass; class TwigLoaderPassTest extends TestCase { /** * @var ContainerBuilder */ private $builder; /** * @var Definition */ private $chainLoader; /** * @var TwigLoaderPass */ private $pass; protected function setUp() { $this->builder = new ContainerBuilder(); $this->builder->register('twig'); $this->chainLoader = new Definition('loader'); $this->pass = new TwigLoaderPass(); } public function testMapperPassWithOneTaggedLoader() { $this->builder->register('test_loader_1') ->addTag('twig.loader'); $this->pass->process($this->builder); $this->assertSame('test_loader_1', (string) $this->builder->getAlias('twig.loader')); } public function testMapperPassWithTwoTaggedLoaders() { $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); $this->builder->register('test_loader_1') ->addTag('twig.loader'); $this->builder->register('test_loader_2') ->addTag('twig.loader'); $this->pass->process($this->builder); $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); $calls = $this->chainLoader->getMethodCalls(); $this->assertCount(2, $calls); $this->assertEquals('addLoader', $calls[0][0]); $this->assertEquals('addLoader', $calls[1][0]); $this->assertEquals('test_loader_1', (string) $calls[0][1][0]); $this->assertEquals('test_loader_2', (string) $calls[1][1][0]); } public function testMapperPassWithTwoTaggedLoadersWithPriority() { $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); $this->builder->register('test_loader_1') ->addTag('twig.loader', array('priority' => 100)); $this->builder->register('test_loader_2') ->addTag('twig.loader', array('priority' => 200)); $this->pass->process($this->builder); $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); $calls = $this->chainLoader->getMethodCalls(); $this->assertCount(2, $calls); $this->assertEquals('addLoader', $calls[0][0]); $this->assertEquals('addLoader', $calls[1][0]); $this->assertEquals('test_loader_2', (string) $calls[0][1][0]); $this->assertEquals('test_loader_1', (string) $calls[1][1][0]); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException */ public function testMapperPassWithZeroTaggedLoaders() { $this->pass->process($this->builder); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php000066400000000000000000000015651324732107100321520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration; use Symfony\Component\Config\Definition\Processor; class ConfigurationTest extends TestCase { public function testDoNoDuplicateDefaultFormResources() { $input = array( 'form_themes' => array('form_div_layout.html.twig'), ); $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(), array($input)); $this->assertEquals(array('form_div_layout.html.twig'), $config['form_themes']); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/000077500000000000000000000000001324732107100275745ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/000077500000000000000000000000001324732107100310055ustar00rootroot00000000000000ChildChildChildChildTwigBundle/000077500000000000000000000000001324732107100366125ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/BundleResources/000077500000000000000000000000001324732107100405645ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundleviews/000077500000000000000000000000001324732107100417215ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resourceslayout.html.twig000066400000000000000000000000211324732107100450660ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/viewsThis is a layout ChildChildChildTwigBundle/000077500000000000000000000000001324732107100356465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/BundleResources/000077500000000000000000000000001324732107100376205ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundleviews/000077500000000000000000000000001324732107100407555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resourceslayout.html.twig000066400000000000000000000000211324732107100441220ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/viewsThis is a layout ChildChildTwigBundle/000077500000000000000000000000001324732107100347025ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/BundleResources/000077500000000000000000000000001324732107100366545ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundleviews/000077500000000000000000000000001324732107100400115ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resourceslayout.html.twig000066400000000000000000000000211324732107100431560ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/viewsThis is a layout ChildTwigBundle/000077500000000000000000000000001324732107100337365ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/BundleResources/000077500000000000000000000000001324732107100357105ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundleviews/000077500000000000000000000000001324732107100370455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resourceslayout.html.twig000066400000000000000000000000211324732107100422120ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/viewsThis is a layout symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/000077500000000000000000000000001324732107100315465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/000077500000000000000000000000001324732107100336125ustar00rootroot00000000000000views/000077500000000000000000000000001324732107100346705ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundlelayout.html.twig000066400000000000000000000000211324732107100400350ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/viewsThis is a layout symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/views/000077500000000000000000000000001324732107100327035ustar00rootroot00000000000000layout.html.twig000066400000000000000000000000211324732107100357710ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Resources/viewsThis is a layout symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/000077500000000000000000000000001324732107100303635ustar00rootroot00000000000000customTemplateEscapingGuesser.php000066400000000000000000000002641324732107100370350ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/phploadFromExtension('twig', array( 'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser', 'autoescape_service_method' => 'guess', )); symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php000066400000000000000000000000671324732107100322350ustar00rootroot00000000000000loadFromExtension('twig', array()); symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php000066400000000000000000000002051324732107100322140ustar00rootroot00000000000000loadFromExtension('twig', array( 'paths' => array( 'namespaced_path3' => 'namespace3', ), )); symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php000066400000000000000000000004771324732107100325570ustar00rootroot00000000000000loadFromExtension('twig', array( 'date' => array( 'format' => 'Y-m-d', 'interval_format' => '%d', 'timezone' => 'Europe/Berlin', ), 'number_format' => array( 'decimals' => 2, 'decimal_point' => ',', 'thousands_separator' => '.', ), )); symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php000066400000000000000000000012601324732107100320350ustar00rootroot00000000000000loadFromExtension('twig', array( 'form_themes' => array( 'MyBundle::form.html.twig', ), 'globals' => array( 'foo' => '@bar', 'baz' => '@@qux', 'pi' => 3.14, 'bad' => array('key' => 'foo'), ), 'auto_reload' => true, 'autoescape' => true, 'base_template_class' => 'stdClass', 'cache' => '/tmp', 'charset' => 'ISO-8859-1', 'debug' => true, 'strict_variables' => true, 'default_path' => '%kernel.project_dir%/Fixtures/templates', 'paths' => array( 'path1', 'path2', 'namespaced_path1' => 'namespace1', 'namespaced_path2' => 'namespace2', ), )); symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/000077500000000000000000000000001324732107100315725ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundles/000077500000000000000000000000001324732107100332265ustar00rootroot00000000000000TwigBundle/000077500000000000000000000000001324732107100352135ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundleslayout.html.twig000066400000000000000000000000211324732107100403600ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundleThis is a layout layout.html.twig000066400000000000000000000000211324732107100346600ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templatesThis is a layout symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/000077500000000000000000000000001324732107100303745ustar00rootroot00000000000000customTemplateEscapingGuesser.xml000066400000000000000000000011031324732107100370500ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml000066400000000000000000000007331324732107100322570ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml000066400000000000000000000012511324732107100322400ustar00rootroot00000000000000 namespaced_path3 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml000066400000000000000000000011571324732107100325750ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml000066400000000000000000000021231324732107100320560ustar00rootroot00000000000000 MyBundle::form.html.twig @@qux 3.14 path1 path2 namespaced_path1 namespaced_path2 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/000077500000000000000000000000001324732107100303755ustar00rootroot00000000000000customTemplateEscapingGuesser.yml000066400000000000000000000001641324732107100370600ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/ymltwig: autoescape_service: my_project.some_bundle.template_escaping_guesser autoescape_service_method: guess symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml000066400000000000000000000000061324732107100322520ustar00rootroot00000000000000twig: symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml000066400000000000000000000000661324732107100322450ustar00rootroot00000000000000twig: paths: namespaced_path3: namespace3 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml000066400000000000000000000003051324732107100325710ustar00rootroot00000000000000twig: date: format: Y-m-d interval_format: '%d' timezone: Europe/Berlin number_format: decimals: 2 decimal_point: ',' thousands_separator: . symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml000066400000000000000000000010531324732107100320610ustar00rootroot00000000000000twig: form_themes: - MyBundle::form.html.twig globals: foo: "@bar" baz: "@@qux" pi: 3.14 bad: {key: foo} auto_reload: true autoescape: true base_template_class: stdClass cache: /tmp charset: ISO-8859-1 debug: true strict_variables: true default_path: '%kernel.project_dir%/Fixtures/templates' paths: path1: '' path2: '' namespaced_path1: namespace1 namespaced_path2: namespace2 symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php000066400000000000000000000416271324732107100321550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension; use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; class TwigExtensionTest extends TestCase { public function testLoadEmptyConfiguration() { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $container->loadFromExtension('twig', array()); $this->compileContainer($container); $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources'); // Twig options $options = $container->getDefinition('twig')->getArgument(1); $this->assertEquals('%kernel.cache_dir%/twig', $options['cache'], '->load() sets default value for cache option'); $this->assertEquals('%kernel.charset%', $options['charset'], '->load() sets default value for charset option'); $this->assertEquals('%kernel.debug%', $options['debug'], '->load() sets default value for debug option'); } /** * @dataProvider getFormats */ public function testLoadFullConfiguration($format) { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'full', $format); $this->compileContainer($container); $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); // Form resources $resources = $container->getParameter('twig.form.resources'); $this->assertContains('form_div_layout.html.twig', $resources, '->load() includes default template for form resources'); $this->assertContains('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources'); // Globals $calls = $container->getDefinition('twig')->getMethodCalls(); $this->assertEquals('app', $calls[0][1][0], '->load() registers services as Twig globals'); $this->assertEquals(new Reference('twig.app_variable'), $calls[0][1][1]); $this->assertEquals('foo', $calls[2][1][0], '->load() registers services as Twig globals'); $this->assertEquals(new Reference('bar'), $calls[2][1][1], '->load() registers services as Twig globals'); $this->assertEquals('baz', $calls[3][1][0], '->load() registers variables as Twig globals'); $this->assertEquals('@qux', $calls[3][1][1], '->load() allows escaping of service identifiers'); $this->assertEquals('pi', $calls[4][1][0], '->load() registers variables as Twig globals'); $this->assertEquals(3.14, $calls[4][1][1], '->load() registers variables as Twig globals'); // Yaml and Php specific configs if (in_array($format, array('yml', 'php'))) { $this->assertEquals('bad', $calls[5][1][0], '->load() registers variables as Twig globals'); $this->assertEquals(array('key' => 'foo'), $calls[5][1][1], '->load() registers variables as Twig globals'); } // Twig options $options = $container->getDefinition('twig')->getArgument(1); $this->assertTrue($options['auto_reload'], '->load() sets the auto_reload option'); $this->assertTrue($options['autoescape'], '->load() sets the autoescape option'); $this->assertEquals('stdClass', $options['base_template_class'], '->load() sets the base_template_class option'); $this->assertEquals('/tmp', $options['cache'], '->load() sets the cache option'); $this->assertEquals('ISO-8859-1', $options['charset'], '->load() sets the charset option'); $this->assertTrue($options['debug'], '->load() sets the debug option'); $this->assertTrue($options['strict_variables'], '->load() sets the strict_variables option'); } /** * @dataProvider getFormats */ public function testLoadCustomTemplateEscapingGuesserConfiguration($format) { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'customTemplateEscapingGuesser', $format); $this->compileContainer($container); $options = $container->getDefinition('twig')->getArgument(1); $this->assertEquals(array(new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'), $options['autoescape']); } /** * @dataProvider getFormats */ public function testLoadDefaultTemplateEscapingGuesserConfiguration($format) { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'empty', $format); $this->compileContainer($container); $options = $container->getDefinition('twig')->getArgument(1); $this->assertEquals('name', $options['autoescape']); } /** * @dataProvider getFormats */ public function testLoadCustomDateFormats($fileFormat) { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'formats', $fileFormat); $this->compileContainer($container); $environmentConfigurator = $container->getDefinition('twig.configurator.environment'); $this->assertSame('Y-m-d', $environmentConfigurator->getArgument(0)); $this->assertSame('%d', $environmentConfigurator->getArgument(1)); $this->assertSame('Europe/Berlin', $environmentConfigurator->getArgument(2)); $this->assertSame(2, $environmentConfigurator->getArgument(3)); $this->assertSame(',', $environmentConfigurator->getArgument(4)); $this->assertSame('.', $environmentConfigurator->getArgument(5)); } public function testGlobalsWithDifferentTypesAndValues() { $globals = array( 'array' => array(), 'false' => false, 'float' => 2.0, 'integer' => 3, 'null' => null, 'object' => new \stdClass(), 'string' => 'foo', 'true' => true, ); $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $container->loadFromExtension('twig', array('globals' => $globals)); $this->compileContainer($container); $calls = $container->getDefinition('twig')->getMethodCalls(); foreach (array_slice($calls, 2) as $call) { $this->assertEquals(key($globals), $call[1][0]); $this->assertSame(current($globals), $call[1][1]); next($globals); } } /** * @dataProvider getFormats */ public function testTwigLoaderPaths($format) { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'full', $format); $this->loadFromFile($container, 'extra', $format); $this->compileContainer($container); $def = $container->getDefinition('twig.loader.native_filesystem'); $paths = array(); foreach ($def->getMethodCalls() as $call) { if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) { $paths[] = $call[1]; } } $this->assertEquals(array( array('path1'), array('path2'), array('namespaced_path1', 'namespace1'), array('namespaced_path2', 'namespace2'), array('namespaced_path3', 'namespace3'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'), array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'), array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'), array(realpath(__DIR__.'/../..').'/Resources/views', '!Twig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'ChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'), array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildChildTwig'), array(__DIR__.'/Fixtures/Resources/views'), array(__DIR__.'/Fixtures/templates'), ), $paths); } public function getFormats() { return array( array('php'), array('yml'), array('xml'), ); } /** * @dataProvider stopwatchExtensionAvailabilityProvider */ public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $expected) { $container = $this->createContainer(); $container->setParameter('kernel.debug', $debug); if ($stopwatchEnabled) { $container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch'); } $container->registerExtension(new TwigExtension()); $container->loadFromExtension('twig', array()); $container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true); $this->compileContainer($container); $tokenParsers = $container->get('test.twig.extension.debug.stopwatch')->getTokenParsers(); $stopwatchIsAvailable = new \ReflectionProperty($tokenParsers[0], 'stopwatchIsAvailable'); $stopwatchIsAvailable->setAccessible(true); $this->assertSame($expected, $stopwatchIsAvailable->getValue($tokenParsers[0])); } public function stopwatchExtensionAvailabilityProvider() { return array( 'debug-and-stopwatch-enabled' => array(true, true, true), 'only-stopwatch-enabled' => array(false, true, false), 'only-debug-enabled' => array(true, false, false), 'debug-and-stopwatch-disabled' => array(false, false, false), ); } public function testRuntimeLoader() { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $container->loadFromExtension('twig', array()); $container->setParameter('kernel.environment', 'test'); $container->setParameter('debug.file_link_format', 'test'); $container->setParameter('foo', 'FooClass'); $container->register('http_kernel', 'FooClass'); $container->register('templating.locator', 'FooClass'); $container->register('templating.name_parser', 'FooClass'); $container->register('foo', '%foo%')->addTag('twig.runtime'); $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); $loader = $container->getDefinition('twig.runtime_loader'); $args = $container->getDefinition((string) $loader->getArgument(0))->getArgument(0); $this->assertArrayHasKey('Symfony\Component\Form\FormRenderer', $args); $this->assertArrayHasKey('FooClass', $args); $this->assertEquals('twig.form.renderer', $args['Symfony\Component\Form\FormRenderer']->getValues()[0]); $this->assertEquals('foo', $args['FooClass']->getValues()[0]); } private function createContainer() { $container = new ContainerBuilder(new ParameterBag(array( 'kernel.cache_dir' => __DIR__, 'kernel.root_dir' => __DIR__.'/Fixtures', 'kernel.project_dir' => __DIR__, 'kernel.charset' => 'UTF-8', 'kernel.debug' => false, 'kernel.bundles' => array( 'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle', 'ChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', 'ChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', 'ChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', 'ChildChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', ), 'kernel.bundles_metadata' => array( 'ChildChildChildChildTwigBundle' => array( 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', 'parent' => 'ChildChildChildTwigBundle', 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle', ), 'TwigBundle' => array( 'namespace' => 'Symfony\\Bundle\\TwigBundle', 'parent' => null, 'path' => realpath(__DIR__.'/../..'), ), 'ChildTwigBundle' => array( 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', 'parent' => 'TwigBundle', 'path' => __DIR__.'/Fixtures/Bundle/ChildTwigBundle', ), 'ChildChildChildTwigBundle' => array( 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', 'parent' => 'ChildChildTwigBundle', 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle', ), 'ChildChildTwigBundle' => array( 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', 'parent' => 'ChildTwigBundle', 'path' => __DIR__.'/Fixtures/Bundle/ChildChildTwigBundle', ), ), ))); return $container; } private function compileContainer(ContainerBuilder $container) { $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); } private function loadFromFile(ContainerBuilder $container, $file, $format) { $locator = new FileLocator(__DIR__.'/Fixtures/'.$format); switch ($format) { case 'php': $loader = new PhpFileLoader($container, $locator); break; case 'xml': $loader = new XmlFileLoader($container, $locator); break; case 'yml': $loader = new YamlFileLoader($container, $locator); break; default: throw new \InvalidArgumentException(sprintf('Unsupported format: %s', $format)); } $loader->load($file.'.'.$format); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/000077500000000000000000000000001324732107100236535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/000077500000000000000000000000001324732107100256515ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/BarBundle/000077500000000000000000000000001324732107100275075ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/BarBundle/Resources/000077500000000000000000000000001324732107100314615ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/BarBundle/Resources/views/000077500000000000000000000000001324732107100326165ustar00rootroot00000000000000index.html.twig000066400000000000000000000000241324732107100355010ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/BarBundle/Resources/views{# Twig template #} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Foo/000077500000000000000000000000001324732107100263745ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Foo/index.html.twig000066400000000000000000000000241324732107100313360ustar00rootroot00000000000000{# Twig template #} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/000077500000000000000000000000001324732107100276235ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/views/000077500000000000000000000000001324732107100307605ustar00rootroot00000000000000layout.html.twig000066400000000000000000000000241324732107100340510ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/views{# Twig template #} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/views/sub/000077500000000000000000000000001324732107100315515ustar00rootroot00000000000000sub.html.twig000066400000000000000000000000241324732107100341160ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/views/sub{# Twig template #} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/000077500000000000000000000000001324732107100241445ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php000066400000000000000000000064651324732107100300600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\Functional; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Bundle\TwigBundle\TwigBundle; class CacheWarmingTest extends TestCase { public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable() { $kernel = new CacheWarmingKernel(true); $kernel->boot(); $warmer = $kernel->getContainer()->get('cache_warmer'); $warmer->enableOptionalWarmers(); $warmer->warmUp($kernel->getCacheDir()); $this->assertFileExists($kernel->getCacheDir().'/twig'); } public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled() { $kernel = new CacheWarmingKernel(false); $kernel->boot(); $warmer = $kernel->getContainer()->get('cache_warmer'); $warmer->enableOptionalWarmers(); $warmer->warmUp($kernel->getCacheDir()); $this->assertFileExists($kernel->getCacheDir().'/twig'); } protected function setUp() { $this->deleteTempDir(); } protected function tearDown() { $this->deleteTempDir(); } private function deleteTempDir() { if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel')) { return; } $fs = new Filesystem(); $fs->remove($dir); } } class CacheWarmingKernel extends Kernel { private $withTemplating; public function __construct($withTemplating) { $this->withTemplating = $withTemplating; parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true); } public function getName() { return 'CacheWarming'; } public function registerBundles() { return array(new FrameworkBundle(), new TwigBundle()); } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function ($container) { $container->loadFromExtension('framework', array( 'secret' => '$ecret', 'form' => array('enabled' => false), )); }); if ($this->withTemplating) { $loader->load(function ($container) { $container->loadFromExtension('framework', array( 'secret' => '$ecret', 'templating' => array('engines' => array('twig')), 'router' => array('resource' => '%kernel.project_dir%/Resources/config/empty_routing.yml'), 'form' => array('enabled' => false), )); }); } } public function getProjectDir() { return __DIR__; } public function getCacheDir() { return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment; } public function getLogDir() { return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/logs'; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php000066400000000000000000000040421324732107100311400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\Functional; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Bundle\TwigBundle\TwigBundle; class NoTemplatingEntryTest extends TestCase { public function test() { $kernel = new NoTemplatingEntryKernel('dev', true); $kernel->boot(); $container = $kernel->getContainer(); $content = $container->get('twig')->render('index.html.twig'); $this->assertContains('{ a: b }', $content); } protected function setUp() { $this->deleteTempDir(); } protected function tearDown() { $this->deleteTempDir(); } protected function deleteTempDir() { if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel')) { return; } $fs = new Filesystem(); $fs->remove($dir); } } class NoTemplatingEntryKernel extends Kernel { public function registerBundles() { return array(new FrameworkBundle(), new TwigBundle()); } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function ($container) { $container->loadFromExtension('framework', array( 'secret' => '$ecret', 'form' => array('enabled' => false), )); }); } public function getCacheDir() { return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/cache/'.$this->environment; } public function getLogDir() { return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/logs'; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/Resources/000077500000000000000000000000001324732107100261165ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/Resources/config/000077500000000000000000000000001324732107100273635ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/Resources/config/empty_routing.yml000066400000000000000000000000001324732107100330010ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/Resources/views/000077500000000000000000000000001324732107100272535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Functional/Resources/views/index.html.twig000066400000000000000000000000331324732107100322150ustar00rootroot00000000000000{{ {a: 'b'}|yaml_encode }} symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Loader/000077500000000000000000000000001324732107100232505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php000066400000000000000000000124251324732107100301000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests\Loader; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader; use Symfony\Bundle\TwigBundle\Tests\TestCase; class FilesystemLoaderTest extends TestCase { public function testGetSourceContext() { $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') ->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) ; $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace'); // Twig-style $this->assertEquals("This is a layout\n", $loader->getSourceContext('@namespace/layout.html.twig')->getCode()); // Symfony-style $this->assertEquals("This is a layout\n", $loader->getSourceContext('TwigBundle::layout.html.twig')->getCode()); } public function testExists() { // should return true for templates that Twig does not find, but Symfony does $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') ->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) ; $loader = new FilesystemLoader($locator, $parser); $this->assertTrue($loader->exists($template)); } /** * @expectedException \Twig\Error\LoaderError */ public function testTwigErrorIfLocatorThrowsInvalid() { $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $parser ->expects($this->once()) ->method('parse') ->with('name.format.engine') ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') ->will($this->throwException(new \InvalidArgumentException('Unable to find template "NonExistent".'))) ; $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); } /** * @expectedException \Twig\Error\LoaderError */ public function testTwigErrorIfLocatorReturnsFalse() { $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $parser ->expects($this->once()) ->method('parse') ->with('name.format.engine') ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') ->will($this->returnValue(false)) ; $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); } /** * @expectedException \Twig\Error\LoaderError * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/ */ public function testTwigErrorIfTemplateDoesNotExist() { $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); $method->setAccessible(true); $method->invoke($loader, 'name.format.engine'); } public function testTwigSoftErrorIfTemplateDoesNotExist() { $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); $method->setAccessible(true); $this->assertFalse($method->invoke($loader, 'name.format.engine', false)); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php000066400000000000000000000026651324732107100267110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests; use Symfony\Bundle\TwigBundle\TemplateIterator; class TemplateIteratorTest extends TestCase { public function testGetIterator() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); $kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array( $bundle, ))); $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo')); $sorted = iterator_to_array($iterator); sort($sorted); $this->assertEquals( array( '@Bar/index.html.twig', '@Foo/index.html.twig', 'layout.html.twig', 'sub/sub.html.twig', ), $sorted ); } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/Tests/TestCase.php000066400000000000000000000005711324732107100242710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Tests; use PHPUnit\Framework\TestCase as PHPUnitTestCase; class TestCase extends PHPUnitTestCase { } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/TwigBundle.php000066400000000000000000000027651324732107100235270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle; use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExceptionListenerPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; /** * Bundle. * * @author Fabien Potencier */ class TwigBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new ExtensionPass()); $container->addCompilerPass(new TwigEnvironmentPass()); $container->addCompilerPass(new TwigLoaderPass()); $container->addCompilerPass(new ExceptionListenerPass()); $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); } public function registerCommands(Application $application) { // noop } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/TwigEngine.php000066400000000000000000000042561324732107100235200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle; use Symfony\Bridge\Twig\TwigEngine as BaseEngine; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Config\FileLocatorInterface; use Twig\Environment; use Twig\Error\Error; /** * This engine renders Twig templates. * * @author Fabien Potencier */ class TwigEngine extends BaseEngine implements EngineInterface { protected $locator; public function __construct(Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator) { parent::__construct($environment, $parser); $this->locator = $locator; } /** * {@inheritdoc} */ public function render($name, array $parameters = array()) { try { return parent::render($name, $parameters); } catch (Error $e) { if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) { try { // try to get the real name of the template where the error occurred $name = $e->getTemplateName(); $path = (string) $this->locator->locate($this->parser->parse($name)); $e->setTemplateName($path); } catch (\Exception $e2) { } } throw $e; } } /** * {@inheritdoc} * * @throws Error if something went wrong like a thrown exception while rendering the template */ public function renderResponse($view, array $parameters = array(), Response $response = null) { if (null === $response) { $response = new Response(); } $response->setContent($this->render($view, $parameters)); return $response; } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/composer.json000066400000000000000000000032711324732107100234650ustar00rootroot00000000000000{ "name": "symfony/twig-bundle", "type": "symfony-bundle", "description": "Symfony TwigBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/config": "~3.2|~4.0", "symfony/twig-bridge": "^3.4.3|^4.0.3", "symfony/http-foundation": "~2.8|~3.0|~4.0", "symfony/http-kernel": "^3.3|~4.0", "twig/twig": "~1.34|~2.4" }, "require-dev": { "symfony/asset": "~2.8|~3.0|~4.0", "symfony/stopwatch": "~2.8|~3.0|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/form": "~2.8|~3.0|~4.0", "symfony/routing": "~2.8|~3.0|~4.0", "symfony/templating": "~2.8|~3.0|~4.0", "symfony/yaml": "~2.8|~3.0|~4.0", "symfony/framework-bundle": "^3.3.11|~4.0", "symfony/web-link": "~3.3|~4.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0" }, "conflict": { "symfony/dependency-injection": "<3.4", "symfony/event-dispatcher": "<3.3.1" }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist000066400000000000000000000015561324732107100241220ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/000077500000000000000000000000001324732107100222465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/.gitignore000066400000000000000000000000421324732107100242320ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md000066400000000000000000000020501324732107100240540ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * Deprecated the `web_profiler.position` config option (in 4.0 version the toolbar will always be displayed at the bottom) and the `web_profiler.debug_toolbar.position` container parameter. 3.1.0 ----- * added information about redirected and forwarded requests to the profiler 3.0.0 ----- * removed profiler:import and profiler:export commands 2.8.0 ----- * deprecated profiler:import and profiler:export commands 2.7.0 ----- * [BC BREAK] if you are using a DB to store profiles, the table must be dropped * added the HTTP status code to profiles 2.3.0 ----- * draw retina canvas if devicePixelRatio is bigger than 1 2.1.0 ----- * deprecated the verbose setting (not relevant anymore) * [BC BREAK] You must clear old profiles after upgrading to 2.1 (don't forget to remove the table if you are using a DB) * added support for the request method * added a routing panel * added a timeline panel * The toolbar position can now be configured via the `position` option (can be `top` or `bottom`) symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Controller/000077500000000000000000000000001324732107100243715ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php000066400000000000000000000073571324732107100311200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Controller; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; use Twig\Error\LoaderError; use Twig\Loader\ExistsLoaderInterface; /** * ExceptionController. * * @author Fabien Potencier */ class ExceptionController { protected $twig; protected $debug; protected $profiler; public function __construct(Profiler $profiler = null, Environment $twig, $debug) { $this->profiler = $profiler; $this->twig = $twig; $this->debug = $debug; } /** * Renders the exception panel for the given token. * * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function showAction($token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); $exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException(); $template = $this->getTemplate(); if (!$this->twig->getLoader()->exists($template)) { $handler = new ExceptionHandler($this->debug, $this->twig->getCharset()); return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html')); } $code = $exception->getStatusCode(); return new Response($this->twig->render( $template, array( 'status_code' => $code, 'status_text' => Response::$statusTexts[$code], 'exception' => $exception, 'logger' => null, 'currentContent' => '', ) ), 200, array('Content-Type' => 'text/html')); } /** * Renders the exception panel stylesheet for the given token. * * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function cssAction($token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); $exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException(); $template = $this->getTemplate(); if (!$this->templateExists($template)) { $handler = new ExceptionHandler($this->debug, $this->twig->getCharset()); return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); } return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css')); } protected function getTemplate() { return '@Twig/Exception/'.($this->debug ? 'exception' : 'error').'.html.twig'; } // to be removed when the minimum required version of Twig is >= 2.0 protected function templateExists($template) { $loader = $this->twig->getLoader(); if ($loader instanceof ExistsLoaderInterface) { return $loader->exists($template); } try { $loader->getSource($template); return true; } catch (LoaderError $e) { } return false; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php000066400000000000000000000354371324732107100307440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Controller; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\Environment; /** * @author Fabien Potencier */ class ProfilerController { private $templateManager; private $generator; private $profiler; private $twig; private $templates; private $toolbarPosition; private $cspHandler; private $baseDir; /** * @param UrlGeneratorInterface $generator The URL Generator * @param Profiler $profiler The profiler * @param Environment $twig The twig environment * @param array $templates The templates * @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration) * @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler * @param string $baseDir The project root directory */ public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, $toolbarPosition = 'bottom', ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null) { $this->generator = $generator; $this->profiler = $profiler; $this->twig = $twig; $this->templates = $templates; $this->toolbarPosition = $toolbarPosition; $this->cspHandler = $cspHandler; $this->baseDir = $baseDir; } /** * Redirects to the last profiles. * * @return RedirectResponse A RedirectResponse instance * * @throws NotFoundHttpException */ public function homeAction() { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)), 302, array('Content-Type' => 'text/html')); } /** * Renders a profiler panel for the given token. * * @param Request $request The current HTTP request * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function panelAction(Request $request, $token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); if (null !== $this->cspHandler) { $this->cspHandler->disableCsp(); } $panel = $request->query->get('panel', 'request'); $page = $request->query->get('page', 'home'); if ('latest' === $token && $latest = current($this->profiler->find(null, null, 1, null, null, null))) { $token = $latest['token']; } if (!$profile = $this->profiler->loadProfile($token)) { return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token, 'request' => $request)), 200, array('Content-Type' => 'text/html')); } if (!$profile->hasCollector($panel)) { throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token)); } return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array( 'token' => $token, 'profile' => $profile, 'collector' => $profile->getCollector($panel), 'panel' => $panel, 'page' => $page, 'request' => $request, 'templates' => $this->getTemplateManager()->getNames($profile), 'is_ajax' => $request->isXmlHttpRequest(), 'profiler_markup_version' => 2, // 1 = original profiler, 2 = Symfony 2.8+ profiler )), 200, array('Content-Type' => 'text/html')); } /** * Renders the Web Debug Toolbar. * * @param Request $request The current HTTP Request * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function toolbarAction(Request $request, $token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $session = $request->getSession(); if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } if ('empty' === $token || null === $token) { return new Response('', 200, array('Content-Type' => 'text/html')); } $this->profiler->disable(); if (!$profile = $this->profiler->loadProfile($token)) { return new Response('', 404, array('Content-Type' => 'text/html')); } // the toolbar position (top, bottom, normal, or null -- use the configuration) if (null === $position = $request->query->get('position')) { $position = $this->toolbarPosition; } $url = null; try { $url = $this->generator->generate('_profiler', array('token' => $token)); } catch (\Exception $e) { // the profiler is not enabled } return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', array( 'request' => $request, 'position' => $position, 'profile' => $profile, 'templates' => $this->getTemplateManager()->getNames($profile), 'profiler_url' => $url, 'token' => $token, 'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar )); } /** * Renders the profiler search bar. * * @return Response A Response instance * * @throws NotFoundHttpException */ public function searchBarAction(Request $request) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); if (null !== $this->cspHandler) { $this->cspHandler->disableCsp(); } if (null === $session = $request->getSession()) { $ip = $method = $statusCode = $url = $start = $end = $limit = $token = null; } else { $ip = $request->query->get('ip', $session->get('_profiler_search_ip')); $method = $request->query->get('method', $session->get('_profiler_search_method')); $statusCode = $request->query->get('status_code', $session->get('_profiler_search_status_code')); $url = $request->query->get('url', $session->get('_profiler_search_url')); $start = $request->query->get('start', $session->get('_profiler_search_start')); $end = $request->query->get('end', $session->get('_profiler_search_end')); $limit = $request->query->get('limit', $session->get('_profiler_search_limit')); $token = $request->query->get('token', $session->get('_profiler_search_token')); } return new Response( $this->twig->render('@WebProfiler/Profiler/search.html.twig', array( 'token' => $token, 'ip' => $ip, 'method' => $method, 'status_code' => $statusCode, 'url' => $url, 'start' => $start, 'end' => $end, 'limit' => $limit, 'request' => $request, )), 200, array('Content-Type' => 'text/html') ); } /** * Renders the search results. * * @param Request $request The current HTTP Request * @param string $token The token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function searchResultsAction(Request $request, $token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); if (null !== $this->cspHandler) { $this->cspHandler->disableCsp(); } $profile = $this->profiler->loadProfile($token); $ip = $request->query->get('ip'); $method = $request->query->get('method'); $statusCode = $request->query->get('status_code'); $url = $request->query->get('url'); $start = $request->query->get('start', null); $end = $request->query->get('end', null); $limit = $request->query->get('limit'); return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array( 'request' => $request, 'token' => $token, 'profile' => $profile, 'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode), 'ip' => $ip, 'method' => $method, 'status_code' => $statusCode, 'url' => $url, 'start' => $start, 'end' => $end, 'limit' => $limit, 'panel' => null, )), 200, array('Content-Type' => 'text/html')); } /** * Narrows the search bar. * * @return Response A Response instance * * @throws NotFoundHttpException */ public function searchAction(Request $request) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); $ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip')); $method = $request->query->get('method'); $statusCode = $request->query->get('status_code'); $url = $request->query->get('url'); $start = $request->query->get('start', null); $end = $request->query->get('end', null); $limit = $request->query->get('limit'); $token = $request->query->get('token'); if (null !== $session = $request->getSession()) { $session->set('_profiler_search_ip', $ip); $session->set('_profiler_search_method', $method); $session->set('_profiler_search_status_code', $statusCode); $session->set('_profiler_search_url', $url); $session->set('_profiler_search_start', $start); $session->set('_profiler_search_end', $end); $session->set('_profiler_search_limit', $limit); $session->set('_profiler_search_token', $token); } if (!empty($token)) { return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token)), 302, array('Content-Type' => 'text/html')); } $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode); return new RedirectResponse($this->generator->generate('_profiler_search_results', array( 'token' => $tokens ? $tokens[0]['token'] : 'empty', 'ip' => $ip, 'method' => $method, 'status_code' => $statusCode, 'url' => $url, 'start' => $start, 'end' => $end, 'limit' => $limit, )), 302, array('Content-Type' => 'text/html')); } /** * Displays the PHP info. * * @return Response A Response instance * * @throws NotFoundHttpException */ public function phpinfoAction() { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); if (null !== $this->cspHandler) { $this->cspHandler->disableCsp(); } ob_start(); phpinfo(); $phpinfo = ob_get_clean(); return new Response($phpinfo, 200, array('Content-Type' => 'text/html')); } /** * Displays the source of a file. * * @return Response A Response instance * * @throws NotFoundHttpException */ public function openAction(Request $request) { if (null === $this->baseDir) { throw new NotFoundHttpException('The base dir should be set.'); } if ($this->profiler) { $this->profiler->disable(); } $file = $request->query->get('file'); $line = $request->query->get('line'); $filename = $this->baseDir.DIRECTORY_SEPARATOR.$file; if (preg_match("'(^|[/\\\\])\.'", $file) || !is_readable($filename)) { throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file)); } return new Response($this->twig->render('@WebProfiler/Profiler/open.html.twig', array( 'filename' => $filename, 'file' => $file, 'line' => $line, )), 200, array('Content-Type' => 'text/html')); } /** * Gets the Template Manager. * * @return TemplateManager The Template Manager */ protected function getTemplateManager() { if (null === $this->templateManager) { $this->templateManager = new TemplateManager($this->profiler, $this->twig, $this->templates); } return $this->templateManager; } private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = array('Content-Type' => 'text/html')) { $response = new Response('', $code, $headers); $nonces = $this->cspHandler ? $this->cspHandler->getNonces($request, $response) : array(); $variables['csp_script_nonce'] = isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null; $variables['csp_style_nonce'] = isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null; $response->setContent($this->twig->render($template, $variables)); return $response; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php000066400000000000000000000063511324732107100304330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; use Twig\Environment; /** * RouterController. * * @author Fabien Potencier */ class RouterController { private $profiler; private $twig; private $matcher; private $routes; public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null) { $this->profiler = $profiler; $this->twig = $twig; $this->matcher = $matcher; $this->routes = (null === $routes && $matcher instanceof RouterInterface) ? $matcher->getRouteCollection() : $routes; } /** * Renders the profiler panel for the given token. * * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function panelAction($token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); if (null === $this->matcher || null === $this->routes) { return new Response('The Router is not enabled.', 200, array('Content-Type' => 'text/html')); } $profile = $this->profiler->loadProfile($token); /** @var RequestDataCollector $request */ $request = $profile->getCollector('request'); return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array( 'request' => $request, 'router' => $profile->getCollector('router'), 'traces' => $this->getTraces($request, $profile->getMethod()), )), 200, array('Content-Type' => 'text/html')); } /** * Returns the routing traces associated to the given request. * * @param RequestDataCollector $request * @param string $method * * @return array */ private function getTraces(RequestDataCollector $request, $method) { $traceRequest = Request::create( $request->getPathInfo(), $request->getRequestServer(true)->get('REQUEST_METHOD'), array(), $request->getRequestCookies(true)->all(), array(), $request->getRequestServer(true)->all() ); $context = $this->matcher->getContext(); $context->setMethod($method); $matcher = new TraceableUrlMatcher($this->routes, $context); return $matcher->getTracesForRequest($traceRequest); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Csp/000077500000000000000000000000001324732107100227735ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php000066400000000000000000000212731324732107100313310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Csp; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * Handles Content-Security-Policy HTTP header for the WebProfiler Bundle. * * @author Romain Neutron * * @internal */ class ContentSecurityPolicyHandler { private $nonceGenerator; private $cspDisabled = false; public function __construct(NonceGenerator $nonceGenerator) { $this->nonceGenerator = $nonceGenerator; } /** * Returns an array of nonces to be used in Twig templates and Content-Security-Policy headers. * * Nonce can be provided by; * - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin * - The response - A call to getNonces() has already been done previously. Same nonce are returned * - They are otherwise randomly generated * * @return array */ public function getNonces(Request $request, Response $response) { if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) { return array( 'csp_script_nonce' => $request->headers->get('X-SymfonyProfiler-Script-Nonce'), 'csp_style_nonce' => $request->headers->get('X-SymfonyProfiler-Style-Nonce'), ); } if ($response->headers->has('X-SymfonyProfiler-Script-Nonce') && $response->headers->has('X-SymfonyProfiler-Style-Nonce')) { return array( 'csp_script_nonce' => $response->headers->get('X-SymfonyProfiler-Script-Nonce'), 'csp_style_nonce' => $response->headers->get('X-SymfonyProfiler-Style-Nonce'), ); } $nonces = array( 'csp_script_nonce' => $this->generateNonce(), 'csp_style_nonce' => $this->generateNonce(), ); $response->headers->set('X-SymfonyProfiler-Script-Nonce', $nonces['csp_script_nonce']); $response->headers->set('X-SymfonyProfiler-Style-Nonce', $nonces['csp_style_nonce']); return $nonces; } /** * Disables Content-Security-Policy. * * All related headers will be removed. */ public function disableCsp() { $this->cspDisabled = true; } /** * Cleanup temporary headers and updates Content-Security-Policy headers. * * @return array Nonces used by the bundle in Content-Security-Policy header */ public function updateResponseHeaders(Request $request, Response $response) { if ($this->cspDisabled) { $this->removeCspHeaders($response); return array(); } $nonces = $this->getNonces($request, $response); $this->cleanHeaders($response); $this->updateCspHeaders($response, $nonces); return $nonces; } private function cleanHeaders(Response $response) { $response->headers->remove('X-SymfonyProfiler-Script-Nonce'); $response->headers->remove('X-SymfonyProfiler-Style-Nonce'); } private function removeCspHeaders(Response $response) { $response->headers->remove('X-Content-Security-Policy'); $response->headers->remove('Content-Security-Policy'); $response->headers->remove('Content-Security-Policy-Report-Only'); } /** * Updates Content-Security-Policy headers in a response. * * @return array */ private function updateCspHeaders(Response $response, array $nonces = array()) { $nonces = array_replace(array( 'csp_script_nonce' => $this->generateNonce(), 'csp_style_nonce' => $this->generateNonce(), ), $nonces); $ruleIsSet = false; $headers = $this->getCspHeaders($response); foreach ($headers as $header => $directives) { foreach (array('script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce') as $type => $tokenName) { if ($this->authorizesInline($directives, $type)) { continue; } if (!isset($headers[$header][$type])) { if (isset($headers[$header]['default-src'])) { $headers[$header][$type] = $headers[$header]['default-src']; } else { // If there is no script-src/style-src and no default-src, no additional rules required. continue; } } $ruleIsSet = true; if (!in_array('\'unsafe-inline\'', $headers[$header][$type], true)) { $headers[$header][$type][] = '\'unsafe-inline\''; } $headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]); } } if (!$ruleIsSet) { return $nonces; } foreach ($headers as $header => $directives) { $response->headers->set($header, $this->generateCspHeader($directives)); } return $nonces; } /** * Generates a valid Content-Security-Policy nonce. * * @return string */ private function generateNonce() { return $this->nonceGenerator->generate(); } /** * Converts a directive set array into Content-Security-Policy header. * * @param array $directives The directive set * * @return string The Content-Security-Policy header */ private function generateCspHeader(array $directives) { return array_reduce(array_keys($directives), function ($res, $name) use ($directives) { return ('' !== $res ? $res.'; ' : '').sprintf('%s %s', $name, implode(' ', $directives[$name])); }, ''); } /** * Converts a Content-Security-Policy header value into a directive set array. * * @param string $header The header value * * @return array The directive set */ private function parseDirectives($header) { $directives = array(); foreach (explode(';', $header) as $directive) { $parts = explode(' ', trim($directive)); if (count($parts) < 1) { continue; } $name = array_shift($parts); $directives[$name] = $parts; } return $directives; } /** * Detects if the 'unsafe-inline' is prevented for a directive within the directive set. * * @param array $directivesSet The directive set * @param string $type The name of the directive to check * * @return bool */ private function authorizesInline(array $directivesSet, $type) { if (isset($directivesSet[$type])) { $directives = $directivesSet[$type]; } elseif (isset($directivesSet['default-src'])) { $directives = $directivesSet['default-src']; } else { return false; } return in_array('\'unsafe-inline\'', $directives, true) && !$this->hasHashOrNonce($directives); } private function hasHashOrNonce(array $directives) { foreach ($directives as $directive) { if ('\'' !== substr($directive, -1)) { continue; } if ('\'nonce-' === substr($directive, 0, 7)) { return true; } if (in_array(substr($directive, 0, 8), array('\'sha256-', '\'sha384-', '\'sha512-'), true)) { return true; } } return false; } /** * Retrieves the Content-Security-Policy headers (either X-Content-Security-Policy or Content-Security-Policy) from * a response. * * @return array An associative array of headers */ private function getCspHeaders(Response $response) { $headers = array(); if ($response->headers->has('Content-Security-Policy')) { $headers['Content-Security-Policy'] = $this->parseDirectives($response->headers->get('Content-Security-Policy')); } if ($response->headers->has('Content-Security-Policy-Report-Only')) { $headers['Content-Security-Policy-Report-Only'] = $this->parseDirectives($response->headers->get('Content-Security-Policy-Report-Only')); } if ($response->headers->has('X-Content-Security-Policy')) { $headers['X-Content-Security-Policy'] = $this->parseDirectives($response->headers->get('X-Content-Security-Policy')); } return $headers; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Csp/NonceGenerator.php000066400000000000000000000010011324732107100264050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Csp; /** * Generates Content-Security-Policy nonce. * * @author Romain Neutron * * @internal */ class NonceGenerator { public function generate() { return bin2hex(random_bytes(16)); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/000077500000000000000000000000001324732107100261675ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php000066400000000000000000000034411324732107100315110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; /** * This class contains the configuration information for the bundle. * * This information is solely responsible for how the different configuration * sections are normalized, and merged. * * @author Fabien Potencier */ class Configuration implements ConfigurationInterface { /** * Generates the configuration tree builder. * * @return TreeBuilder The tree builder */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('web_profiler'); $rootNode ->children() ->booleanNode('toolbar')->defaultFalse()->end() ->scalarNode('position') ->defaultValue('bottom') ->setDeprecated('The "web_profiler.position" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0.') ->validate() ->ifNotInArray(array('bottom', 'top')) ->thenInvalid('The CSS position %s is not supported') ->end() ->end() ->booleanNode('intercept_redirects')->defaultFalse()->end() ->scalarNode('excluded_ajax_paths')->defaultValue('^/((index|app(_[\w]+)?)\.php/)?_wdt')->end() ->end() ; return $treeBuilder; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php000066400000000000000000000046561324732107100330300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; /** * WebProfilerExtension. * * Usage: * * * * @author Fabien Potencier */ class WebProfilerExtension extends Extension { /** * Loads the web profiler configuration. * * @param array $configs An array of configuration settings * @param ContainerBuilder $container A ContainerBuilder instance */ public function load(array $configs, ContainerBuilder $container) { $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('profiler.xml'); $container->setParameter('web_profiler.debug_toolbar.position', $config['position']); if ($config['toolbar'] || $config['intercept_redirects']) { $loader->load('toolbar.xml'); $container->getDefinition('web_profiler.debug_toolbar')->setPrivate(true); $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(5, $config['excluded_ajax_paths']); $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']); $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED); } } /** * Returns the base path for the XSD files. * * @return string The XSD base path */ public function getXsdValidationBasePath() { return __DIR__.'/../Resources/config/schema'; } public function getNamespace() { return 'http://symfony.com/schema/dic/webprofiler'; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/EventListener/000077500000000000000000000000001324732107100250355ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php000066400000000000000000000130741324732107100322700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\EventListener; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\Environment; /** * WebDebugToolbarListener injects the Web Debug Toolbar. * * The onKernelResponse method must be connected to the kernel.response event. * * The WDT is only injected on well-formed HTML (with a proper tag). * This means that the WDT is never included in sub-requests or ESI requests. * * @author Fabien Potencier */ class WebDebugToolbarListener implements EventSubscriberInterface { const DISABLED = 1; const ENABLED = 2; protected $twig; protected $urlGenerator; protected $interceptRedirects; protected $mode; protected $position; protected $excludedAjaxPaths; private $cspHandler; public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom', UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null) { $this->twig = $twig; $this->urlGenerator = $urlGenerator; $this->interceptRedirects = (bool) $interceptRedirects; $this->mode = (int) $mode; $this->position = $position; $this->excludedAjaxPaths = $excludedAjaxPaths; $this->cspHandler = $cspHandler; } public function isEnabled() { return self::DISABLED !== $this->mode; } public function onKernelResponse(FilterResponseEvent $event) { $response = $event->getResponse(); $request = $event->getRequest(); if ($response->headers->has('X-Debug-Token') && null !== $this->urlGenerator) { try { $response->headers->set( 'X-Debug-Token-Link', $this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')), UrlGeneratorInterface::ABSOLUTE_URL) ); } catch (\Exception $e) { $response->headers->set('X-Debug-Error', get_class($e).': '.preg_replace('/\s+/', ' ', $e->getMessage())); } } if (!$event->isMasterRequest()) { return; } $nonces = $this->cspHandler ? $this->cspHandler->updateResponseHeaders($request, $response) : array(); // do not capture redirects or modify XML HTTP Requests if ($request->isXmlHttpRequest()) { return; } if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) { $session = $request->getSession(); if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } $response->setContent($this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', array('location' => $response->headers->get('Location')))); $response->setStatusCode(200); $response->headers->remove('Location'); } if (self::DISABLED === $this->mode || !$response->headers->has('X-Debug-Token') || $response->isRedirection() || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) || 'html' !== $request->getRequestFormat() || false !== stripos($response->headers->get('Content-Disposition'), 'attachment;') ) { return; } $this->injectToolbar($response, $request, $nonces); } /** * Injects the web debug toolbar into the given Response. */ protected function injectToolbar(Response $response, Request $request, array $nonces) { $content = $response->getContent(); $pos = strripos($content, ''); if (false !== $pos) { $toolbar = "\n".str_replace("\n", '', $this->twig->render( '@WebProfiler/Profiler/toolbar_js.html.twig', array( 'position' => $this->position, 'excluded_ajax_paths' => $this->excludedAjaxPaths, 'token' => $response->headers->get('X-Debug-Token'), 'request' => $request, 'csp_script_nonce' => isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null, 'csp_style_nonce' => isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null, ) ))."\n"; $content = substr($content, 0, $pos).$toolbar.substr($content, $pos); $response->setContent($content); } } public static function getSubscribedEvents() { return array( KernelEvents::RESPONSE => array('onKernelResponse', -128), ); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/LICENSE000066400000000000000000000020511324732107100232510ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Profiler/000077500000000000000000000000001324732107100240305ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php000066400000000000000000000072041324732107100276120ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Profiler; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpKernel\Profiler\Profile; use Twig\Environment; use Twig\Error\LoaderError; use Twig\Loader\ExistsLoaderInterface; use Twig\Loader\SourceContextLoaderInterface; use Twig\Template; /** * Profiler Templates Manager. * * @author Fabien Potencier * @author Artur Wielogórski */ class TemplateManager { protected $twig; protected $templates; protected $profiler; public function __construct(Profiler $profiler, Environment $twig, array $templates) { $this->profiler = $profiler; $this->twig = $twig; $this->templates = $templates; } /** * Gets the template name for a given panel. * * @param Profile $profile * @param string $panel * * @return mixed * * @throws NotFoundHttpException */ public function getName(Profile $profile, $panel) { $templates = $this->getNames($profile); if (!isset($templates[$panel])) { throw new NotFoundHttpException(sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel)); } return $templates[$panel]; } /** * Gets the templates for a given profile. * * @return Template[] * * @deprecated not used anymore internally */ public function getTemplates(Profile $profile) { $templates = $this->getNames($profile); foreach ($templates as $name => $template) { $templates[$name] = $this->twig->loadTemplate($template); } return $templates; } /** * Gets template names of templates that are present in the viewed profile. * * @return array * * @throws \UnexpectedValueException */ public function getNames(Profile $profile) { $templates = array(); foreach ($this->templates as $arguments) { if (null === $arguments) { continue; } list($name, $template) = $arguments; if (!$this->profiler->has($name) || !$profile->hasCollector($name)) { continue; } if ('.html.twig' === substr($template, -10)) { $template = substr($template, 0, -10); } if (!$this->templateExists($template.'.html.twig')) { throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name)); } $templates[$name] = $template.'.html.twig'; } return $templates; } // to be removed when the minimum required version of Twig is >= 2.0 protected function templateExists($template) { $loader = $this->twig->getLoader(); if ($loader instanceof ExistsLoaderInterface) { return $loader->exists($template); } try { if ($loader instanceof SourceContextLoaderInterface || method_exists($loader, 'getSourceContext')) { $loader->getSourceContext($template); } else { $loader->getSource($template); } return true; } catch (LoaderError $e) { } return false; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/README.md000066400000000000000000000005251324732107100235270ustar00rootroot00000000000000WebProfilerBundle ================= Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/000077500000000000000000000000001324732107100242205ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/ICONS_LICENSE.txt000066400000000000000000000002671324732107100270030ustar00rootroot00000000000000Icons License ============= Icons created by Sensio (http://www.sensio.com/) are shared under a Creative Commons Attribution license (http://creativecommons.org/licenses/by-sa/3.0/).symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/000077500000000000000000000000001324732107100254655ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml000066400000000000000000000062751324732107100300430ustar00rootroot00000000000000 %data_collector.templates% %web_profiler.debug_toolbar.position% %kernel.project_dir% %kernel.debug% null %kernel.charset% Symfony\Component\VarDumper\Dumper\HtmlDumper::DUMP_LIGHT_ARRAY 4096 %debug.file_link_format% %kernel.project_dir% /_profiler/open?file=%%f&line=%%l#line%%l symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/000077500000000000000000000000001324732107100271545ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml000066400000000000000000000035231324732107100315230ustar00rootroot00000000000000 web_profiler.controller.profiler:homeAction web_profiler.controller.profiler:searchAction web_profiler.controller.profiler:searchBarAction web_profiler.controller.profiler:phpinfoAction web_profiler.controller.profiler:searchResultsAction web_profiler.controller.profiler:openAction web_profiler.controller.profiler:panelAction web_profiler.controller.router:panelAction web_profiler.controller.exception:showAction web_profiler.controller.exception:cssAction symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml000066400000000000000000000006351324732107100305000ustar00rootroot00000000000000 web_profiler.controller.profiler:toolbarAction symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/schema/000077500000000000000000000000001324732107100267255ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/schema/webprofiler-1.0.xsd000066400000000000000000000014231324732107100322610ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml000066400000000000000000000020461324732107100276530ustar00rootroot00000000000000 %web_profiler.debug_toolbar.intercept_redirects% %web_profiler.debug_toolbar.mode% %web_profiler.debug_toolbar.position% symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/000077500000000000000000000000001324732107100253555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/000077500000000000000000000000001324732107100273035ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/ajax.html.twig000066400000000000000000000020001324732107100320550ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% set icon %} {{ include('@WebProfiler/Icon/ajax.svg') }} 0 {% endset %} {% set text %}
Method Type Status URL Time Profile
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig000066400000000000000000000153501324732107100322110ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% if collector.totals.calls > 0 %} {% set icon %} {{ include('@WebProfiler/Icon/cache.svg') }} {{ collector.totals.calls }} in {{ '%0.2f'|format(collector.totals.time * 1000) }} ms {% endset %} {% set text %}
Cache Calls {{ collector.totals.calls }}
Total time {{ '%0.2f'|format(collector.totals.time * 1000) }} ms
Cache hits {{ collector.totals.hits }} / {{ collector.totals.reads }}{% if collector.totals.hit_read_ratio is not null %} ({{ collector.totals.hit_read_ratio }}%){% endif %}
Cache writes {{ collector.totals.writes }}
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }} {% endif %} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/cache.svg') }} Cache {% endblock %} {% block panel %}

Cache

{% if collector.totals.calls == 0 %}

No cache calls were made.

{% else %}
{{ collector.totals.calls }} Total calls
{{ '%0.2f'|format(collector.totals.time * 1000) }} ms Total time
{{ collector.totals.reads }} Total reads
{{ collector.totals.writes }} Total writes
{{ collector.totals.deletes }} Total deletes
{{ collector.totals.hits }} Total hits
{{ collector.totals.misses }} Total misses
{{ collector.totals.hit_read_ratio ?? 0 }} % Hits/reads

Pools

{% for name, calls in collector.calls %}

{{ name }} {{ collector.statistics[name].calls }}

{% if calls|length == 0 %}

No calls were made for {{ name }} pool.

{% else %}

Metrics

{% for key, value in collector.statistics[name] %}
{% if key == 'time' %} {{ '%0.2f'|format(1000 * value.value) }} ms {% elseif key == 'hit_read_ratio' %} {{ value.value ?? 0 }} % {% else %} {{ value }} {% endif %} {{ key == 'hit_read_ratio' ? 'Hits/reads' : key|capitalize }}
{% if key == 'time' or key == 'deletes' %}
{% endif %} {% endfor %}

Calls

{% for call in calls %} {% endfor %}
# Time Call Hit
{{ loop.index }} {{ '%0.2f'|format((call.end - call.start) * 1000) }} ms {{ call.name }}() {{ profiler_dump(call.value.result, maxDepth=2) }}
{% endif %}
{% endfor %}
{% endif %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig000066400000000000000000000262331324732107100324150ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% if 'unknown' == collector.symfonyState %} {% set block_status = '' %} {% set symfony_version_status = 'Unable to retrieve information about the Symfony version.' %} {% elseif 'eol' == collector.symfonyState %} {% set block_status = 'red' %} {% set symfony_version_status = 'This Symfony version will no longer receive security fixes.' %} {% elseif 'eom' == collector.symfonyState %} {% set block_status = 'yellow' %} {% set symfony_version_status = 'This Symfony version will only receive security fixes.' %} {% elseif 'dev' == collector.symfonyState %} {% set block_status = 'yellow' %} {% set symfony_version_status = 'This Symfony version is still in the development phase.' %} {% else %} {% set block_status = '' %} {% set symfony_version_status = '' %} {% endif %} {% set icon %} {% if collector.applicationname %} {{ collector.applicationname }} {{ collector.applicationversion }} {% elseif collector.symfonyState is defined %} {{ include('@WebProfiler/Icon/symfony.svg') }} {{ collector.symfonyversion }} {% endif %} {% endset %} {% set text %}
{% if collector.applicationname %}
{{ collector.applicationname }} {{ collector.applicationversion }}
{% endif %}
Profiler token {% if profiler_url %} {{ collector.token }} {% else %} {{ collector.token }} {% endif %}
{% if 'n/a' is not same as(collector.appname) %}
Kernel name {{ collector.appname }}
{% endif %} {% if 'n/a' is not same as(collector.env) %}
Environment {{ collector.env }}
{% endif %} {% if 'n/a' is not same as(collector.debug) %}
Debug {{ collector.debug ? 'enabled' : 'disabled' }}
{% endif %}
PHP version {{ collector.phpversion }}   View phpinfo()
PHP Extensions xdebug APCu OPcache
PHP SAPI {{ collector.sapiName }}
{% if collector.symfonyversion is defined %}
Resources {% if 'Silex' == collector.applicationname %} Read Silex Docs {% else %} Read Symfony {{ collector.symfonyversion }} Docs {% endif %}
{% endif %}
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status, additional_classes: 'sf-toolbar-block-right', block_attrs: 'title="' ~ symfony_version_status ~ '"' }) }} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/config.svg') }} Configuration {% endblock %} {% block panel %} {% if collector.applicationname %} {# this application is not the Symfony framework #}

Project Configuration

{{ collector.applicationname }} Application name
{{ collector.applicationversion }} Application version

Based on Symfony {{ collector.symfonyversion }}

{% else %}

Symfony Configuration

{{ collector.symfonyversion }} Symfony version
{% if 'n/a' != collector.appname %}
{{ collector.appname }} Application name
{% endif %} {% if 'n/a' != collector.env %}
{{ collector.env }} Environment
{% endif %} {% if 'n/a' != collector.debug %}
{{ collector.debug ? 'enabled' : 'disabled' }} Debug
{% endif %}
{% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %} {% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %}
Symfony Status Bugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed until Security issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until
{{ symfony_status[collector.symfonystate]|upper }} {{ collector.symfonyeom }} {{ collector.symfonyeol }} View roadmap
{% endif %}

PHP Configuration

{{ collector.phpversion }}{% if collector.phpversionextra %} {{ collector.phpversionextra }}{% endif %} PHP version
{{ collector.phparchitecture }} bits Architecture
{{ collector.phpintllocale }} Intl locale
{{ collector.phptimezone }} Timezone
{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }} OPcache
{{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }} APCu
{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }} Xdebug

View full PHP configuration

{% if collector.bundles %}

Enabled Bundles ({{ collector.bundles|length }})

{% for name in collector.bundles|keys|sort %} {% endfor %}
Name Path
{{ name }} {{ profiler_dump(collector.bundles[name]) }}
{% endif %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig000066400000000000000000000056071324732107100324560ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% import _self as helper %} {% block menu %} {{ include('@WebProfiler/Icon/event.svg') }} Events {% endblock %} {% block panel %}

Event Dispatcher

{% if collector.calledlisteners is empty %}

No events have been recorded. Check that debugging is enabled in the kernel.

{% else %}

Called Listeners {{ collector.calledlisteners|length }}

{{ helper.render_table(collector.calledlisteners) }}

Not Called Listeners {{ collector.notcalledlisteners|length }}

{% if collector.notcalledlisteners is empty %}

There are no uncalled listeners.

All listeners were called for this request or an error occurred when trying to collect uncalled listeners (in which case check the logs to get more information).

{% else %} {{ helper.render_table(collector.notcalledlisteners) }} {% endif %}
{% endif %} {% endblock %} {% macro render_table(listeners) %} {% set previous_event = (listeners|first).event %} {% for listener in listeners %} {% if loop.first or listener.event != previous_event %} {% if not loop.first %} {% endif %} {% set previous_event = listener.event %} {% endif %} {% if loop.last %} {% endif %} {% endfor %}
Priority Listener
{{ listener.event }}
{{ listener.priority|default('-') }} {{ profiler_dump(listener.stub) }}
{% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig000066400000000000000000000010621324732107100327630ustar00rootroot00000000000000{{ include('@Twig/exception.css.twig') }} .container { max-width: auto; margin: 0; padding: 0; } .container .container { padding: 0; } .exception-summary { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0 0 1px rgba(128, 128, 128, .2); margin: 1em 0; padding: 10px; } .exception-summary.exception-without-message { display: none; } .exception-message { color: #B0413E; } .exception-metadata, .exception-illustration { display: none; } .exception-message-wrapper .container { min-height: auto; } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig000066400000000000000000000020061324732107100331360ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block head %} {% if collector.hasexception %} {% endif %} {{ parent() }} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/exception.svg') }} Exception {% if collector.hasexception %} 1 {% endif %} {% endblock %} {% block panel %}

Exceptions

{% if not collector.hasexception %}

No exception was thrown and caught during the request.

{% else %}
{{ render(path('_profiler_exception', { token: token })) }}
{% endif %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig000066400000000000000000000606341324732107100321160ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% from _self import form_tree_entry, form_tree_details %} {% block toolbar %} {% if collector.data.nb_errors > 0 or collector.data.forms|length %} {% set status_color = collector.data.nb_errors ? 'red' : '' %} {% set icon %} {{ include('@WebProfiler/Icon/form.svg') }} {{ collector.data.nb_errors ?: collector.data.forms|length }} {% endset %} {% set text %}
Number of forms {{ collector.data.forms|length }}
Number of errors {{ collector.data.nb_errors }}
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/form.svg') }} Forms {% if collector.data.nb_errors > 0 %} {{ collector.data.nb_errors }} {% endif %} {% endblock %} {% block head %} {{ parent() }} {% endblock %} {% block panel %}

Forms

{% if collector.data.forms|length %}
    {% for formName, formData in collector.data.forms %} {{ form_tree_entry(formName, formData, true) }} {% endfor %}
{% for formName, formData in collector.data.forms %} {{ form_tree_details(formName, formData, collector.data.forms_by_hash, loop.first) }} {% endfor %}
{% else %}

No forms were submitted for this request.

{% endif %} {% endblock %} {% macro form_tree_entry(name, data, is_root) %} {% import _self as tree %} {% set has_error = data.errors is defined and data.errors|length > 0 %}
  • {% if has_error %}
    {{ data.errors|length }}
    {% endif %} {% if data.children is not empty %} {% else %}
    {% endif %} {{ name|default('(no name)') }}
    {% if data.children is not empty %}
      {% for childName, childData in data.children %} {{ tree.form_tree_entry(childName, childData, false) }} {% endfor %}
    {% endif %}
  • {% endmacro %} {% macro form_tree_details(name, data, forms_by_hash, show) %} {% import _self as tree %}

    {{ name|default('(no name)') }} {% if data.type_class is defined %}({{ profiler_dump(data.type_class) }}){% endif %}

    {% if data.errors is defined and data.errors|length > 0 %}

    Errors

    {% for error in data.errors %} {% endfor %}
    Message Origin Cause
    {{ error.message }} {% if error.origin is empty %} This form. {% elseif forms_by_hash[error.origin] is not defined %} Unknown. {% else %} {{ forms_by_hash[error.origin].name }} {% endif %} {% if error.trace %} Caused by: {% for stacked in error.trace %} {{ profiler_dump(stacked) }} {% endfor %} {% else %} Unknown. {% endif %}
    {% endif %} {% if data.default_data is defined %}

    Default Data

    Property Value
    Model Format {% if data.default_data.model is defined %} {{ profiler_dump(data.default_data.seek('model')) }} {% else %} same as normalized format {% endif %}
    Normalized Format {{ profiler_dump(data.default_data.seek('norm')) }}
    View Format {% if data.default_data.view is defined %} {{ profiler_dump(data.default_data.seek('view')) }} {% else %} same as normalized format {% endif %}
    {% endif %} {% if data.submitted_data is defined %}

    Submitted Data

    {% if data.submitted_data.norm is defined %}
    Property Value
    View Format {% if data.submitted_data.view is defined %} {{ profiler_dump(data.submitted_data.seek('view')) }} {% else %} same as normalized format {% endif %}
    Normalized Format {{ profiler_dump(data.submitted_data.seek('norm')) }}
    Model Format {% if data.submitted_data.model is defined %} {{ profiler_dump(data.submitted_data.seek('model')) }} {% else %} same as normalized format {% endif %}
    {% else %}

    This form was not submitted.

    {% endif %}
    {% endif %} {% if data.passed_options is defined %}

    Passed Options

    {% if data.passed_options|length %} {% for option, value in data.passed_options %} {% endfor %}
    Option Passed Value Resolved Value
    {{ option }} {{ profiler_dump(value) }} {# values can be stubs #} {% set option_value = value.value|default(value) %} {% set resolved_option_value = data.resolved_options[option].value|default(data.resolved_options[option]) %} {% if resolved_option_value == option_value %} same as passed value {% else %} {{ profiler_dump(data.resolved_options.seek(option)) }} {% endif %}
    {% else %}

    No options where passed when constructing this form.

    {% endif %}
    {% endif %} {% if data.resolved_options is defined %}

    Resolved Options

    {% endif %} {% if data.view_vars is defined %}

    View Variables

    {% endif %}
    {% for childName, childData in data.children %} {{ tree.form_tree_details(childName, childData, forms_by_hash) }} {% endfor %} {% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig000066400000000000000000000271251324732107100324300ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% import _self as helper %} {% block toolbar %} {% if collector.counterrors or collector.countdeprecations or collector.countwarnings %} {% set icon %} {% set status_color = collector.counterrors ? 'red' : 'yellow' %} {{ include('@WebProfiler/Icon/logger.svg') }} {{ collector.counterrors ?: (collector.countdeprecations + collector.countwarnings) }} {% endset %} {% set text %}
    Errors {{ collector.counterrors|default(0) }}
    Warnings {{ collector.countwarnings|default(0) }}
    Deprecations {{ collector.countdeprecations|default(0) }}
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/logger.svg') }} Logs {% if collector.counterrors or collector.countdeprecations or collector.countwarnings %} {{ collector.counterrors ?: (collector.countdeprecations + collector.countwarnings) }} {% endif %} {% endblock %} {% block panel %}

    Log Messages

    {% if collector.logs is empty %}

    No log messages available.

    {% else %} {# sort collected logs in groups #} {% set deprecation_logs, debug_logs, info_and_error_logs, silenced_logs = [], [], [], [] %} {% for log in collector.logs %} {% if log.scream is defined and not log.scream %} {% set deprecation_logs = deprecation_logs|merge([log]) %} {% elseif log.scream is defined and log.scream %} {% set silenced_logs = silenced_logs|merge([log]) %} {% elseif log.priorityName == 'DEBUG' %} {% set debug_logs = debug_logs|merge([log]) %} {% else %} {% set info_and_error_logs = info_and_error_logs|merge([log]) %} {% endif %} {% endfor %}

    Info. & Errors {{ collector.counterrors ?: info_and_error_logs|length }}

    Informational and error log messages generated during the execution of the application.

    {% if info_and_error_logs is empty %}

    There are no log messages of this level.

    {% else %} {{ helper.render_table(info_and_error_logs, 'info', true) }} {% endif %}
    {# 'deprecation_logs|length' is not used because deprecations are now grouped and the group count doesn't match the message count #}

    Deprecations {{ collector.countdeprecations|default(0) }}

    Log messages generated by using features marked as deprecated.

    {% if deprecation_logs is empty %}

    There are no log messages about deprecated features.

    {% else %} {{ helper.render_table(deprecation_logs, 'deprecation', false, true) }} {% endif %}

    Debug {{ debug_logs|length }}

    Unimportant log messages generated during the execution of the application.

    {% if debug_logs is empty %}

    There are no log messages of this level.

    {% else %} {{ helper.render_table(debug_logs, 'debug') }} {% endif %}

    PHP Notices {{ collector.countscreams|default(0) }}

    Log messages generated by PHP notices silenced with the @ operator.

    {% if silenced_logs is empty %}

    There are no log messages of this level.

    {% else %} {{ helper.render_table(silenced_logs, 'silenced') }} {% endif %}
    {% set compilerLogTotal = 0 %} {% for logs in collector.compilerLogs %} {% set compilerLogTotal = compilerLogTotal + logs|length %} {% endfor %}

    Container {{ compilerLogTotal }}

    Log messages generated during the compilation of the service container.

    {% if collector.compilerLogs is empty %}

    There are no compiler log messages.

    {% else %} {% for class, logs in collector.compilerLogs %} {% endfor %}
    Class Messages
    {% set context_id = 'context-compiler-' ~ loop.index %} {{ class }}
      {% for log in logs %}
    • {{ profiler_dump_log(log.message) }}
    • {% endfor %}
    {{ logs|length }}
    {% endif %}
    {% endif %} {% endblock %} {% macro render_table(logs, category = '', show_level = false, is_deprecation = false) %} {% import _self as helper %} {% set channel_is_defined = (logs|first).channel is defined %} {% if channel_is_defined %}{% endif %} {% for log in logs %} {% set css_class = is_deprecation ? '' : log.priorityName in ['CRITICAL', 'ERROR', 'ALERT', 'EMERGENCY'] ? 'status-error' : log.priorityName == 'WARNING' ? 'status-warning' %} {% if channel_is_defined %} {% endif %} {% endfor %}
    {{ show_level ? 'Level' : 'Time' }}ChannelMessage
    {% if show_level %} {{ log.priorityName }} {% endif %} {{ log.timestamp|date('H:i:s') }} {{ log.channel }} {% if log.errorCount is defined and log.errorCount > 1 %} ({{ log.errorCount }} times) {% endif %} {{ helper.render_log_message(category, loop.index, log) }}
    {% endmacro %} {% macro render_log_message(category, log_index, log) %} {% set has_context = log.context is defined and log.context is not empty %} {% set has_trace = log.context.exception.trace is defined %} {% if not has_context %} {{ profiler_dump_log(log.message) }} {% else %} {{ profiler_dump_log(log.message, log.context) }}
    {% set context_id = 'context-' ~ category ~ '-' ~ log_index %} Show context {% if has_trace %}    {% set trace_id = 'trace-' ~ category ~ '-' ~ log_index %} Show trace {% endif %}
    {{ profiler_dump(log.context, maxDepth=1) }}
    {% if has_trace %}
    {{ profiler_dump(log.context.exception.trace, maxDepth=1) }}
    {% endif %} {% endif %} {% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig000066400000000000000000000017241324732107100324560ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% set icon %} {% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' : '' %} {{ include('@WebProfiler/Icon/memory.svg') }} {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB {% endset %} {% set text %}
    Peak memory usage {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB
    PHP memory limit {{ collector.memoryLimit == -1 ? 'Unlimited' : '%.0f MB'|format(collector.memoryLimit / 1024 / 1024) }}
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, name: 'time', status: status_color }) }} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig000066400000000000000000000273561324732107100326470ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% import _self as helper %} {% set request_handler %} {{ helper.set_handler(collector.controller) }} {% endset %} {% if collector.redirect %} {% set redirect_handler %} {{ helper.set_handler(collector.redirect.controller, collector.redirect.route, 'GET' != collector.redirect.method ? collector.redirect.method) }} {% endset %} {% endif %} {% if collector.forward|default(false) %} {% set forward_handler %} {{ helper.set_handler(collector.forward.controller) }} {% endset %} {% endif %} {% set request_status_code_color = (collector.statuscode >= 400) ? 'red' : (collector.statuscode >= 300) ? 'yellow' : 'green' %} {% set icon %} {{ collector.statuscode }} {% if collector.route %} {% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %} {% if collector.forward|default(false) %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %} {{ 'GET' != collector.method ? collector.method }} @ {{ collector.route }} {% endif %} {% endset %} {% set text %}
    HTTP status {{ collector.statuscode }} {{ collector.statustext }}
    {% if 'GET' != collector.method -%}
    Method {{ collector.method }}
    {%- endif %}
    Controller {{ request_handler }}
    {% if collector.controller.class is defined -%}
    Controller class {{ collector.controller.class }}
    {%- endif %}
    Route name {{ collector.route|default('n/a') }}
    Has session {% if collector.sessionmetadata|length %}yes{% else %}no{% endif %}
    {% if redirect_handler is defined -%}
    {{ collector.redirect.status_code }} Redirect from {{ redirect_handler }} ({{ collector.redirect.token }})
    {% endif %} {% if forward_handler is defined %}
    Forwarded to {{ forward_handler }} ({{ collector.forward.token }})
    {% endif %} {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/request.svg') }} Request / Response {% endblock %} {% block panel %} {% import _self as helper %}

    {{ helper.set_handler(collector.controller) }}

    Request

    GET Parameters

    {% if collector.requestquery.all is empty %}

    No GET parameters

    {% else %} {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestquery, maxDepth: 1 }, with_context = false) }} {% endif %}

    POST Parameters

    {% if collector.requestrequest.all is empty %}

    No POST parameters

    {% else %} {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestrequest, maxDepth: 1 }, with_context = false) }} {% endif %}

    Request Attributes

    {% if collector.requestattributes.all is empty %}

    No attributes

    {% else %} {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestattributes }, with_context = false) }} {% endif %}

    Request Headers

    {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }}

    Request Content

    {% if collector.content == false %}

    Request content not available (it was retrieved as a resource).

    {% elseif collector.content %}
    {{ collector.content }}
    {% else %}

    No content

    {% endif %}

    Server Parameters

    {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestserver }, with_context = false) }}

    Response

    Response Headers

    {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responseheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }}

    Cookies

    Request Cookies

    {% if collector.requestcookies.all is empty %}

    No request cookies

    {% else %} {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }} {% endif %}

    Response Cookies

    {% if collector.responsecookies.all is empty %}

    No response cookies

    {% else %} {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responsecookies }, with_context = true) }} {% endif %}

    Flashes

    Flashes

    {% if collector.flashes is empty %}

    No flash messages were created.

    {% else %} {{ include('@WebProfiler/Profiler/table.html.twig', { data: collector.flashes }, with_context = false) }} {% endif %}
    {% if profile.parent %}

    Parent Request

    Return to parent request (token = {{ profile.parent.token }})

    {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: profile.parent.getcollector('request').requestattributes }, with_context = false) }}
    {% endif %} {% if profile.children|length %}

    Sub Requests {{ profile.children|length }}

    {% for child in profile.children %}

    {{ helper.set_handler(child.getcollector('request').controller) }} (token = {{ child.token }})

    {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: child.getcollector('request').requestattributes }, with_context = false) }} {% endfor %}
    {% endif %}
    {% endblock %} {% macro set_handler(controller, route, method) %} {% if controller.class is defined -%} {%- if method|default(false) %}{{ method }}{% endif -%} {%- set link = controller.file|file_link(controller.line) %} {%- if link %}{% else %}{% endif %} {%- if route|default(false) -%} @{{ route }} {%- else -%} {{- controller.class|abbr_class|striptags -}} {{- controller.method ? ' :: ' ~ controller.method -}} {%- endif -%} {%- if link %}{% else %}{% endif %} {%- else -%} {{ route|default(controller) }} {%- endif %} {% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig000066400000000000000000000005401324732107100324610ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %}{% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/router.svg') }} Routing {% endblock %} {% block panel %} {{ render(path('_profiler_router', { token: token })) }} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig000066400000000000000000000513221324732107100321030ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% import _self as helper %} {% if colors is not defined %} {% set colors = { 'default': '#999', 'section': '#444', 'event_listener': '#00B8F5', 'event_listener_loading': '#00B8F5', 'template': '#66CC00', 'doctrine': '#FF6633', 'propel': '#FF6633', } %} {% endif %} {% block toolbar %} {% set has_time_events = collector.events|length > 0 %} {% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %} {% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %} {% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' : '' %} {% set icon %} {{ include('@WebProfiler/Icon/time.svg') }} {{ total_time }} ms {% endset %} {% set text %}
    Total time {{ total_time }} ms
    Initialization time {{ initialization_time }} ms
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/time.svg') }} Performance {% endblock %} {% block panel %} {% set has_time_events = collector.events|length > 0 %}

    Performance metrics

    {{ '%.0f'|format(collector.duration) }} ms Total execution time
    {{ '%.0f'|format(collector.inittime) }} ms Symfony initialization
    {% if profile.collectors.memory %}
    {{ '%.2f'|format(profile.collectors.memory.memory / 1024 / 1024) }} MB Peak memory usage
    {% endif %} {% if profile.children|length > 0 %}
    {{ profile.children|length }} Sub-Request{{ profile.children|length > 1 ? 's' }}
    {% if has_time_events %} {% set subrequests_time = 0 %} {% for child in profile.children %} {% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %} {% endfor %} {% else %} {% set subrequests_time = 'n/a' %} {% endif %}
    {{ subrequests_time }} ms Sub-Request{{ profile.children|length > 1 ? 's' }} time
    {% endif %}

    Execution timeline

    {% if collector.events is empty %}

    No timing events have been recorded. Are you sure that debugging is enabled in the kernel?

    {% else %} {{ block('panelContent') }} {% endif %} {% endblock %} {% block panelContent %}
    ms (timeline only displays events with a duration longer than this threshold)
    {% if profile.parent %}

    Sub-Request {{ profiler_dump(profile.getcollector('request').requestattributes.get('_controller')) }} {{ collector.events.__section__.duration }} ms Return to parent request

    {% elseif profile.children|length > 0 %}

    Main Request {{ collector.events.__section__.duration }} ms

    {% endif %} {{ helper.display_timeline('timeline_' ~ token, collector.events, colors) }} {% if profile.children|length %}

    Note: sections with a striped background correspond to sub-requests.

    Sub-requests ({{ profile.children|length }})

    {% for child in profile.children %} {% set events = child.getcollector('time').events %}

    {{ child.getcollector('request').identifier }} {{ events.__section__.duration }} ms

    {{ helper.display_timeline('timeline_' ~ child.token, events, colors) }} {% endfor %} {% endif %} {% endblock %} {% macro dump_request_data(token, profile, events, origin) %} {% autoescape 'js' %} {% from _self import dump_events %} { "id": "{{ token }}", "left": {{ "%F"|format(events.__section__.origin - origin) }}, "events": [ {{ dump_events(events) }} ] } {% endautoescape %} {% endmacro %} {% macro dump_events(events) %} {% autoescape 'js' %} {% for name, event in events %} {% if '__section__' != name %} { "name": "{{ name }}", "category": "{{ event.category }}", "origin": {{ "%F"|format(event.origin) }}, "starttime": {{ "%F"|format(event.starttime) }}, "endtime": {{ "%F"|format(event.endtime) }}, "duration": {{ "%F"|format(event.duration) }}, "memory": {{ "%.1F"|format(event.memory / 1024 / 1024) }}, "periods": [ {%- for period in event.periods -%} {"start": {{ "%F"|format(period.starttime) }}, "end": {{ "%F"|format(period.endtime) }}}{{ loop.last ? '' : ', ' }} {%- endfor -%} ] }{{ loop.last ? '' : ',' }} {% endif %} {% endfor %} {% endautoescape %} {% endmacro %} {% macro display_timeline(id, events, colors) %}
    {% for category, color in colors %} {{ category }} {% endfor %}
    {% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig000066400000000000000000000212001324732107100334730ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% import _self as helper %} {% block toolbar %} {% if collector.messages|length %} {% set icon %} {{ include('@WebProfiler/Icon/translation.svg') }} {% set status_color = collector.countMissings ? 'red' : collector.countFallbacks ? 'yellow' %} {% set error_count = collector.countMissings + collector.countFallbacks %} {{ error_count ?: collector.countDefines }} {% endset %} {% set text %}
    Locale {{ collector.locale|default('-') }}
    Missing messages {{ collector.countMissings }}
    Fallback messages {{ collector.countFallbacks }}
    Defined messages {{ collector.countDefines }}
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/translation.svg') }} Translation {% if collector.countMissings or collector.countFallbacks %} {% set error_count = collector.countMissings + collector.countFallbacks %} {{ error_count }} {% endif %} {% endblock %} {% block panel %} {% if collector.messages is empty %}

    Translations

    No translations have been called.

    {% else %} {{ block('panelContent') }} {% endif %} {% endblock %} {% block panelContent %}

    Translation Locales

    {{ collector.locale|default('-') }} Locale
    {{ collector.fallbackLocales|join(', ')|default('-') }} Fallback locales

    Translation Metrics

    {{ collector.countDefines }} Defined messages
    {{ collector.countFallbacks }} Fallback messages
    {{ collector.countMissings }} Missing messages

    Translation Messages

    {% block messages %} {# sort translation messages in groups #} {% set messages_defined, messages_missing, messages_fallback = [], [], [] %} {% for message in collector.messages %} {% if message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_DEFINED') %} {% set messages_defined = messages_defined|merge([message]) %} {% elseif message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_MISSING') %} {% set messages_missing = messages_missing|merge([message]) %} {% elseif message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK') %} {% set messages_fallback = messages_fallback|merge([message]) %} {% endif %} {% endfor %}

    Defined {{ collector.countDefines }}

    These messages are correctly translated into the given locale.

    {% if messages_defined is empty %}

    None of the used translation messages are defined for the given locale.

    {% else %} {% block defined_messages %} {{ helper.render_table(messages_defined) }} {% endblock %} {% endif %}

    Fallback {{ collector.countFallbacks }}

    These messages are not available for the given locale but Symfony found them in the fallback locale catalog.

    {% if messages_fallback is empty %}

    No fallback translation messages were used.

    {% else %} {% block fallback_messages %} {{ helper.render_table(messages_fallback) }} {% endblock %} {% endif %}

    Missing {{ collector.countMissings }}

    These messages are not available for the given locale and cannot be found in the fallback locales. Add them to the translation catalogue to avoid Symfony outputting untranslated contents.

    {% if messages_missing is empty %}

    There are no messages of this category.

    {% else %} {% block missing_messages %} {{ helper.render_table(messages_missing) }} {% endblock %} {% endif %}
    {% endblock messages %} {% endblock %} {% macro render_table(messages) %} {% for message in messages %} {% endfor %}
    Locale Domain Times used Message ID Message Preview
    {{ message.locale }} {{ message.domain }} {{ message.count }} {{ message.id }} {% if message.transChoiceNumber is not null %} (pluralization is used) {% endif %} {% if message.parameters|length > 0 %} {% endif %} {{ message.translation }}
    {% endmacro %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig000066400000000000000000000065311324732107100321210ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% set time = collector.templatecount ? '%0.0f'|format(collector.time) : 'n/a' %} {% set icon %} {{ include('@WebProfiler/Icon/twig.svg') }} {{ time }} ms {% endset %} {% set text %}
    Render Time {{ time }} ms
    Template Calls {{ collector.templatecount }}
    Block Calls {{ collector.blockcount }}
    Macro Calls {{ collector.macrocount }}
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/twig.svg') }} Twig {% endblock %} {% block panel %} {% if collector.templatecount == 0 %}

    Twig

    No Twig templates were rendered for this request.

    {% else %}

    Twig Metrics

    {{ '%0.0f'|format(collector.time) }} ms Render time
    {{ collector.templatecount }} Template calls
    {{ collector.blockcount }} Block calls
    {{ collector.macrocount }} Macro calls

    Render time includes sub-requests rendering time (if any).

    Rendered Templates

    {% for template, count in collector.templates %} {%- set file = collector.templatePaths[template]|default(false) -%} {%- set link = file ? file|file_link(1) : false -%} {% endfor %}
    Template Name Render Count
    {% if link %}{{ template }}{% else %}{{ template }}{% endif %} {{ count }}

    Rendering Call Graph

    {{ collector.htmlcallgraph }}
    {% endif %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/validator.html.twig000066400000000000000000000076671324732107100331470ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% if collector.violationsCount > 0 or collector.calls|length %} {% set status_color = collector.violationsCount ? 'red' : '' %} {% set icon %} {{ include('@WebProfiler/Icon/validator.svg') }} {{ collector.violationsCount ?: collector.calls|length }} {% endset %} {% set text %}
    Validator calls {{ collector.calls|length }}
    Number of violations {{ collector.violationsCount }}
    {% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} {% block menu %} {{ include('@WebProfiler/Icon/validator.svg') }} Validator {% if collector.violationsCount > 0 %} {{ collector.violationsCount }} {% endif %} {% endblock %} {% block panel %}

    Validator calls

    {% for call in collector.calls %}
    {% if call.violations|length %} {% for violation in call.violations %} {% endfor %}
    Path Message Invalid value Violation
    {{ violation.propertyPath }} {{ violation.message }} {{ profiler_dump(violation.seek('invalidValue')) }} {{ profiler_dump(violation) }}
    {% else %} No violations {% endif %}
    {% else %}

    No calls to the validator were collected during this request.

    {% endfor %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/000077500000000000000000000000001324732107100262455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg000066400000000000000000000010751324732107100277140ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/cache.svg000066400000000000000000000011151324732107100300270ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/close.svg000066400000000000000000000007541324732107100301010ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/config.svg000066400000000000000000000010371324732107100302340ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/event.svg000066400000000000000000000022101324732107100301020ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/exception.svg000066400000000000000000000032021324732107100307610ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/form.svg000066400000000000000000000012571324732107100277360ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/forward.svg000066400000000000000000000006021324732107100304300ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/logger.svg000066400000000000000000000012401324732107100302420ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/memory.svg000066400000000000000000000010001324732107100302650ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg000066400000000000000000000013431324732107100277330ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/no.svg000066400000000000000000000007211324732107100274020ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/redirect.svg000066400000000000000000000020431324732107100305660ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/request.svg000066400000000000000000000034641324732107100304650ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/router.svg000066400000000000000000000011731324732107100303100ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/search.svg000066400000000000000000000012651324732107100302370ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/symfony.svg000066400000000000000000000025241324732107100304750ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/time.svg000066400000000000000000000010321324732107100277200ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg000066400000000000000000000026321324732107100313270ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/twig.svg000066400000000000000000000007411324732107100277420ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/validator.svg000066400000000000000000000010531324732107100307520ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg000066400000000000000000000007311324732107100275670ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/000077500000000000000000000000001324732107100271375ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/ajax_layout.html.twig000066400000000000000000000000251324732107100333130ustar00rootroot00000000000000{% block panel '' %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/bag.html.twig000066400000000000000000000011461324732107100315310ustar00rootroot00000000000000 {% for key in bag.keys|sort %} {% else %} {% endfor %}
    {{ labels is defined ? labels[0] : 'Key' }} {{ labels is defined ? labels[1] : 'Value' }}
    {{ key }} {{ profiler_dump(bag.get(key), maxDepth=maxDepth|default(0)) }}
    (no data)
    symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base.html.twig000066400000000000000000000045321324732107100317140ustar00rootroot00000000000000 Symfony Profiler {% block head %} {% endblock %} {% block body '' %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig000066400000000000000000000557011324732107100324140ustar00rootroot00000000000000{# This file is partially duplicated in TwigBundle/Resources/views/base_js.html.twig. If you make any change in this file, verify the same change is needed in the other file. #} /* 1) { setTimeout(function(){ options.maxTries--; request(url, onSuccess, onError, payload, options); }, 1000); return null; } if (200 === xhr.status) { (onSuccess || noop)(xhr); } else { (onError || noop)(xhr); } }; xhr.send(payload || ''); }; var getPreference = function(name) { if (!window.localStorage) { return null; } return localStorage.getItem(profilerStorageKey + name); }; var setPreference = function(name, value) { if (!window.localStorage) { return null; } localStorage.setItem(profilerStorageKey + name, value); }; var requestStack = []; var extractHeaders = function(xhr, stackElement) { /* Here we avoid to call xhr.getResponseHeader in order to */ /* prevent polluting the console with CORS security errors */ var allHeaders = xhr.getAllResponseHeaders(); var ret; if (ret = allHeaders.match(/^x-debug-token:\s+(.*)$/im)) { stackElement.profile = ret[1]; } if (ret = allHeaders.match(/^x-debug-token-link:\s+(.*)$/im)) { stackElement.profilerUrl = ret[1]; } }; var successStreak = 4; var pendingRequests = 0; var renderAjaxRequests = function() { var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter'); if (!requestCounter) { return; } requestCounter.textContent = requestStack.length; var infoSpan = document.querySelector(".sf-toolbar-ajax-info"); if (infoSpan) { infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : ''); } var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax'); if (requestStack.length) { ajaxToolbarPanel.style.display = 'block'; } else { ajaxToolbarPanel.style.display = 'none'; } if (pendingRequests > 0) { addClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); } else if (successStreak < 4) { addClass(ajaxToolbarPanel, 'sf-toolbar-status-red'); removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); } else { removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red'); } }; var startAjaxRequest = function(index) { var tbody = document.querySelector('.sf-toolbar-ajax-request-list'); if (!tbody) { return; } var nbOfAjaxRequest = tbody.rows.length; if (nbOfAjaxRequest >= 100) { tbody.deleteRow(nbOfAjaxRequest - 1); } var request = requestStack[index]; pendingRequests++; var row = document.createElement('tr'); request.DOMNode = row; var methodCell = document.createElement('td'); methodCell.textContent = request.method; row.appendChild(methodCell); var typeCell = document.createElement('td'); typeCell.textContent = request.type; row.appendChild(typeCell); var statusCodeCell = document.createElement('td'); var statusCode = document.createElement('span'); statusCode.textContent = 'n/a'; statusCodeCell.appendChild(statusCode); row.appendChild(statusCodeCell); var pathCell = document.createElement('td'); pathCell.className = 'sf-ajax-request-url'; if ('GET' === request.method) { var pathLink = document.createElement('a'); pathLink.setAttribute('href', request.url); pathLink.textContent = request.url; pathCell.appendChild(pathLink); } else { pathCell.textContent = request.url; } pathCell.setAttribute('title', request.url); row.appendChild(pathCell); var durationCell = document.createElement('td'); durationCell.className = 'sf-ajax-request-duration'; durationCell.textContent = 'n/a'; row.appendChild(durationCell); var profilerCell = document.createElement('td'); profilerCell.textContent = 'n/a'; row.appendChild(profilerCell); row.className = 'sf-ajax-request sf-ajax-request-loading'; tbody.insertBefore(row, tbody.firstChild); renderAjaxRequests(); }; var finishAjaxRequest = function(index) { var request = requestStack[index]; if (!request.DOMNode) { return; } pendingRequests--; var row = request.DOMNode; /* Unpack the children from the row */ var methodCell = row.children[0]; var statusCodeCell = row.children[2]; var statusCodeElem = statusCodeCell.children[0]; var durationCell = row.children[4]; var profilerCell = row.children[5]; if (request.error) { row.className = 'sf-ajax-request sf-ajax-request-error'; methodCell.className = 'sf-ajax-request-error'; successStreak = 0; } else { row.className = 'sf-ajax-request sf-ajax-request-ok'; successStreak++; } if (request.statusCode) { if (request.statusCode < 300) { statusCodeElem.setAttribute('class', 'sf-toolbar-status'); } else if (request.statusCode < 400) { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow'); } else { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red'); } statusCodeElem.textContent = request.statusCode; } else { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red'); } if (request.duration) { durationCell.textContent = request.duration + 'ms'; } if (request.profilerUrl) { profilerCell.textContent = ''; var profilerLink = document.createElement('a'); profilerLink.setAttribute('href', request.profilerUrl); profilerLink.textContent = request.profile; profilerCell.appendChild(profilerLink); } renderAjaxRequests(); }; var addEventListener; var el = document.createElement('div'); if (!('addEventListener' in el)) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, callback); }; } else { addEventListener = function (element, eventName, callback) { element.addEventListener(eventName, callback, false); }; } {% if excluded_ajax_paths is defined %} if (window.fetch && window.fetch.polyfill === undefined) { var oldFetch = window.fetch; window.fetch = function () { var promise = oldFetch.apply(this, arguments); var url = arguments[0]; var params = arguments[1]; var paramType = Object.prototype.toString.call(arguments[0]); if (paramType === '[object Request]') { url = arguments[0].url; params = { method: arguments[0].method, credentials: arguments[0].credentials, headers: arguments[0].headers, mode: arguments[0].mode, redirect: arguments[0].redirect }; } else { url = String(url); } if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var method = 'GET'; if (params && params.method !== undefined) { method = params.method; } var stackElement = { error: false, url: url, method: method, type: 'fetch', start: new Date() }; var idx = requestStack.push(stackElement) - 1; promise.then(function (r) { stackElement.duration = new Date() - stackElement.start; stackElement.error = r.status < 200 || r.status >= 400; stackElement.statusCode = r.status; stackElement.profile = r.headers.get('x-debug-token'); stackElement.profilerUrl = r.headers.get('x-debug-token-link'); finishAjaxRequest(idx); }, function (e){ stackElement.error = true; finishAjaxRequest(idx); }); startAjaxRequest(idx); } return promise; }; } if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) { var proxied = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { var self = this; /* prevent logging AJAX calls to static and inline files, like templates */ var path = url; if (url.substr(0, 1) === '/') { if (0 === url.indexOf('{{ request.basePath|e('js') }}')) { path = url.substr({{ request.basePath|length }}); } } else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) { path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }}); } if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var stackElement = { error: false, url: url, method: method, type: 'xhr', start: new Date() }; var idx = requestStack.push(stackElement) - 1; this.addEventListener('readystatechange', function() { if (self.readyState == 4) { stackElement.duration = new Date() - stackElement.start; stackElement.error = self.status < 200 || self.status >= 400; stackElement.statusCode = self.status; extractHeaders(self, stackElement); finishAjaxRequest(idx); } }, false); startAjaxRequest(idx); } proxied.apply(this, Array.prototype.slice.call(arguments)); }; } {% endif %} return { hasClass: hasClass, removeClass: removeClass, addClass: addClass, toggleClass: toggleClass, getPreference: getPreference, setPreference: setPreference, addEventListener: addEventListener, request: request, renderAjaxRequests: renderAjaxRequests, load: function(selector, url, onSuccess, onError, options) { var el = document.getElementById(selector); if (el && el.getAttribute('data-sfurl') !== url) { request( url, function(xhr) { el.innerHTML = xhr.responseText; el.setAttribute('data-sfurl', url); removeClass(el, 'loading'); for (var i = 0; i < requestStack.length; i++) { startAjaxRequest(i); if (requestStack[i].duration) { finishAjaxRequest(i); } } (onSuccess || noop)(xhr, el); }, function(xhr) { (onError || noop)(xhr, el); }, '', options ); } return this; }, toggle: function(selector, elOn, elOff) { var tmp = elOn.style.display, el = document.getElementById(selector); elOn.style.display = elOff.style.display; elOff.style.display = tmp; if (el) { el.style.display = 'none' === tmp ? 'none' : 'block'; } return this; }, createTabs: function() { var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])'); /* create the tab navigation for each group of tabs */ for (var i = 0; i < tabGroups.length; i++) { var tabs = tabGroups[i].querySelectorAll('.tab'); var tabNavigation = document.createElement('ul'); tabNavigation.className = 'tab-navigation'; for (var j = 0; j < tabs.length; j++) { var tabId = 'tab-' + i + '-' + j; var tabTitle = tabs[j].querySelector('.tab-title').innerHTML; var tabNavigationItem = document.createElement('li'); tabNavigationItem.setAttribute('data-tab-id', tabId); if (j == 0) { addClass(tabNavigationItem, 'active'); } if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); } tabNavigationItem.innerHTML = tabTitle; tabNavigation.appendChild(tabNavigationItem); var tabContent = tabs[j].querySelector('.tab-content'); tabContent.parentElement.setAttribute('id', tabId); } tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild); } /* display the active tab and add the 'click' event listeners */ for (i = 0; i < tabGroups.length; i++) { tabNavigation = tabGroups[i].querySelectorAll('.tab-navigation li'); for (j = 0; j < tabNavigation.length; j++) { tabId = tabNavigation[j].getAttribute('data-tab-id'); document.getElementById(tabId).querySelector('.tab-title').className = 'hidden'; if (hasClass(tabNavigation[j], 'active')) { document.getElementById(tabId).className = 'block'; } else { document.getElementById(tabId).className = 'hidden'; } tabNavigation[j].addEventListener('click', function(e) { var activeTab = e.target || e.srcElement; /* needed because when the tab contains HTML contents, user can click */ /* on any of those elements instead of their parent '
  • ' element */ while (activeTab.tagName.toLowerCase() !== 'li') { activeTab = activeTab.parentNode; } /* get the full list of tabs through the parent of the active tab element */ var tabNavigation = activeTab.parentNode.children; for (var k = 0; k < tabNavigation.length; k++) { var tabId = tabNavigation[k].getAttribute('data-tab-id'); document.getElementById(tabId).className = 'hidden'; removeClass(tabNavigation[k], 'active'); } addClass(activeTab, 'active'); var activeTabId = activeTab.getAttribute('data-tab-id'); document.getElementById(activeTabId).className = 'block'; }); } tabGroups[i].setAttribute('data-processed', 'true'); } }, createToggles: function() { var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])'); for (var i = 0; i < toggles.length; i++) { var elementSelector = toggles[i].getAttribute('data-toggle-selector'); var element = document.querySelector(elementSelector); addClass(element, 'sf-toggle-content'); if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') { addClass(toggles[i], 'sf-toggle-on'); addClass(element, 'sf-toggle-visible'); } else { addClass(toggles[i], 'sf-toggle-off'); addClass(element, 'sf-toggle-hidden'); } addEventListener(toggles[i], 'click', function(e) { e.preventDefault(); if ('' !== window.getSelection().toString()) { /* Don't do anything on text selection */ return; } var toggle = e.target || e.srcElement; /* needed because when the toggle contains HTML contents, user can click */ /* on any of those elements instead of their parent '.sf-toggle' element */ while (!hasClass(toggle, 'sf-toggle')) { toggle = toggle.parentNode; } var element = document.querySelector(toggle.getAttribute('data-toggle-selector')); toggleClass(toggle, 'sf-toggle-on'); toggleClass(toggle, 'sf-toggle-off'); toggleClass(element, 'sf-toggle-hidden'); toggleClass(element, 'sf-toggle-visible'); /* the toggle doesn't change its contents when clicking on it */ if (!toggle.hasAttribute('data-toggle-alt-content')) { return; } if (!toggle.hasAttribute('data-toggle-original-content')) { toggle.setAttribute('data-toggle-original-content', toggle.innerHTML); } var currentContent = toggle.innerHTML; var originalContent = toggle.getAttribute('data-toggle-original-content'); var altContent = toggle.getAttribute('data-toggle-alt-content'); toggle.innerHTML = currentContent !== altContent ? altContent : originalContent; }); /* Prevents from disallowing clicks on links inside toggles */ var toggleLinks = toggles[i].querySelectorAll('a'); for (var j = 0; j < toggleLinks.length; j++) { addEventListener(toggleLinks[j], 'click', function(e) { e.stopPropagation(); }); } toggles[i].setAttribute('data-processed', 'true'); } } }; })(); Sfjs.addEventListener(document, 'DOMContentLoaded', function() { Sfjs.createTabs(); Sfjs.createToggles(); }); /*]]>*/ symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/header.html.twig000066400000000000000000000010341324732107100322240ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig000066400000000000000000000013101324732107100317240ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% set messages = { 'no_token' : { status: 'error', title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found', message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.' } } %} {% block summary %}

    {{ messages[about].status|title }}

    {% endblock %} {% block panel %}

    {{ messages[about].title }}

    {{ messages[about].message }}

    {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig000066400000000000000000000164341324732107100323230ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/base.html.twig' %} {% block body %} {{ include('@WebProfiler/Profiler/header.html.twig', with_context = false) }}
    {% block summary %} {% if profile is defined %} {% set status_code = ('request' in profile.collectors|keys) ? profile.getcollector('request').statuscode|default(0) : 0 %} {% set css_class = status_code > 399 ? 'status-error' : status_code > 299 ? 'status-warning' : 'status-success' %}

    {% if profile.method|upper in ['GET', 'HEAD'] %} {{ profile.url }} {% else %} {{ profile.url }} {% endif %}

    {% set request_collector = profile.collectors.request|default(false) %} {% if request_collector and request_collector.redirect -%} {%- set redirect = request_collector.redirect -%} {%- set controller = redirect.controller -%} {%- set redirect_route = '@' ~ redirect.route %} {%- endif %} {% if request_collector and request_collector.forward|default(false) and request_collector.forward.controller.class is defined -%} {%- set forward = request_collector.forward -%} {%- set controller = forward.controller -%} {%- endif %}
    {% endif %} {% endblock %}
    {{ include('@WebProfiler/Profiler/base_js.html.twig') }} {% block panel '' %}
    {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig000066400000000000000000000072331324732107100315700ustar00rootroot00000000000000{# Mixins ========================================================================= #} {% set mixins = { 'break_long_words': '-ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto;', 'monospace_font': 'font-family: monospace; font-size: 13px; font-size-adjust: 0.5;', 'sans_serif_font': 'font-family: Helvetica, Arial, sans-serif;', 'subtle_border_and_shadow': 'background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2);' } %} {# Normalization (normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css) ========================================================================= #} html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0} {# Basic styles ========================================================================= #} html, body { height: 100%; width: 100%; } body { background-color: #F9F9F9; color: #aaa; display: flex; flex-direction: column; {{ mixins.sans_serif_font|raw }} font-size: 14px; line-height: 1.4; } .header { background-color: #222; position: fixed; top: 0; display: flex; width: 100%; } .header h1 { color: #FFF; font-weight: normal; font-size: 21px; margin: 0; padding: 10px 10px 8px; word-break: break-all; } a.doc { color: #FFF; text-decoration: none; margin: auto; margin-right: 10px; } a.doc:hover { text-decoration: underline; } .source { margin-top: 41px; } .source li code { color: #555; } .source li.selected { background: rgba(255, 255, 153, 0.5); } .anchor { position: relative; display: inline-block; top: -7em; visibility: hidden; } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig000066400000000000000000000010461324732107100317400ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/base.html.twig' %} {% block head %} {% endblock %} {% block body %}

    {{ file }} line {{ line }}

    Open in your IDE?
    {{ filename|file_excerpt(line, -1) }}
    {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig000066400000000000000000000565661324732107100324660ustar00rootroot00000000000000{# Mixins ========================================================================= #} {% set mixins = { 'break_long_words': '-ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto;', 'monospace_font': 'font-family: monospace; font-size: 13px; font-size-adjust: 0.5;', 'sans_serif_font': 'font-family: Helvetica, Arial, sans-serif;', 'subtle_border_and_shadow': 'background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2);' } %} {# when updating any of these colors, do the same in toolbar.css.twig #} {% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %} {# Normalization (normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css) ========================================================================= #} html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0} {# Basic styles ========================================================================= #} html, body { height: 100%; width: 100%; } body { background-color: #F9F9F9; color: #222; display: flex; flex-direction: column; {{ mixins.sans_serif_font|raw }} font-size: 14px; line-height: 1.4; } h2, h3, h4 { font-weight: 500; margin: 1.5em 0 .5em; } h2 + h3, h3 + h4 { margin-top: 1em; } h2 { font-size: 24px; } h3 { font-size: 21px; } h4 { font-size: 18px; } h2 span, h3 span, h4 span, h2 small, h3 small, h4 small { color: #999; } li { margin-bottom: 10px; } p { font-size: 16px; margin-bottom: 1em; } a { color: #218BC3; text-decoration: none; } a:hover { text-decoration: underline; } a.link-inverse { text-decoration: underline; } a.link-inverse:hover { text-decoration: none; } a:active, a:hover { outline: 0; } h2 a, h3 a, h4 a { text-decoration: underline; } h2 a:hover, h3 a:hover, h4 a:hover { text-decoration: none; } abbr { border-bottom: 1px dotted #444; cursor: help; } code, pre { {{ mixins.monospace_font|raw }} } {# Buttons ------------------------------------------------------------------------- #} button { {{ mixins.sans_serif_font|raw }} } .btn { background: #777; border-radius: 2px; border: 0; color: #F5F5F5; display: inline-block; padding: .5em .75em; } .btn:hover { cursor: pointer; opacity: 0.8; text-decoration: none; } .btn-sm { font-size: 12px; } .btn-sm svg { height: 16px; width: 16px; vertical-align: middle; } .btn-link { border-color: transparent; color: #218BC3; text-decoration: none; background-color: transparent; outline: none; border: 0; padding: 0; cursor: pointer; } .btn-link:hover { text-decoration: underline; } {# Tables ------------------------------------------------------------------------- #} table, tr, th, td { background: #FFF; border-collapse: collapse; line-height: 1.5; vertical-align: top; } table { {{ mixins.subtle_border_and_shadow|raw }}; margin: 1em 0; width: 100%; } table th, table td { padding: 8px 10px; } table th { font-weight: bold; text-align: left; } table thead th { background-color: #E0E0E0; } table thead th.key { width: 19%; } table thead.small th { font-size: 12px; padding: 4px 10px; } table tbody th, table tbody td { {{ mixins.monospace_font|raw }} border: 1px solid #E0E0E0; border-width: 1px 0; } table tbody div { margin: .25em 0; } table tbody ul { margin: 0; padding: 0 0 0 1em; } {# Utility classes ========================================================================= #} .block { display: block; } .full-width { width: 100%; } .hidden { display: none; } .nowrap { white-space: pre; } .prewrap { white-space: pre-wrap; } .newline { display: block; } .break-long-words { {{ mixins.break_long_words|raw }} } .text-small { font-size: 12px !important; } .text-muted { color: #999; } .text-bold { font-weight: bold; } .text-right { text-align: right; } .text-center { text-align: center; } .font-normal { {{ mixins.sans_serif_font|raw }} font-size: 14px; } .help { color: #999; font-size: 14px; margin-bottom: .5em; } .empty { border: 4px dashed #E0E0E0; color: #999; margin: 1em 0; padding: .5em 2em; } .label { background-color: #666; color: #FAFAFA; display: inline-block; font-size: 12px; font-weight: bold; padding: 3px 7px; white-space: nowrap; } .label.same-width { min-width: 70px; text-align: center; } .label.status-success { background: {{ colors.success|raw }}; color: #FFF; } .label.status-warning { background: {{ colors.warning|raw }}; color: #FFF; } .label.status-error { background: {{ colors.error|raw }}; color: #FFF; } {# Metrics ------------------------------------------------------------------------- #} .metrics { margin: 1em 0 0; overflow: auto; } .metrics .metric { float: left; margin: 0 1em 1em 0; } .metric { {{ mixins.subtle_border_and_shadow|raw }}; min-width: 100px; min-height: 70px; } .metric .value { display: block; font-size: 28px; padding: 8px 15px 4px; text-align: center; } .metric .value svg { margin: 5px 0 -5px; } .metric .unit { color: #999; font-size: 18px; margin-left: -4px; } .metric .label { background: #E0E0E0; color: #222; display: block; font-size: 12px; padding: 5px; text-align: center; } .metrics-horizontal .metric { min-height: 0; min-width: 0; } .metrics-horizontal .metric .value, .metrics-horizontal .metric .label { display: inline; padding: 2px 6px; } .metrics-horizontal .metric .label { display: inline-block; padding: 6px; } .metrics-horizontal .metric .value { font-size: 16px; } .metrics-horizontal .metric .value svg { max-height: 14px; line-height: 10px; margin: 0; padding-left: 4px; vertical-align: middle; } .metric-divider { float: left; margin: 0 1em; min-height: 1px; {# required to apply 'margin' to an empty 'div' #} } {# Cards ------------------------------------------------------------------------- #} .card { {{ mixins.subtle_border_and_shadow|raw }}; margin: 1em 0; padding: 10px; } .card-block + .card-block { border-top: 1px solid #E0E0E0; padding-top: 10px; } .card *:first-child, .card-block *:first-child { margin-top: 0; } .card .label { background-color: #EEE; color: #222; } {# Status ------------------------------------------------------------------------- #} .status-success { background: rgba(94, 151, 110, 0.3); } .status-warning { background: rgba(240, 181, 24, 0.3); } .status-error { background: rgba(176, 65, 62, 0.2); } .status-success td, .status-warning td, .status-error td { background: transparent; } tr.status-error td, tr.status-warning td { border-bottom: 1px solid #FAFAFA; border-top: 1px solid #FAFAFA; } .status-warning .colored { color: {{ colors.warning|raw }}; } .status-error .colored { color: {{ colors.error|raw }}; } {# Syntax highlighting ========================================================================= #} .highlight pre { margin: 0; white-space: pre-wrap; } .highlight .keyword { color: #8959A8; font-weight: bold; } .highlight .word { color: #222222; } .highlight .variable { color: #916319; } .highlight .symbol { color: #222222; } .highlight .comment { color: #999999; } .highlight .backtick { color: #718C00; } .highlight .string { color: #718C00; } .highlight .number { color: #F5871F; font-weight: bold; } .highlight .error { color: #C82829; } {# Icons ========================================================================= #} .sf-icon { vertical-align: middle; background-repeat: no-repeat; background-size: contain; width: 16px; height: 16px; display: inline-block; } .sf-icon svg { width: 16px; height: 16px; } .sf-icon.sf-medium, .sf-icon.sf-medium svg { width: 24px; height: 24px; } .sf-icon.sf-large, .sf-icon.sf-large svg { width: 32px; height: 32px; } {# Layout ========================================================================= #} .container { max-width: 1300px; padding-right: 15px; } #header { flex: 0 0 auto; } #header .container { display: flex; flex-direction: row; justify-content: space-between; } #summary { flex: 0 0 auto; } #content { height: 100%; } #main { display: flex; flex-direction: row; min-height: 100%; } #sidebar { flex: 0 0 220px; } #collector-wrapper { flex: 0 1 100%; min-width: 0; } #collector-content { margin: 0 0 30px 0; padding: 14px 0 14px 20px; } #main h2:first-of-type { margin-top: 0; } {# Header ========================================================================= #} #header { background-color: #222; overflow: hidden; } #header h1 { color: #FFF; flex: 1; font-weight: normal; font-size: 21px; margin: 0; padding: 10px 10px 8px; } #header h1 span { color: #CCC; } #header h1 svg { height: 40px; width: 40px; margin-top: -4px; vertical-align: middle; } #header h1 svg path, #header h1 svg .sf-svg-path { fill: #FFF; } #header .search { padding-top: 11px; } #header .search input { border: 1px solid #DDD; margin-right: 4px; padding: 7px 8px; width: 200px; } {# Summary ========================================================================= #} #summary .status { background: #E0E0E0; border: solid rgba(0, 0, 0, 0.1); border-width: 2px 0; padding: 10px; } #summary h2, #summary h2 a { color: #222; font-size: 21px; margin: 0; text-decoration: none; } #summary h2 a:hover { text-decoration: underline; } #summary .status-success { background: {{ colors.success|raw }}; } #summary .status-warning { background: {{ colors.warning|raw }}; } #summary .status-error { background: {{ colors.error|raw }}; } #summary .status-success h2, #summary .status-success a, #summary .status-warning h2, #summary .status-warning a, #summary .status-error h2, #summary .status-error a { color: #FFF; } #summary dl.metadata, #summary dl.metadata a { margin: 5px 0 0; color: rgba(255, 255, 255, 0.75); } #summary dl.metadata dt, #summary dl.metadata dd { display: inline-block; font-size: 13px; } #summary dl.metadata dt { font-weight: bold; } #summary dl.metadata dt:after { content: ':'; } #summary dl.metadata dd { margin: 0 1.5em 0 0; } #summary dl.metadata .label { background: rgba(255, 255, 255, 0.2); } {# Sidebar ========================================================================= #} #sidebar { background: #444; color: #CCC; padding-bottom: 30px; position: relative; width: 220px; z-index: 9999; } #sidebar .module { padding: 10px; width: 220px; } {# Sidebar Shortcuts ------------------------------------------------------------------------- #} #sidebar #sidebar-shortcuts { background: #333; width: 220px; } #sidebar #sidebar-shortcuts .shortcuts { position: relative; padding: 16px 10px; } #sidebar-shortcuts .icon { display: block; float: left; width: 50px; margin: 2px 0 0 -10px; text-align: center; } #sidebar #sidebar-shortcuts .btn { color: #F5F5F5; } #sidebar #sidebar-shortcuts .btn + .btn { margin-left: 5px; } #sidebar #sidebar-shortcuts .btn { padding: .5em; } {# Sidebar Search ------------------------------------------------------------------------- #} #sidebar-search .form-group:first-of-type { padding-top: 20px; } #sidebar-search .form-group { clear: both; overflow: hidden; padding-bottom: 10px; } #sidebar-search .form-group label { float: left; font-size: 13px; line-height: 24px; width: 60px; } #sidebar-search .form-group input, #sidebar-search .form-group select { float: left; font-size: 13px; padding: 3px 6px; } #sidebar-search .form-group input { background: #CCC; border: 1px solid #999; color: #222; width: 120px; } #sidebar-search .form-group select { color: #222; } #sidebar-search .form-group .btn { float: right; margin-right: 10px; } {# Sidebar Menu ------------------------------------------------------------------------- #} #menu-profiler { margin: 0; padding: 0; list-style-type: none; } #menu-profiler li { position: relative; margin-bottom: 0; } #menu-profiler li a { border: solid transparent; border-width: 2px 0; color: #CCC; display: block; } #menu-profiler li a:hover { text-decoration: none; } #menu-profiler li a .label { background: transparent; color: #EEE; display: block; padding: 8px 10px 8px 50px; overflow: hidden; white-space: nowrap; } #menu-profiler li a .label .icon { display: block; position: absolute; left: 0; top: 8px; width: 50px; text-align: center; } #menu-profiler .label .icon img, #menu-profiler .label .icon svg { height: 24px; max-width: 24px; } #menu-profiler li a .label .icon svg path, #menu-profiler li a .label .icon svg .sf-svg-path { fill: #DDD; } #menu-profiler li a .label strong { font-size: 16px; font-weight: normal; } #menu-profiler li a .label.disabled { opacity: .25; } #menu-profiler li a:hover .label.disabled, #menu-profiler li.selected a .label.disabled { opacity: 1; } #menu-profiler li.selected a, #menu-profiler:hover li.selected a:hover, #menu-profiler li a:hover { background: #666; border: solid #555; border-width: 2px 0; } #menu-profiler li.selected a .label, #menu-profiler li a:hover .label { color: #FFF; } #menu-profiler li.selected a .icon svg path, #menu-profiler li.selected a .icon svg .sf-svg-path, #menu-profiler li a:hover .icon svg path, #menu-profiler li a:hover .icon svg .sf-svg-path { fill: #FFF; } #menu-profiler li a .count { background-color: #666; color: #FFF; display: inline-block; font-weight: bold; min-width: 10px; padding: 2px 6px; position: absolute; right: 10px; text-align: center; vertical-align: baseline; white-space: nowrap; } #menu-profiler li a span.count span { font-size: 12px; } #menu-profiler li a span.count span + span::before { content: " / "; color: #AAA; } #menu-profiler .label-status-warning .count { background: {{ colors.warning|raw }}; } #menu-profiler .label-status-error .count { background: {{ colors.error|raw }}; } {# Timeline panel ========================================================================= #} #timeline-control { background: #FFF; margin: 1em 0; padding: 10px; } #timeline-control label { font-weight: bold; margin-right: 1em; } #timeline-control input { font-size: 16px; padding: 4px; text-align: right; width: 40px; } #timeline-control .help { margin-left: 1em; } .sf-profiler-timeline .legends { font-size: 12px; line-height: 1.5em; } .sf-profiler-timeline .legends span { border-left: solid 14px; padding: 0 10px 0 5px; } .sf-profiler-timeline canvas { border: 1px solid #DDD; background: #FFF; margin: .5em 0; } .sf-profiler-timeline + p.help { margin-top: 0; } {# Tabbed navigation ========================================================================= #} .tab-navigation { margin: 0 0 1em 0; padding: 0; } .tab-navigation li { background: #FFF; border: 1px solid #DDD; color: #444; cursor: pointer; display: inline-block; font-size: 16px; margin: 0 0 0 -1px; padding: .5em .75em; z-index: 1; } .tab-navigation li:hover { background: #EEE; } .tab-navigation li .badge { background-color: #F5F5F5; color: #777; display: inline-block; font-size: 14px; font-weight: bold; margin-left: 8px; min-width: 10px; padding: 1px 6px; text-align: center; white-space: nowrap; } .tab-navigation li:hover .badge { background: #FAFAFA; color: #777; } .tab-navigation li.disabled { background: #F5F5F5; color: #999; } .tab-navigation li.active { background: #666; border-color: #666; color: #FAFAFA; z-index: 1100; } .tab-navigation li.active .badge { background-color: #444; color: #FFF; } .tab-content > *:first-child { margin-top: 0; } .tab-navigation li .badge.status-warning { background: {{ colors.warning|raw }}; color: #FFF; } .tab-navigation li .badge.status-error { background: {{ colors.error|raw }}; color: #FFF; } .sf-tabs .tab:not(:first-child) { display: none; } {# Toggles ========================================================================= #} .sf-toggle-content { -moz-transition: display .25s ease; -webkit-transition: display .25s ease; transition: display .25s ease; } .sf-toggle-content.sf-toggle-hidden { display: none; } .sf-toggle-content.sf-toggle-visible { display: block; } {# Twig panel ========================================================================= #} #twig-dump pre { font-size: 12px; line-height: 1.7; } #twig-dump span { border-radius: 2px; padding: 1px 2px; } #twig-dump .status-error { background: transparent; color: #B0413E; } #twig-dump .status-warning { background: rgba(240, 181, 24, 0.3); } #twig-dump .status-success { background: rgba(100, 189, 99, 0.2); } {# Logger panel ========================================================================= #} table.logs .metadata { display: block; font-size: 12px; } {# Doctrine panel ========================================================================= #} .sql-runnable { background: #F5F5F5; margin: .5em 0; padding: 1em; } .sql-explain { overflow-x: auto; max-width: 920px; } .sql-explain table td, .sql-explain table tr { word-break: normal; } .queries-table pre { {{ mixins.break_long_words|raw }} margin: 0; white-space: pre-wrap; } {# Validator panel ========================================================================= #} #collector-content .sf-validator { margin-bottom: 2em; } #collector-content .sf-validator .sf-validator-context, #collector-content .sf-validator .trace { border: 1px solid #DDD; background: #FFF; padding: 10px; margin: 0.5em 0; } #collector-content .sf-validator .trace { font-size: 12px; } #collector-content .sf-validator .trace li { margin-bottom: 0; padding: 0; } #collector-content .sf-validator .trace li.selected { background: rgba(255, 255, 153, 0.5); } {# Dump panel ========================================================================= #} #collector-content .sf-dump { margin-bottom: 2em; } #collector-content pre.sf-dump, #collector-content .sf-dump code, #collector-content .sf-dump samp { {{ mixins.monospace_font|raw }} } #collector-content .sf-dump a { cursor: pointer; } #collector-content .sf-dump pre.sf-dump, #collector-content .sf-dump .trace { border: 1px solid #DDD; background: #FFF; padding: 10px; margin: 0.5em 0; } #collector-content pre.sf-dump, #collector-content .sf-dump-default { color: #CC7832; background: none; } #collector-content .sf-dump-str { color: #629755; } #collector-content .sf-dump-private, #collector-content .sf-dump-protected, #collector-content .sf-dump-public { color: #262626; } #collector-content .sf-dump-note { color: #6897BB; } #collector-content .sf-dump-key { color: #789339; } #collector-content .sf-dump-ref { color: #6E6E6E; } #collector-content .sf-dump-ellipsis { color: #CC7832; max-width: 100em; } #collector-content .sf-dump-ellipsis-path { max-width: 5em; } #collector-content .sf-dump { margin: 0; padding: 0; line-height: 1.4; } #collector-content .dump-inline .sf-dump { display: inline; white-space: normal; font-size: inherit; line-height: inherit; } #collector-content .dump-inline .sf-dump:after { display: none; } #collector-content .sf-dump .trace { font-size: 12px; } #collector-content .sf-dump .trace li { margin-bottom: 0; padding: 0; } #collector-content .sf-dump .trace li.selected { background: rgba(255, 255, 153, 0.5); } {# Search Results page ========================================================================= #} #search-results td { {{ mixins.sans_serif_font|raw }} vertical-align: middle; } #search-results .sf-search { visibility: hidden; margin-left: 2px; } #search-results tr:hover .sf-search { visibility: visible; } {# Small screens ========================================================================= #} .visible-small { display: none; } .hidden-small { display: inherit; } @media (max-width: 768px) { #sidebar { flex-basis: 50px; overflow-x: hidden; transition: flex-basis 200ms ease-out; } #sidebar:hover, #sidebar.expanded { flex-basis: 220px; } #sidebar-search { display: none; } #sidebar:hover #sidebar-search.sf-toggle-visible, #sidebar.expanded #sidebar-search.sf-toggle-visible { display: block; } #sidebar .module { display: none; } #sidebar:hover .module, #sidebar.expanded .module { display: block; } #sidebar:not(:hover):not(.expanded) .label .count { border-radius: 50%; border: 1px solid #eee; height: 8px; min-width: 0; padding: 0; right: 4px; text-indent: -9999px; top: 50%; width: 8px; } .visible-small { display: inherit; } .hidden-small { display: none; } .btn-sm svg { margin-left: 2px; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig000066400000000000000000000066641324732107100325130ustar00rootroot00000000000000{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block summary %}

    Profile Search

    {% endblock %} {% block panel %}

    {{ tokens ? tokens|length : 'No' }} results found

    {% if tokens %} {% for result in tokens %} {% set css_class = result.status_code|default(0) > 399 ? 'status-error' : result.status_code|default(0) > 299 ? 'status-warning' : 'status-success' %} {% endfor %}
    Status IP Method URL Time Token
    {{ result.status_code|default('n/a') }} {{ result.ip }} {% if request.session is not null %} {{ include('@WebProfiler/Icon/search.svg') }} {% endif %} {{ result.method }} {% if request.session is not null %} {{ include('@WebProfiler/Icon/search.svg') }} {% endif %} {{ result.url }} {% if request.session is not null %} {{ include('@WebProfiler/Icon/search.svg') }} {% endif %} {{ result.time|date('d-M-Y') }} {{ result.time|date('H:i:s') }} {{ result.token }}
    {% else %}

    The query returned no result.

    {% endif %} {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/search.html.twig000066400000000000000000000037011324732107100322440ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/table.html.twig000066400000000000000000000007551324732107100320740ustar00rootroot00000000000000 {% for key in data|keys|sort %} {% endfor %}
    {{ labels is defined ? labels[0] : 'Key' }} {{ labels is defined ? labels[1] : 'Value' }}
    {{ key }} {{ profiler_dump(data[key]) }}
    symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig000066400000000000000000000323271324732107100322730ustar00rootroot00000000000000{# when updating any of these colors, do the same in profiler.css.twig #} {% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %} .sf-minitoolbar { background-color: #222; border-top-left-radius: 4px; bottom: 0; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: none; height: 36px; padding: 6px; position: fixed; right: 0; z-index: 99999; } .sf-minitoolbar a { display: block; } .sf-minitoolbar svg, .sf-minitoolbar img { max-height: 24px; max-width: 24px; display: inline; } .sf-toolbar-clearer { clear: both; height: 36px; } .sf-display-none { display: none; } .sf-toolbarreset * { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; vertical-align: baseline; letter-spacing: normal; width: auto; } .sf-toolbarreset { background-color: #222; bottom: 0; box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); color: #EEE; font: 11px Arial, sans-serif; left: 0; margin: 0; padding: 0 36px 0 0; position: fixed; right: 0; text-align: left; text-transform: none; z-index: 99999; /* neutralize the aliasing defined by external CSS styles */ -webkit-font-smoothing: subpixel-antialiased; -moz-osx-font-smoothing: auto; } .sf-toolbarreset abbr { border: dashed #777; border-width: 0 0 1px; } .sf-toolbarreset svg, .sf-toolbarreset img { height: 20px; display: inline-block; } .sf-toolbarreset .hide-button { background: #444; display: block; position: absolute; top: 0; right: 0; width: 36px; height: 36px; cursor: pointer; text-align: center; } .sf-toolbarreset .hide-button svg { max-height: 18px; margin-top: 10px; } .sf-toolbar-block { cursor: default; display: block; float: left; height: 36px; margin-right: 0; white-space: nowrap; } .sf-toolbar-block > a, .sf-toolbar-block > a:hover { display: block; text-decoration: none; } .sf-toolbar-block span { display: inline-block; } .sf-toolbar-block .sf-toolbar-value { color: #F5F5F5; font-size: 13px; line-height: 36px; padding: 0; } .sf-toolbar-block .sf-toolbar-label, .sf-toolbar-block .sf-toolbar-class-separator { color: #AAA; font-size: 12px; } .sf-toolbar-block .sf-toolbar-info { border-collapse: collapse; display: table; z-index: 100000; } .sf-toolbar-block hr { border-top: 1px solid #777; margin: 4px 0; padding-top: 4px; } .sf-toolbar-block .sf-toolbar-info-piece { /* this 'border-bottom' trick is needed because 'margin-bottom' doesn't work for table rows */ border-bottom: solid transparent 3px; display: table-row; } .sf-toolbar-block .sf-toolbar-info-piece-additional, .sf-toolbar-block .sf-toolbar-info-piece-additional-detail { display: none; } .sf-toolbar-block .sf-toolbar-info-group { margin-bottom: 4px; padding-bottom: 2px; border-bottom: 1px solid #333333; } .sf-toolbar-block .sf-toolbar-info-group:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; } .sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status { padding: 2px 5px; margin-bottom: 0; } .sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status + .sf-toolbar-status { margin-left: 4px; } .sf-toolbar-block .sf-toolbar-info-piece:last-child { margin-bottom: 0; } .sf-toolbar-block .sf-toolbar-info-piece a { color: #99CDD8; text-decoration: underline; } .sf-toolbar-block .sf-toolbar-info-piece a:hover { text-decoration: none; } .sf-toolbar-block .sf-toolbar-info-piece b { color: #AAA; display: table-cell; font-size: 11px; padding: 4px 8px 4px 0; } .sf-toolbar-block:not(.sf-toolbar-block-dump) .sf-toolbar-info-piece span { color: #F5F5F5; } .sf-toolbar-block .sf-toolbar-info-piece span { font-size: 12px; } .sf-toolbar-block .sf-toolbar-info { background-color: #444; bottom: 36px; color: #F5F5F5; display: none; padding: 9px 0; position: absolute; } .sf-toolbar-block .sf-toolbar-info:empty { visibility: hidden; } .sf-toolbar-block .sf-toolbar-status { display: inline-block; color: #FFF; background-color: #666; padding: 3px 6px; margin-bottom: 2px; vertical-align: middle; min-width: 15px; min-height: 13px; text-align: center; } .sf-toolbar-block .sf-toolbar-status-green { background-color: {{ colors.success|raw }}; } .sf-toolbar-block .sf-toolbar-status-red { background-color: {{ colors.error|raw }}; } .sf-toolbar-block .sf-toolbar-status-yellow { background-color: {{ colors.warning|raw }}; } .sf-toolbar-block.sf-toolbar-status-green { background-color: {{ colors.success|raw }}; color: #FFF; } .sf-toolbar-block.sf-toolbar-status-red { background-color: {{ colors.error|raw }}; color: #FFF; } .sf-toolbar-block.sf-toolbar-status-yellow { background-color: {{ colors.warning|raw }}; color: #FFF; } .sf-toolbar-block-request .sf-toolbar-status { color: #FFF; display: inline-block; font-size: 14px; height: 36px; line-height: 36px; padding: 0 10px; } .sf-toolbar-block-request .sf-toolbar-info-piece a { text-decoration: none; } .sf-toolbar-block-request .sf-toolbar-info-piece a:hover { text-decoration: underline; } .sf-toolbar-block-request .sf-toolbar-redirection-status { font-weight: normal; padding: 2px 4px; line-height: 18px; } .sf-toolbar-block-request .sf-toolbar-info-piece span.sf-toolbar-redirection-method { font-size: 12px; height: 17px; line-height: 17px; margin-right: 5px; } .sf-toolbar-block-ajax .sf-toolbar-icon { cursor: pointer; } .sf-toolbar-status-green .sf-toolbar-label, .sf-toolbar-status-yellow .sf-toolbar-label, .sf-toolbar-status-red .sf-toolbar-label { color: #FFF; } .sf-toolbar-status-green svg path, .sf-toolbar-status-green svg .sf-svg-path, .sf-toolbar-status-red svg path, .sf-toolbar-status-red svg .sf-svg-path, .sf-toolbar-status-yellow svg path, .sf-toolbar-status-yellow svg .sf-svg-path { fill: #FFF; } .sf-toolbar-block-config svg path, .sf-toolbar-block-config svg .sf-svg-path { fill: #FFF; } .sf-toolbar-block .sf-toolbar-icon { display: block; height: 36px; padding: 0 7px; } .sf-toolbar-block-request .sf-toolbar-icon { padding-left: 0; padding-right: 0; } .sf-toolbar-block .sf-toolbar-icon img, .sf-toolbar-block .sf-toolbar-icon svg { border-width: 0; position: relative; top: 8px; } .sf-toolbar-block .sf-toolbar-icon img + span, .sf-toolbar-block .sf-toolbar-icon svg + span { margin-left: 4px; } .sf-toolbar-block-config .sf-toolbar-icon .sf-toolbar-value { margin-left: 4px; } .sf-toolbar-block:hover, .sf-toolbar-block.hover { position: relative; } .sf-toolbar-block:hover .sf-toolbar-icon, .sf-toolbar-block.hover .sf-toolbar-icon { background-color: #444; position: relative; z-index: 10002; } .sf-toolbar-block-ajax.hover .sf-toolbar-info { z-index: 10001; } .sf-toolbar-block:hover .sf-toolbar-info, .sf-toolbar-block.hover .sf-toolbar-info { display: block; padding: 10px; max-width: 480px; max-height: 480px; word-wrap: break-word; overflow: hidden; overflow-y: auto; } .sf-toolbar-info-piece b.sf-toolbar-ajax-info { color: #F5F5F5; } .sf-toolbar-ajax-requests { table-layout: auto; width: 100%; } .sf-toolbar-ajax-requests td { background-color: #444; border-bottom: 1px solid #777; color: #F5F5F5; font-size: 12px; padding: 4px; } .sf-toolbar-ajax-requests tr:last-child td { border-bottom: 0; } .sf-toolbar-ajax-requests th { background-color: #222; border-bottom: 0; color: #AAA; font-size: 11px; padding: 4px; } .sf-ajax-request-url { max-width: 250px; line-height: 9px; overflow: hidden; text-overflow: ellipsis; } .sf-toolbar-ajax-requests .sf-ajax-request-url a { text-decoration: none; } .sf-toolbar-ajax-requests .sf-ajax-request-url a:hover { text-decoration: underline; } .sf-ajax-request-duration { text-align: right; } .sf-ajax-request-loading { -webkit-animation: sf-blink .5s ease-in-out infinite; -o-animation: sf-blink .5s ease-in-out infinite; -moz-animation: sf-blink .5s ease-in-out infinite; animation: sf-blink .5s ease-in-out infinite; } @-webkit-keyframes sf-blink { 0% { background: #222; } 50% { background: #444; } 100% { background: #222; } } @-moz-keyframes sf-blink { 0% { background: #222; } 50% { background: #444; } 100% { background: #222; } } @keyframes sf-blink { 0% { background: #222; } 50% { background: #444; } 100% { background: #222; } } .sf-toolbar-block.sf-toolbar-block-dump .sf-toolbar-info { max-width: none; width: 100%; position: fixed; box-sizing: border-box; left: 0; } .sf-toolbar-block-dump pre.sf-dump { background-color: #222; border-color: #777; border-radius: 0; margin: 6px 0 12px 0; } .sf-toolbar-block-dump pre.sf-dump:last-child { margin-bottom: 0; } .sf-toolbar-block-dump pre.sf-dump .sf-dump-search-wrapper { margin-bottom: 5px; } .sf-toolbar-block-dump pre.sf-dump span.sf-dump-search-count { color: #333; font-size: 12px; } .sf-toolbar-block-dump .sf-toolbar-info-piece { display: block; } .sf-toolbar-block-dump .sf-toolbar-info-piece .sf-toolbar-file-line { color: #AAA; margin-left: 4px; } .sf-toolbar-block-dump .sf-toolbar-info img { display: none; } /* Override the setting when the toolbar is on the top */ {% if position == 'top' %} .sf-minitoolbar { border-bottom-left-radius: 4px; border-top-left-radius: 0; bottom: auto; right: 0; top: 0; } .sf-toolbarreset { bottom: auto; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); top: 0; } .sf-toolbar-block .sf-toolbar-info { bottom: auto; top: 36px; } {% endif %} {% if not floatable %} .sf-toolbarreset { position: static; } {% endif %} /* Responsive Design */ .sf-toolbar-icon .sf-toolbar-label, .sf-toolbar-icon .sf-toolbar-value { display: none; } .sf-toolbar-block-config .sf-toolbar-icon .sf-toolbar-label { display: inline-block; } /* Legacy Design - these styles are maintained to make old panels look a bit better on the new toolbar */ .sf-toolbar-block .sf-toolbar-info-piece-additional-detail { color: #AAA; font-size: 12px; } .sf-toolbar-status-green .sf-toolbar-info-piece-additional-detail, .sf-toolbar-status-yellow .sf-toolbar-info-piece-additional-detail, .sf-toolbar-status-red .sf-toolbar-info-piece-additional-detail { color: #FFF; } @media (min-width: 768px) { .sf-toolbar-icon .sf-toolbar-label, .sf-toolbar-icon .sf-toolbar-value { display: inline; } .sf-toolbar-block .sf-toolbar-icon img, .sf-toolbar-block .sf-toolbar-icon svg { top: 6px; } .sf-toolbar-block-time .sf-toolbar-icon svg, .sf-toolbar-block-memory .sf-toolbar-icon svg { display: none; } .sf-toolbar-block-time .sf-toolbar-icon svg + span, .sf-toolbar-block-memory .sf-toolbar-icon svg + span { margin-left: 0; } .sf-toolbar-block .sf-toolbar-icon { padding: 0 10px; } .sf-toolbar-block-time .sf-toolbar-icon { padding-right: 5px; } .sf-toolbar-block-memory .sf-toolbar-icon { padding-left: 5px; } .sf-toolbar-block-request .sf-toolbar-icon { padding-left: 0; padding-right: 0; } .sf-toolbar-block-request .sf-toolbar-label { margin-left: 5px; } .sf-toolbar-block-request .sf-toolbar-status + svg { margin-left: 5px; } .sf-toolbar-block-request .sf-toolbar-icon svg + .sf-toolbar-label { margin-left: 0; } .sf-toolbar-block-request .sf-toolbar-label + .sf-toolbar-value { margin-right: 10px; } .sf-toolbar-block-request:hover .sf-toolbar-info { max-width: none; } .sf-toolbar-block .sf-toolbar-info-piece b { font-size: 12px; } .sf-toolbar-block .sf-toolbar-info-piece span { font-size: 13px; } .sf-toolbar-block-right { float: right; margin-left: 0; margin-right: 0; } } @media (min-width: 1024px) { .sf-toolbar-block .sf-toolbar-info-piece-additional, .sf-toolbar-block .sf-toolbar-info-piece-additional-detail { display: inline-block; } .sf-toolbar-block .sf-toolbar-info-piece-additional:empty, .sf-toolbar-block .sf-toolbar-info-piece-additional-detail:empty { display: none; } } /***** Error Toolbar *****/ .sf-error-toolbar .sf-toolbarreset { background: #222; color: #f5f5f5; font: 13px/36px Arial, sans-serif; height: 36px; padding: 0 15px; text-align: left; } .sf-error-toolbar .sf-toolbarreset svg { height: auto; } .sf-error-toolbar .sf-toolbarreset a { color: #99cdd8; margin-left: 5px; text-decoration: underline; } .sf-error-toolbar .sf-toolbarreset a:hover { text-decoration: none; } .sf-error-toolbar .sf-toolbarreset .sf-toolbar-icon { float: left; padding: 5px 0; margin-right: 10px; } /***** Media query print: Do not print the Toolbar. *****/ @media print { .sf-toolbar { display: none; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig000066400000000000000000000024041324732107100324400ustar00rootroot00000000000000
    {% for name, template in templates %} {% if block('toolbar', template) is defined %} {% with { collector: profile.getcollector(name), profiler_url: profiler_url, token: profile.token, name: name, profiler_markup_version: profiler_markup_version, csp_script_nonce: csp_script_nonce, csp_style_nonce: csp_style_nonce } %} {{ block('toolbar', template) }} {% endwith %} {% endif %} {% endfor %} {{ include('@WebProfiler/Icon/close.svg') }}
    symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig000066400000000000000000000007431324732107100334620ustar00rootroot00000000000000
    {% if link is not defined or link %}{% endif %}
    {{ icon|default('') }}
    {% if link|default(false) %}
    {% endif %}
    {{ text|default('') }}
    symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig000066400000000000000000000172301324732107100331370ustar00rootroot00000000000000
    {{ include('@WebProfiler/Profiler/base_js.html.twig') }} {{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }} /* pageWidth) { toolbarInfo.style.left = 0; } else if (leftValue > 0 && rightValue > 0) { toolbarInfo.style.right = (rightValue * -1) + 'px'; } else if (leftValue < 0) { toolbarInfo.style.left = 0; } else { toolbarInfo.style.right = '0px'; } }; } Sfjs.addEventListener(document.getElementById('sfToolbarHideButton-{{ token }}'), 'click', function (event) { event.preventDefault(); var p = this.parentNode; p.style.display = 'none'; (p.previousElementSibling || p.previousSibling).style.display = 'none'; document.getElementById('sfMiniToolbar-{{ token }}').style.display = 'block'; Sfjs.setPreference('toolbar/displayState', 'none'); }); Sfjs.addEventListener(document.getElementById('sfToolbarMiniToggler-{{ token }}'), 'click', function (event) { event.preventDefault(); var elem = this.parentNode; if (elem.style.display == 'none') { document.getElementById('sfToolbarMainContent-{{ token }}').style.display = 'none'; document.getElementById('sfToolbarClearer-{{ token }}').style.display = 'none'; elem.style.display = 'block'; } else { document.getElementById('sfToolbarMainContent-{{ token }}').style.display = 'block'; document.getElementById('sfToolbarClearer-{{ token }}').style.display = 'block'; elem.style.display = 'none' } Sfjs.setPreference('toolbar/displayState', 'block'); }); Sfjs.renderAjaxRequests(); Sfjs.addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) { event.preventDefault(); Sfjs.toggleClass(this.parentNode, 'hover'); }); var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info'); if (null !== dumpInfo) { Sfjs.addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () { dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px'; }); Sfjs.addEventListener(dumpInfo, 'mouseleave', function () { dumpInfo.style.minHeight = ''; }); } }, function(xhr) { if (xhr.status !== 0) { var sfwdt = document.getElementById('sfwdt{{ token }}'); sfwdt.innerHTML = '\
    \
    \ An error occurred while loading the web debug toolbar. Open the web profiler.\
    \ '; sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar'); } }, { maxTries: 5 } ); })(); /*]]>*/ toolbar_redirect.html.twig000066400000000000000000000010741324732107100342440ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler{% extends '@Twig/layout.html.twig' %} {% block title 'Redirection Intercepted' %} {% block body %}

    This request redirects to {{ location }}.

    The redirect was intercepted by the web debug toolbar to help debugging. For more information, see the "intercept-redirects" option of the Profiler.

    {% endblock %} symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/000077500000000000000000000000001324732107100266355ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/panel.html.twig000066400000000000000000000044541324732107100316020ustar00rootroot00000000000000

    Routing

    {{ request.route ?: '(none)' }} Matched route
    {% if request.route %}
    {{ traces|length }} Tested routes before match
    {% endif %}
    {% if request.route %}

    Route Parameters

    {% if request.routeParams is empty %}

    No parameters.

    {% else %} {{ include('@WebProfiler/Profiler/table.html.twig', { data: request.routeParams, labels: ['Name', 'Value'] }, with_context = false) }} {% endif %} {% endif %} {% if router.redirect %}

    Route Redirection

    This page redirects to:

    {{ router.targetUrl }} {% if router.targetRoute %}(route: "{{ router.targetRoute }}"){% endif %}
    {% endif %}

    Route Matching Logs

    Path to match: {{ request.pathinfo }}
    {% for trace in traces %} {% endfor %}
    # Route name Path Log
    {{ loop.index }} {{ trace.name }} {{ trace.path }} {% if trace.level == 1 %} Path almost matches, but {{ trace.log }} {% elseif trace.level == 2 %} {{ trace.log }} {% else %} Path does not match {% endif %}

    Note: These matching logs are based on the current router configuration, which might differ from the configuration used when profiling this request.

    symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/000077500000000000000000000000001324732107100233505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/000077500000000000000000000000001324732107100254735ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php000066400000000000000000000157041324732107100327010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpFoundation\Request; class ProfilerControllerTest extends TestCase { /** * @dataProvider getEmptyTokenCases */ public function testEmptyToken($token) { $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); $controller = new ProfilerController($urlGenerator, $profiler, $twig, array()); $response = $controller->toolbarAction(Request::create('/_wdt/empty'), $token); $this->assertEquals(200, $response->getStatusCode()); } public function getEmptyTokenCases() { return array( array(null), // "empty" is also a valid empty token case, see https://github.com/symfony/symfony/issues/10806 array('empty'), ); } /** * @dataProvider getOpenFileCases */ public function testOpeningDisallowedPaths($path, $isAllowed) { $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); $controller = new ProfilerController($urlGenerator, $profiler, $twig, array(), 'bottom', null, __DIR__.'/../..'); try { $response = $controller->openAction(Request::create('/_wdt/open', Request::METHOD_GET, array('file' => $path))); $this->assertEquals(200, $response->getStatusCode()); $this->assertTrue($isAllowed); } catch (NotFoundHttpException $e) { $this->assertFalse($isAllowed); } } public function getOpenFileCases() { return array( array('README.md', true), array('composer.json', true), array('Controller/ProfilerController.php', true), array('.gitignore', false), array('../TwigBundle/README.md', false), array('Controller/../README.md', false), array('Controller/./ProfilerController.php', false), ); } /** * @dataProvider provideCspVariants */ public function testReturns404onTokenNotFound($withCsp) { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); $profiler ->expects($this->exactly(2)) ->method('loadProfile') ->will($this->returnCallback(function ($token) { if ('found' == $token) { return new Profile($token); } })) ; $controller = $this->createController($profiler, $twig, $withCsp); $response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found'); $this->assertEquals(200, $response->getStatusCode()); $response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound'); $this->assertEquals(404, $response->getStatusCode()); } /** * @dataProvider provideCspVariants */ public function testSearchResult($withCsp) { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); $controller = $this->createController($profiler, $twig, $withCsp); $tokens = array( array( 'token' => 'token1', 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/', 'time' => 0, 'parent' => null, 'status_code' => 200, ), array( 'token' => 'token2', 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/not_found', 'time' => 0, 'parent' => null, 'status_code' => 404, ), ); $profiler ->expects($this->once()) ->method('find') ->will($this->returnValue($tokens)); $request = Request::create('/_profiler/empty/search/results', 'GET', array( 'limit' => 2, 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/', )); $twig->expects($this->once()) ->method('render') ->with($this->stringEndsWith('results.html.twig'), $this->equalTo(array( 'token' => 'empty', 'profile' => null, 'tokens' => $tokens, 'ip' => '127.0.0.1', 'method' => 'GET', 'status_code' => null, 'url' => 'http://example.com/', 'start' => null, 'end' => null, 'limit' => 2, 'panel' => null, 'request' => $request, ))); $response = $controller->searchResultsAction($request, 'empty'); $this->assertEquals(200, $response->getStatusCode()); } public function provideCspVariants() { return array( array(true), array(false), ); } private function createController($profiler, $twig, $withCSP) { $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); if ($withCSP) { $nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock(); return new ProfilerController($urlGenerator, $profiler, $twig, array(), 'bottom', new ContentSecurityPolicyHandler($nonceGenerator)); } return new ProfilerController($urlGenerator, $profiler, $twig, array()); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/000077500000000000000000000000001324732107100240755ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php000066400000000000000000000247261324732107100333010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\Csp; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class ContentSecurityPolicyHandlerTest extends TestCase { /** * @dataProvider provideRequestAndResponses */ public function testGetNonces($nonce, $expectedNonce, Request $request, Response $response) { $cspHandler = new ContentSecurityPolicyHandler($this->mockNonceGenerator($nonce)); $this->assertSame($expectedNonce, $cspHandler->getNonces($request, $response)); } /** * @dataProvider provideRequestAndResponsesForOnKernelResponse */ public function testOnKernelResponse($nonce, $expectedNonce, Request $request, Response $response, array $expectedCsp) { $cspHandler = new ContentSecurityPolicyHandler($this->mockNonceGenerator($nonce)); $this->assertSame($expectedNonce, $cspHandler->updateResponseHeaders($request, $response)); $this->assertFalse($response->headers->has('X-SymfonyProfiler-Script-Nonce')); $this->assertFalse($response->headers->has('X-SymfonyProfiler-Style-Nonce')); foreach ($expectedCsp as $header => $value) { $this->assertSame($value, $response->headers->get($header)); } } public function provideRequestAndResponses() { $nonce = bin2hex(random_bytes(16)); $requestScriptNonce = 'request-with-headers-script-nonce'; $requestStyleNonce = 'request-with-headers-style-nonce'; $responseScriptNonce = 'response-with-headers-script-nonce'; $responseStyleNonce = 'response-with-headers-style-nonce'; $requestNonceHeaders = array( 'X-SymfonyProfiler-Script-Nonce' => $requestScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $requestStyleNonce, ); $responseNonceHeaders = array( 'X-SymfonyProfiler-Script-Nonce' => $responseScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $responseStyleNonce, ); return array( array($nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse()), array($nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse($responseNonceHeaders)), array($nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse()), array($nonce, array('csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce), $this->createRequest(), $this->createResponse($responseNonceHeaders)), ); } public function provideRequestAndResponsesForOnKernelResponse() { $nonce = bin2hex(random_bytes(16)); $requestScriptNonce = 'request-with-headers-script-nonce'; $requestStyleNonce = 'request-with-headers-style-nonce'; $responseScriptNonce = 'response-with-headers-script-nonce'; $responseStyleNonce = 'response-with-headers-style-nonce'; $requestNonceHeaders = array( 'X-SymfonyProfiler-Script-Nonce' => $requestScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $requestStyleNonce, ); $responseNonceHeaders = array( 'X-SymfonyProfiler-Script-Nonce' => $responseScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $responseStyleNonce, ); return array( array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(), array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse($responseNonceHeaders), array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse(), array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce), $this->createRequest(), $this->createResponse($responseNonceHeaders), array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:')), array('Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:', 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'')), array('Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain-report-only.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'')), array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'')), array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'')), array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\'')), array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\'')), array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null), ), array( $nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\'')), array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\''), ), ); } private function createRequest(array $headers = array()) { $request = new Request(); $request->headers->add($headers); return $request; } private function createResponse(array $headers = array()) { $response = new Response(); $response->headers->add($headers); return $response; } private function mockNonceGenerator($value) { $generator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock(); $generator->expects($this->any()) ->method('generate') ->will($this->returnValue($value)); return $generator; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/000077500000000000000000000000001324732107100272715ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php000066400000000000000000000054511324732107100334560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\DependencyInjection\Configuration; use Symfony\Component\Config\Definition\Processor; class ConfigurationTest extends TestCase { /** * @dataProvider getDebugModes */ public function testConfigTree($options, $results) { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, array($options)); $this->assertEquals($results, $config); } /** * @dataProvider getPositionConfig * @group legacy * @expectedDeprecation The "web_profiler.position" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0. */ public function testPositionConfig($options, $results) { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, array($options)); $this->assertEquals($results, $config); } public function getDebugModes() { return array( array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt')), array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt')), array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt')), array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt')), array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')), ); } public function getPositionConfig() { return array( array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', 'position' => 'top')), array(array('position' => 'bottom'), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', 'position' => 'bottom')), ); } } WebProfilerExtensionTest.php000066400000000000000000000121711324732107100347020ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\DependencyInjection; use Symfony\Bundle\WebProfilerBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\DependencyInjection\WebProfilerExtension; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; use Symfony\Component\EventDispatcher\EventDispatcher; class WebProfilerExtensionTest extends TestCase { private $kernel; /** * @var \Symfony\Component\DependencyInjection\Container */ private $container; public static function assertSaneContainer(Container $container, $message = '', $knownPrivates = array()) { $errors = array(); foreach ($container->getServiceIds() as $id) { if (in_array($id, $knownPrivates, true)) { // to be removed in 4.0 continue; } try { $container->get($id); } catch (\Exception $e) { $errors[$id] = $e->getMessage(); } } self::assertEquals(array(), $errors, $message); } protected function setUp() { parent::setUp(); $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); $this->container = new ContainerBuilder(); $this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true); $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true); $this->container->register('twig', 'Twig\Environment')->setPublic(true); $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array())->setPublic(true); $this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'))->setPublic(true); $this->container->setParameter('kernel.bundles', array()); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); $this->container->setParameter('kernel.project_dir', __DIR__); $this->container->setParameter('kernel.charset', 'UTF-8'); $this->container->setParameter('debug.file_link_format', null); $this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')); $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) ->setPublic(true) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); $this->container->setParameter('data_collector.templates', array()); $this->container->set('kernel', $this->kernel); $this->container->addCompilerPass(new RegisterListenersPass()); } protected function tearDown() { parent::tearDown(); $this->container = null; $this->kernel = null; } /** * @dataProvider getDebugModes */ public function testDefaultConfig($debug) { $this->container->setParameter('kernel.debug', $debug); $extension = new WebProfilerExtension(); $extension->load(array(array()), $this->container); $this->assertFalse($this->container->has('web_profiler.debug_toolbar')); $this->assertSaneContainer($this->getCompiledContainer()); } /** * @dataProvider getDebugModes */ public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listenerInjected, $listenerEnabled) { $extension = new WebProfilerExtension(); $extension->load(array(array('toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects)), $this->container); $this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar')); $this->assertSaneContainer($this->getCompiledContainer(), '', array('web_profiler.csp.handler')); if ($listenerInjected) { $this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled()); } } public function getDebugModes() { return array( array(false, false, false, false), array(true, false, true, true), array(false, true, true, false), array(true, true, true, true), ); } private function getCompiledContainer() { if ($this->container->has('web_profiler.debug_toolbar')) { $this->container->getDefinition('web_profiler.debug_toolbar')->setPublic(true); } $this->container->compile(); $this->container->set('kernel', $this->kernel); return $this->container; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/000077500000000000000000000000001324732107100261375ustar00rootroot00000000000000WebDebugToolbarListenerTest.php000066400000000000000000000313201324732107100341450ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\EventListener; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class WebDebugToolbarListenerTest extends TestCase { /** * @dataProvider getInjectToolbarTests */ public function testInjectToolbar($content, $expected) { $listener = new WebDebugToolbarListener($this->getTwigMock()); $m = new \ReflectionMethod($listener, 'injectToolbar'); $m->setAccessible(true); $response = new Response($content); $m->invoke($listener, $response, Request::create('/'), array('csp_script_nonce' => 'scripto', 'csp_style_nonce' => 'stylo')); $this->assertEquals($expected, $response->getContent()); } public function getInjectToolbarTests() { return array( array('', "\nWDT\n"), array(' ', " \nWDT\n "), ); } /** * @dataProvider provideRedirects */ public function testRedirectionIsIntercepted($statusCode, $hasSession) { $response = new Response('Some content', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('Redirection', $response->getContent()); } public function testToolbarIsInjected() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals("\nWDT\n", $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedOnNonHtmlContentType() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Type', 'text/xml'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedOnContentDispositionAttachment() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Disposition', 'attachment; filename=test.html'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html'), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } /** * @depends testToolbarIsInjected * @dataProvider provideRedirects */ public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession) { $response = new Response('', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } public function provideRedirects() { return array( array(301, true), array(302, true), array(301, false), array(302, false), ); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader() { $response = new Response(''); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedWhenOnSubRequest() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses() { $response = new Response('
    Some content
    '); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('
    Some content
    ', $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedOnXmlHttpRequests() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(true), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } /** * @depends testToolbarIsInjected */ public function testToolbarIsNotInjectedOnNonHtmlRequests() { $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'json'), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); $this->assertEquals('', $response->getContent()); } public function testXDebugUrlHeader() { $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $urlGenerator = $this->getUrlGeneratorMock(); $urlGenerator ->expects($this->once()) ->method('generate') ->with('_profiler', array('token' => 'xxxxxxxx'), UrlGeneratorInterface::ABSOLUTE_URL) ->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx')) ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator); $listener->onKernelResponse($event); $this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link')); } public function testThrowingUrlGenerator() { $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $urlGenerator = $this->getUrlGeneratorMock(); $urlGenerator ->expects($this->once()) ->method('generate') ->with('_profiler', array('token' => 'xxxxxxxx')) ->will($this->throwException(new \Exception('foo'))) ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator); $listener->onKernelResponse($event); $this->assertEquals('Exception: foo', $response->headers->get('X-Debug-Error')); } public function testThrowingErrorCleanup() { $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $urlGenerator = $this->getUrlGeneratorMock(); $urlGenerator ->expects($this->once()) ->method('generate') ->with('_profiler', array('token' => 'xxxxxxxx')) ->will($this->throwException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))) ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator); $listener->onKernelResponse($event); $this->assertEquals('Exception: This multiline tabbed text should come out on a single plain line', $response->headers->get('X-Debug-Error')); } protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') ->will($this->returnValue($isXmlHttpRequest)); $request->expects($this->any()) ->method('getRequestFormat') ->will($this->returnValue($requestFormat)); $request->headers = new HeaderBag(); if ($hasSession) { $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getSession') ->will($this->returnValue($session)); } return $request; } protected function getTwigMock($render = 'WDT') { $templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $templating->expects($this->any()) ->method('render') ->will($this->returnValue($render)); return $templating; } protected function getUrlGeneratorMock() { return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); } protected function getKernelMock() { return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/000077500000000000000000000000001324732107100251615ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/profile.data000066400000000000000000000014001324732107100274470ustar00rootroot00000000000000Tzo0NToiU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlIjo4OntzOjUyOiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAHRva2VuIjtzOjU6IlRPS0VOIjtzOjUzOiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAHBhcmVudCI7TjtzOjU1OiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAGNoaWxkcmVuIjthOjA6e31zOjU3OiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAGNvbGxlY3RvcnMiO2E6MDp7fXM6NDk6IgBTeW1mb255XENvbXBvbmVudFxIdHRwS2VybmVsXFByb2ZpbGVyXFByb2ZpbGUAaXAiO047czo1MzoiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQBtZXRob2QiO047czo1MDoiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQB1cmwiO047czo1MToiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQB0aW1lIjtOO30=symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/000077500000000000000000000000001324732107100251325ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php000066400000000000000000000113241324732107100315520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\Profiler; use Symfony\Bundle\WebProfilerBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; use Twig\Environment; /** * Test for TemplateManager class. * * @author Artur Wielogórski */ class TemplateManagerTest extends TestCase { /** * @var Environment */ protected $twigEnvironment; /** * @var \Symfony\Component\HttpKernel\Profiler\Profiler */ protected $profiler; /** * @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager */ protected $templateManager; protected function setUp() { parent::setUp(); $profiler = $this->mockProfiler(); $twigEnvironment = $this->mockTwigEnvironment(); $templates = array( 'data_collector.foo' => array('foo', 'FooBundle:Collector:foo'), 'data_collector.bar' => array('bar', 'FooBundle:Collector:bar'), 'data_collector.baz' => array('baz', 'FooBundle:Collector:baz'), ); $this->templateManager = new TemplateManager($profiler, $twigEnvironment, $templates); } /** * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function testGetNameOfInvalidTemplate() { $profile = $this->mockProfile(); $this->templateManager->getName($profile, 'notexistingpanel'); } /** * if template exists in both profile and profiler then its name should be returned. */ public function testGetNameValidTemplate() { $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() ->will($this->returnCallback(array($this, 'profilerHasCallback'))); $profile = $this->mockProfile(); $profile->expects($this->any()) ->method('hasCollector') ->will($this->returnCallback(array($this, 'profileHasCollectorCallback'))); $this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName($profile, 'foo')); } /** * template should be loaded for 'foo' because other collectors are * missing in profile or in profiler. */ public function testGetTemplates() { $profile = $this->mockProfile(); $profile->expects($this->any()) ->method('hasCollector') ->will($this->returnCallback(array($this, 'profilerHasCallback'))); $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() ->will($this->returnCallback(array($this, 'profileHasCollectorCallback'))); $result = $this->templateManager->getTemplates($profile); $this->assertArrayHasKey('foo', $result); $this->assertArrayNotHasKey('bar', $result); $this->assertArrayNotHasKey('baz', $result); } public function profilerHasCallback($panel) { switch ($panel) { case 'foo': case 'bar': return true; default: return false; } } public function profileHasCollectorCallback($panel) { switch ($panel) { case 'foo': case 'baz': return true; default: return false; } } protected function mockProfile() { return $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')->disableOriginalConstructor()->getMock(); } protected function mockTwigEnvironment() { $this->twigEnvironment = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $this->twigEnvironment->expects($this->any()) ->method('loadTemplate') ->will($this->returnValue('loadedTemplate')); if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) { $loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock(); } else { $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); } $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); return $this->twigEnvironment; } protected function mockProfiler() { $this->profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); return $this->profiler; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/000077500000000000000000000000001324732107100253225ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php000066400000000000000000000020351324732107100275630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources; use PHPUnit\Framework\TestCase; class IconTest extends TestCase { /** * @dataProvider provideIconFilePaths */ public function testIconFileContents($iconFilePath) { $this->assertRegExp('~.*~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath)); } public function provideIconFilePaths() { return array_map(function ($filePath) { return (array) $filePath; }, glob(__DIR__.'/../../Resources/views/Icon/*.svg')); } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Tests/TestCase.php000066400000000000000000000006001324732107100255700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Tests; use PHPUnit\Framework\TestCase as PHPUnitTestCase; class TestCase extends PHPUnitTestCase { } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Twig/000077500000000000000000000000001324732107100231605ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php000066400000000000000000000074171324732107100300170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle\Twig; use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Twig\Environment; use Twig\Extension\ProfilerExtension; use Twig\Profiler\Profile; use Twig\TwigFunction; /** * Twig extension for the profiler. * * @author Fabien Potencier */ class WebProfilerExtension extends ProfilerExtension { /** * @var ValueExporter */ private $valueExporter; /** * @var HtmlDumper */ private $dumper; /** * @var resource */ private $output; /** * @var int */ private $stackLevel = 0; public function __construct(HtmlDumper $dumper = null) { $this->dumper = $dumper ?: new HtmlDumper(); $this->dumper->setOutput($this->output = fopen('php://memory', 'r+b')); } public function enter(Profile $profile) { ++$this->stackLevel; } public function leave(Profile $profile) { if (0 === --$this->stackLevel) { $this->dumper->setOutput($this->output = fopen('php://memory', 'r+b')); } } /** * {@inheritdoc} */ public function getFunctions() { $profilerDump = function (Environment $env, $value, $maxDepth = 0) { return $value instanceof Data ? $this->dumpData($env, $value, $maxDepth) : twig_escape_filter($env, $this->dumpValue($value)); }; return array( new TwigFunction('profiler_dump', $profilerDump, array('is_safe' => array('html'), 'needs_environment' => true)), new TwigFunction('profiler_dump_log', array($this, 'dumpLog'), array('is_safe' => array('html'), 'needs_environment' => true)), ); } public function dumpData(Environment $env, Data $data, $maxDepth = 0) { $this->dumper->setCharset($env->getCharset()); $this->dumper->dump($data, null, array( 'maxDepth' => $maxDepth, )); $dump = stream_get_contents($this->output, -1, 0); rewind($this->output); ftruncate($this->output, 0); return str_replace("\n$1"', $message); if (null === $context || false === strpos($message, '{')) { return ''.$message.''; } $replacements = array(); foreach ($context as $k => $v) { $k = '{'.twig_escape_filter($env, $k).'}'; $replacements['"'.$k.'"'] = $replacements['"'.$k.'"'] = $replacements[$k] = $this->dumpData($env, $v); } return ''.strtr($message, $replacements).''; } /** * @deprecated since 3.2, to be removed in 4.0. Use the dumpData() method instead. */ public function dumpValue($value) { @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use the dumpData() method instead.', __METHOD__), E_USER_DEPRECATED); if (null === $this->valueExporter) { $this->valueExporter = new ValueExporter(); } return $this->valueExporter->exportValue($value); } /** * {@inheritdoc} */ public function getName() { return 'profiler'; } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php000066400000000000000000000006761324732107100263420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebProfilerBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Bundle. * * @author Fabien Potencier */ class WebProfilerBundle extends Bundle { } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/composer.json000066400000000000000000000026521324732107100247750ustar00rootroot00000000000000{ "name": "symfony/web-profiler-bundle", "type": "symfony-bundle", "description": "Symfony WebProfilerBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/http-kernel": "~3.3|~4.0", "symfony/polyfill-php70": "~1.0", "symfony/routing": "~2.8|~3.0|~4.0", "symfony/twig-bridge": "~2.8|~3.0|~4.0", "symfony/var-dumper": "~3.3|~4.0", "twig/twig": "~1.34|~2.4" }, "require-dev": { "symfony/config": "~3.4|~4.0", "symfony/console": "~2.8|~3.0|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "conflict": { "symfony/config": "<3.4", "symfony/dependency-injection": "<3.4", "symfony/event-dispatcher": "<3.3.1", "symfony/var-dumper": "<3.3" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist000066400000000000000000000015651324732107100254300ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/000077500000000000000000000000001324732107100217325ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/CHANGELOG.md000066400000000000000000000002131324732107100235370ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * WebServer can now use '*' as a wildcard to bind to 0.0.0.0 (INADDR_ANY) 3.3.0 ----- * Added bundle symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/000077500000000000000000000000001324732107100233105ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerCommand.php000066400000000000000000000012511324732107100265650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Symfony\Component\Console\Command\Command; /** * Base methods for commands related to a local web server. * * @author Christian Flothmann * * @internal */ abstract class ServerCommand extends Command { /** * {@inheritdoc} */ public function isEnabled() { return !defined('HHVM_VERSION') && parent::isEnabled(); } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php000066400000000000000000000121751324732107100272360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Monolog\Formatter\FormatterInterface; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; /** * @author Grégoire Pineau */ class ServerLogCommand extends Command { private static $bgColor = array('black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'); private $el; private $handler; protected static $defaultName = 'server:log'; public function isEnabled() { if (!class_exists(ConsoleFormatter::class)) { return false; } // based on a symfony/symfony package, it crashes due a missing FormatterInterface from monolog/monolog if (!interface_exists(FormatterInterface::class)) { return false; } return parent::isEnabled(); } protected function configure() { if (!class_exists(ConsoleFormatter::class)) { return; } $this ->addOption('host', null, InputOption::VALUE_REQUIRED, 'The server host', '0.0.0.0:9911') ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The line format', ConsoleFormatter::SIMPLE_FORMAT) ->addOption('date-format', null, InputOption::VALUE_REQUIRED, 'The date format', ConsoleFormatter::SIMPLE_DATE) ->addOption('filter', null, InputOption::VALUE_REQUIRED, 'An expression to filter log. Example: "level > 200 or channel in [\'app\', \'doctrine\']"') ->setDescription('Starts a log server that displays logs in real time') ->setHelp(<<<'EOF' %command.name% starts a log server to display in real time the log messages generated by your application: php %command.full_name% To get the information as a machine readable format, use the --filter option: php %command.full_name% --filter=port EOF ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $filter = $input->getOption('filter'); if ($filter) { if (!class_exists(ExpressionLanguage::class)) { throw new \LogicException('Package "symfony/expression-language" is required to use the "filter" option.'); } $this->el = new ExpressionLanguage(); } $this->handler = new ConsoleHandler($output); $this->handler->setFormatter(new ConsoleFormatter(array( 'format' => str_replace('\n', "\n", $input->getOption('format')), 'date_format' => $input->getOption('date-format'), 'colors' => $output->isDecorated(), 'multiline' => OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity(), ))); if (false === strpos($host = $input->getOption('host'), '://')) { $host = 'tcp://'.$host; } if (!$socket = stream_socket_server($host, $errno, $errstr)) { throw new \RuntimeException(sprintf('Server start failed on "%s": %s %s.', $host, $errstr, $errno)); } foreach ($this->getLogs($socket) as $clientId => $message) { $record = unserialize(base64_decode($message)); // Impossible to decode the message, give up. if (false === $record) { continue; } if ($filter && !$this->el->evaluate($filter, $record)) { continue; } $this->displayLog($input, $output, $clientId, $record); } } private function getLogs($socket) { $sockets = array((int) $socket => $socket); $write = array(); while (true) { $read = $sockets; stream_select($read, $write, $write, null); foreach ($read as $stream) { if ($socket === $stream) { $stream = stream_socket_accept($socket); $sockets[(int) $stream] = $stream; } elseif (feof($stream)) { unset($sockets[(int) $stream]); fclose($stream); } else { yield (int) $stream => fgets($stream); } } } } private function displayLog(InputInterface $input, OutputInterface $output, $clientId, array $record) { if ($this->handler->isHandling($record)) { if (isset($record['log_id'])) { $clientId = unpack('H*', $record['log_id'])[1]; } $logBlock = sprintf(' ', self::$bgColor[$clientId % 8]); $output->write($logBlock); } $this->handler->handle($record); } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php000066400000000000000000000123541324732107100272600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Symfony\Bundle\WebServerBundle\WebServer; use Symfony\Bundle\WebServerBundle\WebServerConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Process\Process; /** * Runs Symfony application using a local web server. * * @author Michał Pipa */ class ServerRunCommand extends ServerCommand { private $documentRoot; private $environment; protected static $defaultName = 'server:run'; public function __construct($documentRoot = null, $environment = null) { $this->documentRoot = $documentRoot; $this->environment = $environment; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'), new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root, usually where your front controllers are stored'), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), )) ->setDescription('Runs a local web server') ->setHelp(<<<'EOF' %command.name% runs a local web server: By default, the server listens on 127.0.0.1 address and the port number is automatically selected as the first free port starting from 8000: %command.full_name% This command blocks the console. If you want to run other commands, stop it by pressing Control+C or use the non-blocking server:start command instead. Change the default address and port by passing them as an argument: %command.full_name% 127.0.0.1:8080 Use the --docroot option to change the default docroot directory: %command.full_name% --docroot=htdocs/ Specify your own router script via the --router option: %command.full_name% --router=app/config/router.php See also: http://www.php.net/manual/en/features.commandline.webserver.php EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); // deprecated, logic to be removed in 4.0 // this allows the commands to work out of the box with web/ and public/ if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) { $this->documentRoot = dirname($this->documentRoot).'/web'; } if (null === $documentRoot = $input->getOption('docroot')) { if (!$this->documentRoot) { $io->error('The document root directory must be either passed as first argument of the constructor or through the "--docroot" input option.'); return 1; } $documentRoot = $this->documentRoot; } if (!$env = $this->environment) { if ($input->hasOption('env') && !$env = $input->getOption('env')) { $io->error('The environment must be either passed as second argument of the constructor or through the "--env" input option.'); return 1; } else { $io->error('The environment must be passed as second argument of the constructor.'); return 1; } } if ('prod' === $env) { $io->error('Running this server in production environment is NOT recommended!'); } $callback = null; $disableOutput = false; if ($output->isQuiet()) { $disableOutput = true; } else { $callback = function ($type, $buffer) use ($output) { if (Process::ERR === $type && $output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $output->write($buffer, false, OutputInterface::OUTPUT_RAW); }; } try { $server = new WebServer(); $config = new WebServerConfig($documentRoot, $env, $input->getArgument('addressport'), $input->getOption('router')); $io->success(sprintf('Server listening on http://%s', $config->getAddress())); $io->comment('Quit the server with CONTROL-C.'); $exitCode = $server->run($config, $disableOutput, $callback); } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } return $exitCode; } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php000066400000000000000000000133341324732107100276100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Symfony\Bundle\WebServerBundle\WebServer; use Symfony\Bundle\WebServerBundle\WebServerConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\EventDispatcher; /** * Runs a local web server in a background process. * * @author Christian Flothmann */ class ServerStartCommand extends ServerCommand { private $documentRoot; private $environment; protected static $defaultName = 'server:start'; public function __construct($documentRoot = null, $environment = null) { $this->documentRoot = $documentRoot; $this->environment = $environment; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'), new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root'), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), )) ->setDescription('Starts a local web server in the background') ->setHelp(<<<'EOF' %command.name% runs a local web server: By default, the server listens on 127.0.0.1 address and the port number is automatically selected as the first free port starting from 8000: php %command.full_name% The server is run in the background and you can keep executing other commands. Execute server:stop to stop it. Change the default address and port by passing them as an argument: php %command.full_name% 127.0.0.1:8080 Use the --docroot option to change the default docroot directory: php %command.full_name% --docroot=htdocs/ Specify your own router script via the --router option: php %command.full_name% --router=app/config/router.php See also: http://www.php.net/manual/en/features.commandline.webserver.php EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); if (!extension_loaded('pcntl')) { $io->error(array( 'This command needs the pcntl extension to run.', 'You can either install it or use the "server:run" command instead.', )); if ($io->confirm('Do you want to execute server:run immediately?', false)) { return $this->getApplication()->find('server:run')->run($input, $output); } return 1; } // deprecated, logic to be removed in 4.0 // this allows the commands to work out of the box with web/ and public/ if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) { $this->documentRoot = dirname($this->documentRoot).'/web'; } if (null === $documentRoot = $input->getOption('docroot')) { if (!$this->documentRoot) { $io->error('The document root directory must be either passed as first argument of the constructor or through the "docroot" input option.'); return 1; } $documentRoot = $this->documentRoot; } if (!$env = $this->environment) { if ($input->hasOption('env') && !$env = $input->getOption('env')) { $io->error('The environment must be either passed as second argument of the constructor or through the "--env" input option.'); return 1; } else { $io->error('The environment must be passed as second argument of the constructor.'); return 1; } } if ('prod' === $env) { $io->error('Running this server in production environment is NOT recommended!'); } // replace event dispatcher with an empty one to prevent console.terminate from firing // as container could have changed between start and stop $this->getApplication()->setDispatcher(new EventDispatcher()); try { $server = new WebServer(); if ($server->isRunning($input->getOption('pidfile'))) { $io->error(sprintf('The web server is already running (listening on http://%s).', $server->getAddress($input->getOption('pidfile')))); return 1; } $config = new WebServerConfig($documentRoot, $env, $input->getArgument('addressport'), $input->getOption('router')); if (WebServer::STARTED === $server->start($config, $input->getOption('pidfile'))) { $io->success(sprintf('Server listening on http://%s', $config->getAddress())); } } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php000066400000000000000000000061271324732107100300000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Symfony\Bundle\WebServerBundle\WebServer; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; /** * Shows the status of a process that is running PHP's built-in web server in * the background. * * @author Christian Flothmann */ class ServerStatusCommand extends ServerCommand { protected static $defaultName = 'server:status'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'The value to display (one of port, host, or address)'), )) ->setDescription('Outputs the status of the local web server for the given address') ->setHelp(<<<'EOF' %command.name% shows the details of the given local web server, such as the address and port where it is listening to: php %command.full_name% To get the information as a machine readable format, use the --filter option: php %command.full_name% --filter=port Supported values are port, host, and address. EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); $server = new WebServer(); if ($filter = $input->getOption('filter')) { if ($server->isRunning($input->getOption('pidfile'))) { list($host, $port) = explode(':', $address = $server->getAddress($input->getOption('pidfile'))); if ('address' === $filter) { $output->write($address); } elseif ('host' === $filter) { $output->write($host); } elseif ('port' === $filter) { $output->write($port); } else { throw new \InvalidArgumentException(sprintf('"%s" is not a valid filter.', $filter)); } } else { return 1; } } else { if ($server->isRunning($input->getOption('pidfile'))) { $io->success(sprintf('Web server still listening on http://%s', $server->getAddress($input->getOption('pidfile')))); } else { $io->warning('No web server is listening.'); return 1; } } } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php000066400000000000000000000035031324732107100274350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Command; use Symfony\Bundle\WebServerBundle\WebServer; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Style\SymfonyStyle; /** * Stops a background process running a local web server. * * @author Christian Flothmann */ class ServerStopCommand extends ServerCommand { protected static $defaultName = 'server:stop'; /** * {@inheritdoc} */ protected function configure() { $this ->setDefinition(array( new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), )) ->setDescription('Stops the local web server that was started with the server:start command') ->setHelp(<<<'EOF' %command.name% stops the local web server: php %command.full_name% EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); try { $server = new WebServer(); $server->stop($input->getOption('pidfile')); $io->success('Stopped the web server.'); } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/DependencyInjection/000077500000000000000000000000001324732107100256535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php000066400000000000000000000020321324732107100321620ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\DependencyInjection; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; /** * @author Robin Chalas */ class WebServerExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('webserver.xml'); if (!class_exists(ConsoleFormatter::class)) { $container->removeDefinition('web_server.command.server_log'); } } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/LICENSE000066400000000000000000000020511324732107100227350ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/README.md000066400000000000000000000011041324732107100232050ustar00rootroot00000000000000WebServerBundle =============== WebServerBundle provides commands for running applications using the PHP built-in web server. It simplifies your local development setup because you don't have to configure a proper web server such as Apache or Nginx to run your application. Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Resources/000077500000000000000000000000001324732107100237045ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Resources/config/000077500000000000000000000000001324732107100251515ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Resources/config/webserver.xml000066400000000000000000000030731324732107100277020ustar00rootroot00000000000000 %kernel.project_dir%/public %kernel.environment% %kernel.project_dir%/public %kernel.environment% symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Resources/router.php000066400000000000000000000027661324732107100257500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* * This file implements rewrite rules for PHP built-in web server. * * See: http://www.php.net/manual/en/features.commandline.webserver.php * * If you have custom directory layout, then you have to write your own router * and pass it as a value to 'router' option of server:run command. * * @author: Michał Pipa * @author: Albert Jessurum */ // Workaround https://bugs.php.net/64566 if (ini_get('auto_prepend_file') && !in_array(realpath(ini_get('auto_prepend_file')), get_included_files(), true)) { require ini_get('auto_prepend_file'); } if (is_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$_SERVER['SCRIPT_NAME'])) { return false; } $script = isset($_ENV['APP_FRONT_CONTROLLER']) ? $_ENV['APP_FRONT_CONTROLLER'] : 'index.php'; $_SERVER = array_merge($_SERVER, $_ENV); $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$script; // Since we are rewriting to app_dev.php, adjust SCRIPT_NAME and PHP_SELF accordingly $_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR.$script; $_SERVER['PHP_SELF'] = DIRECTORY_SEPARATOR.$script; require $script; error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4); symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Tests/000077500000000000000000000000001324732107100230345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/000077500000000000000000000000001324732107100267555ustar00rootroot00000000000000WebServerExtensionTest.php000066400000000000000000000022741324732107100340550ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Bundle\WebServerBundle\DependencyInjection\WebServerExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; class WebServerExtensionTest extends TestCase { public function testLoad() { $container = new ContainerBuilder(); (new WebServerExtension())->load(array(), $container); $this->assertTrue($container->hasDefinition('web_server.command.server_run')); $this->assertTrue($container->hasDefinition('web_server.command.server_start')); $this->assertTrue($container->hasDefinition('web_server.command.server_stop')); $this->assertTrue($container->hasDefinition('web_server.command.server_status')); $this->assertSame(class_exists(ConsoleFormatter::class), $container->hasDefinition('web_server.command.server_log')); } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/WebServer.php000066400000000000000000000112221324732107100243450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle; use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\RuntimeException; /** * Manages a local HTTP web server. * * @author Fabien Potencier */ class WebServer { const STARTED = 0; const STOPPED = 1; public function run(WebServerConfig $config, $disableOutput = true, callable $callback = null) { if ($this->isRunning()) { throw new \RuntimeException(sprintf('A process is already listening on http://%s.', $config->getAddress())); } $process = $this->createServerProcess($config); if ($disableOutput) { $process->disableOutput(); $callback = null; } else { try { $process->setTty(true); $callback = null; } catch (RuntimeException $e) { } } $process->run($callback); if (!$process->isSuccessful()) { $error = 'Server terminated unexpectedly.'; if ($process->isOutputDisabled()) { $error .= ' Run the command again with -v option for more details.'; } throw new \RuntimeException($error); } } public function start(WebServerConfig $config, $pidFile = null) { $pidFile = $pidFile ?: $this->getDefaultPidFile(); if ($this->isRunning($pidFile)) { throw new \RuntimeException(sprintf('A process is already listening on http://%s.', $config->getAddress())); } $pid = pcntl_fork(); if ($pid < 0) { throw new \RuntimeException('Unable to start the server process.'); } if ($pid > 0) { return self::STARTED; } if (posix_setsid() < 0) { throw new \RuntimeException('Unable to set the child process as session leader.'); } $process = $this->createServerProcess($config); $process->disableOutput(); $process->start(); if (!$process->isRunning()) { throw new \RuntimeException('Unable to start the server process.'); } file_put_contents($pidFile, $config->getAddress()); // stop the web server when the lock file is removed while ($process->isRunning()) { if (!file_exists($pidFile)) { $process->stop(); } sleep(1); } return self::STOPPED; } public function stop($pidFile = null) { $pidFile = $pidFile ?: $this->getDefaultPidFile(); if (!file_exists($pidFile)) { throw new \RuntimeException('No web server is listening.'); } unlink($pidFile); } public function getAddress($pidFile = null) { $pidFile = $pidFile ?: $this->getDefaultPidFile(); if (!file_exists($pidFile)) { return false; } return file_get_contents($pidFile); } public function isRunning($pidFile = null) { $pidFile = $pidFile ?: $this->getDefaultPidFile(); if (!file_exists($pidFile)) { return false; } $address = file_get_contents($pidFile); $pos = strrpos($address, ':'); $hostname = substr($address, 0, $pos); $port = substr($address, $pos + 1); if (false !== $fp = @fsockopen($hostname, $port, $errno, $errstr, 1)) { fclose($fp); return true; } unlink($pidFile); return false; } /** * @return Process The process */ private function createServerProcess(WebServerConfig $config) { $finder = new PhpExecutableFinder(); if (false === $binary = $finder->find(false)) { throw new \RuntimeException('Unable to find the PHP binary.'); } $process = new Process(array_merge(array($binary), $finder->findArguments(), array('-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()))); $process->setWorkingDirectory($config->getDocumentRoot()); $process->setTimeout(null); if (in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) { $process->setEnv(array('APP_ENV' => false)); $process->inheritEnvironmentVariables(); } return $process; } private function getDefaultPidFile() { return getcwd().'/.web-server-pid'; } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/WebServerBundle.php000066400000000000000000000005631324732107100255050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class WebServerBundle extends Bundle { } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php000066400000000000000000000071101324732107100254740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\WebServerBundle; /** * @author Fabien Potencier */ class WebServerConfig { private $hostname; private $port; private $documentRoot; private $env; private $router; public function __construct($documentRoot, $env, $address = null, $router = null) { if (!is_dir($documentRoot)) { throw new \InvalidArgumentException(sprintf('The document root directory "%s" does not exist.', $documentRoot)); } if (null === $file = $this->findFrontController($documentRoot, $env)) { throw new \InvalidArgumentException(sprintf('Unable to find the front controller under "%s" (none of these files exist: %s).', $documentRoot, implode(', ', $this->getFrontControllerFileNames($env)))); } $_ENV['APP_FRONT_CONTROLLER'] = $file; $this->documentRoot = $documentRoot; $this->env = $env; if (null !== $router) { $absoluteRouterPath = realpath($router); if (false === $absoluteRouterPath) { throw new \InvalidArgumentException(sprintf('Router script "%s" does not exist.', $router)); } $this->router = $absoluteRouterPath; } else { $this->router = __DIR__.'/Resources/router.php'; } if (null === $address) { $this->hostname = '127.0.0.1'; $this->port = $this->findBestPort(); } elseif (false !== $pos = strrpos($address, ':')) { $this->hostname = substr($address, 0, $pos); if ('*' === $this->hostname) { $this->hostname = '0.0.0.0'; } $this->port = substr($address, $pos + 1); } elseif (ctype_digit($address)) { $this->hostname = '127.0.0.1'; $this->port = $address; } else { $this->hostname = $address; $this->port = $this->findBestPort(); } if (!ctype_digit($this->port)) { throw new \InvalidArgumentException(sprintf('Port "%s" is not valid.', $this->port)); } } public function getDocumentRoot() { return $this->documentRoot; } public function getEnv() { return $this->env; } public function getRouter() { return $this->router; } public function getHostname() { return $this->hostname; } public function getPort() { return $this->port; } public function getAddress() { return $this->hostname.':'.$this->port; } private function findFrontController($documentRoot, $env) { $fileNames = $this->getFrontControllerFileNames($env); foreach ($fileNames as $fileName) { if (file_exists($documentRoot.'/'.$fileName)) { return $fileName; } } } private function getFrontControllerFileNames($env) { return array('app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'); } private function findBestPort() { $port = 8000; while (false !== $fp = @fsockopen($this->hostname, $port, $errno, $errstr, 1)) { fclose($fp); if ($port++ >= 8100) { throw new \RuntimeException('Unable to find a port available to run the web server.'); } } return $port; } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/composer.json000066400000000000000000000022441324732107100244560ustar00rootroot00000000000000{ "name": "symfony/web-server-bundle", "type": "symfony-bundle", "description": "Symfony WebServerBundle", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/config": "~3.4|~4.0", "symfony/console": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/http-kernel": "~3.3|~4.0", "symfony/process": "~3.3.14|^3.4.2|^4.0.2" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "suggest": { "symfony/monolog-bridge": "For using the log server.", "symfony/expression-language": "For using the filter option of the log server." }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Bundle/WebServerBundle/phpunit.xml.dist000066400000000000000000000015631324732107100251120ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Component/000077500000000000000000000000001324732107100174255ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/000077500000000000000000000000001324732107100205045ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/.gitignore000066400000000000000000000000421324732107100224700ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Component/Asset/CHANGELOG.md000066400000000000000000000005421324732107100223160ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added optional arguments `$basePath` and `$secure` in `RequestStackContext::__construct()` to provide a default request context in case the stack is empty 3.3.0 ----- * Added `JsonManifestVersionStrategy` as a way to read final, versioned paths from a JSON manifest file. 2.7.0 ----- * added the component symfony-3.4.6/src/Symfony/Component/Asset/Context/000077500000000000000000000000001324732107100221305ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Context/ContextInterface.php000066400000000000000000000013151324732107100261060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Context; /** * Holds information about the current request. * * @author Fabien Potencier */ interface ContextInterface { /** * Gets the base path. * * @return string The base path */ public function getBasePath(); /** * Checks whether the request is secure or not. * * @return bool true if the request is secure, false otherwise */ public function isSecure(); } symfony-3.4.6/src/Symfony/Component/Asset/Context/NullContext.php000066400000000000000000000011651324732107100251230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Context; /** * A context that does nothing. * * @author Fabien Potencier */ class NullContext implements ContextInterface { /** * {@inheritdoc} */ public function getBasePath() { return ''; } /** * {@inheritdoc} */ public function isSecure() { return false; } } symfony-3.4.6/src/Symfony/Component/Asset/Context/RequestStackContext.php000066400000000000000000000025551324732107100266330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Context; use Symfony\Component\HttpFoundation\RequestStack; /** * Uses a RequestStack to populate the context. * * @author Fabien Potencier */ class RequestStackContext implements ContextInterface { private $requestStack; private $basePath; private $secure; /** * @param RequestStack $requestStack * @param string $basePath * @param bool $secure */ public function __construct(RequestStack $requestStack, $basePath = '', $secure = false) { $this->requestStack = $requestStack; $this->basePath = $basePath; $this->secure = $secure; } /** * {@inheritdoc} */ public function getBasePath() { if (!$request = $this->requestStack->getMasterRequest()) { return $this->basePath; } return $request->getBasePath(); } /** * {@inheritdoc} */ public function isSecure() { if (!$request = $this->requestStack->getMasterRequest()) { return $this->secure; } return $request->isSecure(); } } symfony-3.4.6/src/Symfony/Component/Asset/Exception/000077500000000000000000000000001324732107100224425ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Exception/ExceptionInterface.php000066400000000000000000000006551324732107100267400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Exception; /** * Base ExceptionInterface for the Asset component. * * @author Fabien Potencier */ interface ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Asset/Exception/InvalidArgumentException.php000066400000000000000000000007651324732107100301330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Exception; /** * Base InvalidArgumentException for the Asset component. * * @author Fabien Potencier */ class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Asset/Exception/LogicException.php000066400000000000000000000007271324732107100260750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Exception; /** * Base LogicException for the Asset component. * * @author Fabien Potencier */ class LogicException extends \LogicException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Asset/LICENSE000066400000000000000000000020511324732107100215070ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Component/Asset/Package.php000066400000000000000000000032631324732107100225540ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\Context\NullContext; use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface; /** * Basic package that adds a version to asset URLs. * * @author Kris Wallsmith * @author Fabien Potencier */ class Package implements PackageInterface { private $versionStrategy; private $context; public function __construct(VersionStrategyInterface $versionStrategy, ContextInterface $context = null) { $this->versionStrategy = $versionStrategy; $this->context = $context ?: new NullContext(); } /** * {@inheritdoc} */ public function getVersion($path) { return $this->versionStrategy->getVersion($path); } /** * {@inheritdoc} */ public function getUrl($path) { if ($this->isAbsoluteUrl($path)) { return $path; } return $this->versionStrategy->applyVersion($path); } /** * @return ContextInterface */ protected function getContext() { return $this->context; } /** * @return VersionStrategyInterface */ protected function getVersionStrategy() { return $this->versionStrategy; } protected function isAbsoluteUrl($url) { return false !== strpos($url, '://') || '//' === substr($url, 0, 2); } } symfony-3.4.6/src/Symfony/Component/Asset/PackageInterface.php000066400000000000000000000014071324732107100243730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; /** * Asset package interface. * * @author Kris Wallsmith */ interface PackageInterface { /** * Returns the asset version for an asset. * * @param string $path A path * * @return string The version string */ public function getVersion($path); /** * Returns an absolute or root-relative public path. * * @param string $path A path * * @return string The public path */ public function getUrl($path); } symfony-3.4.6/src/Symfony/Component/Asset/Packages.php000066400000000000000000000061031324732107100227330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; use Symfony\Component\Asset\Exception\InvalidArgumentException; use Symfony\Component\Asset\Exception\LogicException; /** * Helps manage asset URLs. * * @author Fabien Potencier * @author Kris Wallsmith */ class Packages { private $defaultPackage; private $packages = array(); /** * @param PackageInterface $defaultPackage The default package * @param PackageInterface[] $packages Additional packages indexed by name */ public function __construct(PackageInterface $defaultPackage = null, array $packages = array()) { $this->defaultPackage = $defaultPackage; foreach ($packages as $name => $package) { $this->addPackage($name, $package); } } public function setDefaultPackage(PackageInterface $defaultPackage) { $this->defaultPackage = $defaultPackage; } /** * Adds a package. * * @param string $name The package name * @param PackageInterface $package The package */ public function addPackage($name, PackageInterface $package) { $this->packages[$name] = $package; } /** * Returns an asset package. * * @param string $name The name of the package or null for the default package * * @return PackageInterface An asset package * * @throws InvalidArgumentException If there is no package by that name * @throws LogicException If no default package is defined */ public function getPackage($name = null) { if (null === $name) { if (null === $this->defaultPackage) { throw new LogicException('There is no default asset package, configure one first.'); } return $this->defaultPackage; } if (!isset($this->packages[$name])) { throw new InvalidArgumentException(sprintf('There is no "%s" asset package.', $name)); } return $this->packages[$name]; } /** * Gets the version to add to public URL. * * @param string $path A public path * @param string $packageName A package name * * @return string The current version */ public function getVersion($path, $packageName = null) { return $this->getPackage($packageName)->getVersion($path); } /** * Returns the public path. * * Absolute paths (i.e. http://...) are returned unmodified. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string A public path which takes into account the base path and URL path */ public function getUrl($path, $packageName = null) { return $this->getPackage($packageName)->getUrl($path); } } symfony-3.4.6/src/Symfony/Component/Asset/PathPackage.php000066400000000000000000000043051324732107100233670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface; /** * Package that adds a base path to asset URLs in addition to a version. * * In addition to the provided base path, this package also automatically * prepends the current request base path if a Context is available to * allow a website to be hosted easily under any given path under the Web * Server root directory. * * @author Fabien Potencier */ class PathPackage extends Package { private $basePath; /** * @param string $basePath The base path to be prepended to relative paths * @param VersionStrategyInterface $versionStrategy The version strategy * @param ContextInterface|null $context The context */ public function __construct($basePath, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) { parent::__construct($versionStrategy, $context); if (!$basePath) { $this->basePath = '/'; } else { if ('/' != $basePath[0]) { $basePath = '/'.$basePath; } $this->basePath = rtrim($basePath, '/').'/'; } } /** * {@inheritdoc} */ public function getUrl($path) { if ($this->isAbsoluteUrl($path)) { return $path; } $versionedPath = $this->getVersionStrategy()->applyVersion($path); // if absolute or begins with /, we're done if ($this->isAbsoluteUrl($versionedPath) || ($versionedPath && '/' === $versionedPath[0])) { return $versionedPath; } return $this->getBasePath().ltrim($versionedPath, '/'); } /** * Returns the base path. * * @return string The base path */ public function getBasePath() { return $this->getContext()->getBasePath().$this->basePath; } } symfony-3.4.6/src/Symfony/Component/Asset/README.md000066400000000000000000000010551324732107100217640ustar00rootroot00000000000000Asset Component =============== The Asset component manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files. Resources --------- * [Documentation](https://symfony.com/doc/current/components/asset/introduction.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Component/Asset/Tests/000077500000000000000000000000001324732107100216065ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Tests/Context/000077500000000000000000000000001324732107100232325ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Tests/Context/NullContextTest.php000066400000000000000000000013041324732107100270600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\Context; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\NullContext; class NullContextTest extends TestCase { public function testGetBasePath() { $nullContext = new NullContext(); $this->assertEmpty($nullContext->getBasePath()); } public function testIsSecure() { $nullContext = new NullContext(); $this->assertFalse($nullContext->isSecure()); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php000066400000000000000000000050241324732107100305670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\Context; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\RequestStackContext; class RequestStackContextTest extends TestCase { public function testGetBasePathEmpty() { $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertEmpty($requestStackContext->getBasePath()); } public function testGetBasePathSet() { $testBasePath = 'test-path'; $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('getBasePath') ->willReturn($testBasePath); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); $requestStackContext = new RequestStackContext($requestStack); $this->assertEquals($testBasePath, $requestStackContext->getBasePath()); } public function testIsSecureFalse() { $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertFalse($requestStackContext->isSecure()); } public function testIsSecureTrue() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('isSecure') ->willReturn(true); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); $requestStackContext = new RequestStackContext($requestStack); $this->assertTrue($requestStackContext->isSecure()); } public function testDefaultContext() { $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackContext = new RequestStackContext($requestStack, 'default-path', true); $this->assertSame('default-path', $requestStackContext->getBasePath()); $this->assertTrue($requestStackContext->isSecure()); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/PackageTest.php000066400000000000000000000034141324732107100245140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; class PackageTest extends TestCase { /** * @dataProvider getConfigs */ public function testGetUrl($version, $format, $path, $expected) { $package = new Package($version ? new StaticVersionStrategy($version, $format) : new EmptyVersionStrategy()); $this->assertEquals($expected, $package->getUrl($path)); } public function getConfigs() { return array( array('v1', '', 'http://example.com/foo', 'http://example.com/foo'), array('v1', '', 'https://example.com/foo', 'https://example.com/foo'), array('v1', '', '//example.com/foo', '//example.com/foo'), array('v1', '', '/foo', '/foo?v1'), array('v1', '', 'foo', 'foo?v1'), array(null, '', '/foo', '/foo'), array(null, '', 'foo', 'foo'), array('v1', 'version-%2$s/%1$s', '/foo', '/version-v1/foo'), array('v1', 'version-%2$s/%1$s', 'foo', 'version-v1/foo'), array('v1', 'version-%2$s/%1$s', 'foo/', 'version-v1/foo/'), array('v1', 'version-%2$s/%1$s', '/foo/', '/version-v1/foo/'), ); } public function testGetVersion() { $package = new Package(new StaticVersionStrategy('v1')); $this->assertEquals('v1', $package->getVersion('/foo')); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/PackagesTest.php000066400000000000000000000044311324732107100246770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; class PackagesTest extends TestCase { public function testGetterSetters() { $packages = new Packages(); $packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); $packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); $this->assertEquals($default, $packages->getPackage()); $this->assertEquals($a, $packages->getPackage('a')); $packages = new Packages($default, array('a' => $a)); $this->assertEquals($default, $packages->getPackage()); $this->assertEquals($a, $packages->getPackage('a')); } public function testGetVersion() { $packages = new Packages( new Package(new StaticVersionStrategy('default')), array('a' => new Package(new StaticVersionStrategy('a'))) ); $this->assertEquals('default', $packages->getVersion('/foo')); $this->assertEquals('a', $packages->getVersion('/foo', 'a')); } public function testGetUrl() { $packages = new Packages( new Package(new StaticVersionStrategy('default')), array('a' => new Package(new StaticVersionStrategy('a'))) ); $this->assertEquals('/foo?default', $packages->getUrl('/foo')); $this->assertEquals('/foo?a', $packages->getUrl('/foo', 'a')); } /** * @expectedException \Symfony\Component\Asset\Exception\LogicException */ public function testNoDefaultPackage() { $packages = new Packages(); $packages->getPackage(); } /** * @expectedException \Symfony\Component\Asset\Exception\InvalidArgumentException */ public function testUndefinedPackage() { $packages = new Packages(); $packages->getPackage('a'); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/PathPackageTest.php000066400000000000000000000067421324732107100253400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\PathPackage; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; class PathPackageTest extends TestCase { /** * @dataProvider getConfigs */ public function testGetUrl($basePath, $format, $path, $expected) { $package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format)); $this->assertEquals($expected, $package->getUrl($path)); } public function getConfigs() { return array( array('/foo', '', 'http://example.com/foo', 'http://example.com/foo'), array('/foo', '', 'https://example.com/foo', 'https://example.com/foo'), array('/foo', '', '//example.com/foo', '//example.com/foo'), array('', '', '/foo', '/foo?v1'), array('/foo', '', '/bar', '/bar?v1'), array('/foo', '', 'bar', '/foo/bar?v1'), array('foo', '', 'bar', '/foo/bar?v1'), array('foo/', '', 'bar', '/foo/bar?v1'), array('/foo/', '', 'bar', '/foo/bar?v1'), array('/foo', 'version-%2$s/%1$s', '/bar', '/version-v1/bar'), array('/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'), array('/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'), array('/foo', 'version-%2$s/%1$s', '/bar/', '/version-v1/bar/'), ); } /** * @dataProvider getContextConfigs */ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $path, $expected) { $package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format), $this->getContext($basePathRequest)); $this->assertEquals($expected, $package->getUrl($path)); } public function getContextConfigs() { return array( array('', '/foo', '', '/baz', '/baz?v1'), array('', '/foo', '', 'baz', '/foo/baz?v1'), array('', 'foo', '', 'baz', '/foo/baz?v1'), array('', 'foo/', '', 'baz', '/foo/baz?v1'), array('', '/foo/', '', 'baz', '/foo/baz?v1'), array('/bar', '/foo', '', '/baz', '/baz?v1'), array('/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'), array('/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'), array('/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'), array('/bar', '/foo/', '', 'baz', '/bar/foo/baz?v1'), ); } public function testVersionStrategyGivesAbsoluteURL() { $versionStrategy = $this->getMockBuilder('Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface')->getMock(); $versionStrategy->expects($this->any()) ->method('applyVersion') ->willReturn('https://cdn.com/bar/main.css'); $package = new PathPackage('/subdirectory', $versionStrategy, $this->getContext('/bar')); $this->assertEquals('https://cdn.com/bar/main.css', $package->getUrl('main.css')); } private function getContext($basePath) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath)); return $context; } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/UrlPackageTest.php000066400000000000000000000114741324732107100252040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\UrlPackage; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; class UrlPackageTest extends TestCase { /** * @dataProvider getConfigs */ public function testGetUrl($baseUrls, $format, $path, $expected) { $package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format)); $this->assertEquals($expected, $package->getUrl($path)); } public function getConfigs() { return array( array('http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'), array('http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'), array('http://example.net', '', '//example.com/foo', '//example.com/foo'), array('http://example.com', '', '/foo', 'http://example.com/foo?v1'), array('http://example.com', '', 'foo', 'http://example.com/foo?v1'), array('http://example.com/', '', 'foo', 'http://example.com/foo?v1'), array('http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'), array('http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'), array(array('http://example.com'), '', '/foo', 'http://example.com/foo?v1'), array(array('http://example.com', 'http://example.net'), '', '/foo', 'http://example.com/foo?v1'), array(array('http://example.com', 'http://example.net'), '', '/fooa', 'http://example.net/fooa?v1'), array('http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'), array('http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'), array('http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'), array('http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'), ); } /** * @dataProvider getContextConfigs */ public function testGetUrlWithContext($secure, $baseUrls, $format, $path, $expected) { $package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format), $this->getContext($secure)); $this->assertEquals($expected, $package->getUrl($path)); } public function getContextConfigs() { return array( array(false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'), array(false, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'), array(false, array('http://example.com', 'https://example.com'), '', 'foo', 'http://example.com/foo?v1'), array(false, array('http://example.com', 'https://example.com'), '', 'fooa', 'https://example.com/fooa?v1'), array(false, array('http://example.com/bar'), '', 'foo', 'http://example.com/bar/foo?v1'), array(false, array('http://example.com/bar/'), '', 'foo', 'http://example.com/bar/foo?v1'), array(false, array('//example.com/bar/'), '', 'foo', '//example.com/bar/foo?v1'), array(true, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'), array(true, array('http://example.com', 'https://example.com'), '', 'foo', 'https://example.com/foo?v1'), ); } public function testVersionStrategyGivesAbsoluteURL() { $versionStrategy = $this->getMockBuilder('Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface')->getMock(); $versionStrategy->expects($this->any()) ->method('applyVersion') ->willReturn('https://cdn.com/bar/main.css'); $package = new UrlPackage('https://example.com', $versionStrategy); $this->assertEquals('https://cdn.com/bar/main.css', $package->getUrl('main.css')); } /** * @expectedException \Symfony\Component\Asset\Exception\LogicException */ public function testNoBaseUrls() { new UrlPackage(array(), new EmptyVersionStrategy()); } /** * @expectedException \Symfony\Component\Asset\Exception\InvalidArgumentException */ public function testWrongBaseUrl() { new UrlPackage(array('not-a-url'), new EmptyVersionStrategy()); } private function getContext($secure) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure)); return $context; } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/VersionStrategy/000077500000000000000000000000001324732107100247565ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php000066400000000000000000000015561324732107100325250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; class EmptyVersionStrategyTest extends TestCase { public function testGetVersion() { $emptyVersionStrategy = new EmptyVersionStrategy(); $path = 'test-path'; $this->assertEmpty($emptyVersionStrategy->getVersion($path)); } public function testApplyVersion() { $emptyVersionStrategy = new EmptyVersionStrategy(); $path = 'test-path'; $this->assertEquals($path, $emptyVersionStrategy->applyVersion($path)); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php000066400000000000000000000034221324732107100340210ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy; class JsonManifestVersionStrategyTest extends TestCase { public function testGetVersion() { $strategy = $this->createStrategy('manifest-valid.json'); $this->assertEquals('main.123abc.js', $strategy->getVersion('main.js')); } public function testApplyVersion() { $strategy = $this->createStrategy('manifest-valid.json'); $this->assertEquals('css/styles.555def.css', $strategy->getVersion('css/styles.css')); } public function testApplyVersionWhenKeyDoesNotExistInManifest() { $strategy = $this->createStrategy('manifest-valid.json'); $this->assertEquals('css/other.css', $strategy->getVersion('css/other.css')); } /** * @expectedException \RuntimeException */ public function testMissingManifestFileThrowsException() { $strategy = $this->createStrategy('non-existent-file.json'); $strategy->getVersion('main.js'); } /** * @expectedException \RuntimeException * @expectedExceptionMessage Error parsing JSON */ public function testManifestFileWithBadJSONThrowsException() { $strategy = $this->createStrategy('manifest-invalid.json'); $strategy->getVersion('main.js'); } private function createStrategy($manifestFilename) { return new JsonManifestVersionStrategy(__DIR__.'/../fixtures/'.$manifestFilename); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php000066400000000000000000000023221324732107100326460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; class StaticVersionStrategyTest extends TestCase { public function testGetVersion() { $version = 'v1'; $path = 'test-path'; $staticVersionStrategy = new StaticVersionStrategy($version); $this->assertEquals($version, $staticVersionStrategy->getVersion($path)); } /** * @dataProvider getConfigs */ public function testApplyVersion($path, $version, $format) { $staticVersionStrategy = new StaticVersionStrategy($version, $format); $formatted = sprintf($format ?: '%s?%s', $path, $version); $this->assertEquals($formatted, $staticVersionStrategy->applyVersion($path)); } public function getConfigs() { return array( array('test-path', 'v1', null), array('test-path', 'v2', '%s?test%s'), ); } } symfony-3.4.6/src/Symfony/Component/Asset/Tests/fixtures/000077500000000000000000000000001324732107100234575ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/Tests/fixtures/manifest-invalid.json000066400000000000000000000001161324732107100276020ustar00rootroot00000000000000{ "main.js": main.123abc.js", "css/styles.css": "css/styles.555def.css" } symfony-3.4.6/src/Symfony/Component/Asset/Tests/fixtures/manifest-valid.json000066400000000000000000000001171324732107100272540ustar00rootroot00000000000000{ "main.js": "main.123abc.js", "css/styles.css": "css/styles.555def.css" } symfony-3.4.6/src/Symfony/Component/Asset/UrlPackage.php000066400000000000000000000077601324732107100232450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface; use Symfony\Component\Asset\Exception\InvalidArgumentException; use Symfony\Component\Asset\Exception\LogicException; /** * Package that adds a base URL to asset URLs in addition to a version. * * The package allows to use more than one base URLs in which case * it randomly chooses one for each asset; it also guarantees that * any given path will always use the same base URL to be nice with * HTTP caching mechanisms. * * When the request context is available, this package can choose the * best base URL to use based on the current request scheme: * * * For HTTP request, it chooses between all base URLs; * * For HTTPs requests, it chooses between HTTPs base URLs and relative protocol URLs * or falls back to any base URL if no secure ones are available. * * @author Fabien Potencier */ class UrlPackage extends Package { private $baseUrls = array(); private $sslPackage; /** * @param string|string[] $baseUrls Base asset URLs * @param VersionStrategyInterface $versionStrategy The version strategy * @param ContextInterface|null $context Context */ public function __construct($baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) { parent::__construct($versionStrategy, $context); if (!is_array($baseUrls)) { $baseUrls = (array) $baseUrls; } if (!$baseUrls) { throw new LogicException('You must provide at least one base URL.'); } foreach ($baseUrls as $baseUrl) { $this->baseUrls[] = rtrim($baseUrl, '/'); } $sslUrls = $this->getSslUrls($baseUrls); if ($sslUrls && $baseUrls !== $sslUrls) { $this->sslPackage = new self($sslUrls, $versionStrategy); } } /** * {@inheritdoc} */ public function getUrl($path) { if ($this->isAbsoluteUrl($path)) { return $path; } if (null !== $this->sslPackage && $this->getContext()->isSecure()) { return $this->sslPackage->getUrl($path); } $url = $this->getVersionStrategy()->applyVersion($path); if ($this->isAbsoluteUrl($url)) { return $url; } if ($url && '/' != $url[0]) { $url = '/'.$url; } return $this->getBaseUrl($path).$url; } /** * Returns the base URL for a path. * * @param string $path * * @return string The base URL */ public function getBaseUrl($path) { if (1 === count($this->baseUrls)) { return $this->baseUrls[0]; } return $this->baseUrls[$this->chooseBaseUrl($path)]; } /** * Determines which base URL to use for the given path. * * Override this method to change the default distribution strategy. * This method should always return the same base URL index for a given path. * * @param string $path * * @return int The base URL index for the given path */ protected function chooseBaseUrl($path) { return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), count($this->baseUrls)); } private function getSslUrls($urls) { $sslUrls = array(); foreach ($urls as $url) { if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) { $sslUrls[] = $url; } elseif ('http://' !== substr($url, 0, 7)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid URL', $url)); } } return $sslUrls; } } symfony-3.4.6/src/Symfony/Component/Asset/VersionStrategy/000077500000000000000000000000001324732107100236545ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php000066400000000000000000000012361324732107100305560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\VersionStrategy; /** * Disable version for all assets. * * @author Fabien Potencier */ class EmptyVersionStrategy implements VersionStrategyInterface { /** * {@inheritdoc} */ public function getVersion($path) { return ''; } /** * {@inheritdoc} */ public function applyVersion($path) { return $path; } } symfony-3.4.6/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php000066400000000000000000000036771324732107100320730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\VersionStrategy; /** * Reads the versioned path of an asset from a JSON manifest file. * * For example, the manifest file might look like this: * { * "main.js": "main.abc123.js", * "css/styles.css": "css/styles.555abc.css" * } * * You could then ask for the version of "main.js" or "css/styles.css". */ class JsonManifestVersionStrategy implements VersionStrategyInterface { private $manifestPath; private $manifestData; /** * @param string $manifestPath Absolute path to the manifest file */ public function __construct($manifestPath) { $this->manifestPath = $manifestPath; } /** * With a manifest, we don't really know or care about what * the version is. Instead, this returns the path to the * versioned file. */ public function getVersion($path) { return $this->applyVersion($path); } public function applyVersion($path) { return $this->getManifestPath($path) ?: $path; } private function getManifestPath($path) { if (null === $this->manifestData) { if (!file_exists($this->manifestPath)) { throw new \RuntimeException(sprintf('Asset manifest file "%s" does not exist.', $this->manifestPath)); } $this->manifestData = json_decode(file_get_contents($this->manifestPath), true); if (0 < json_last_error()) { throw new \RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s" - %s', $this->manifestPath, json_last_error_msg())); } } return isset($this->manifestData[$path]) ? $this->manifestData[$path] : null; } } symfony-3.4.6/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php000066400000000000000000000022301324732107100307020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\VersionStrategy; /** * Returns the same version for all assets. * * @author Fabien Potencier */ class StaticVersionStrategy implements VersionStrategyInterface { private $version; private $format; /** * @param string $version Version number * @param string $format Url format */ public function __construct($version, $format = null) { $this->version = $version; $this->format = $format ?: '%s?%s'; } /** * {@inheritdoc} */ public function getVersion($path) { return $this->version; } /** * {@inheritdoc} */ public function applyVersion($path) { $versionized = sprintf($this->format, ltrim($path, '/'), $this->getVersion($path)); if ($path && '/' == $path[0]) { return '/'.$versionized; } return $versionized; } } symfony-3.4.6/src/Symfony/Component/Asset/VersionStrategy/VersionStrategyInterface.php000066400000000000000000000014531324732107100313610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\VersionStrategy; /** * Asset version strategy interface. * * @author Fabien Potencier */ interface VersionStrategyInterface { /** * Returns the asset version for an asset. * * @param string $path A path * * @return string The version string */ public function getVersion($path); /** * Applies version to the supplied path. * * @param string $path A path * * @return string The versionized path */ public function applyVersion($path); } symfony-3.4.6/src/Symfony/Component/Asset/composer.json000066400000000000000000000016661324732107100232370ustar00rootroot00000000000000{ "name": "symfony/asset", "type": "library", "description": "Symfony Asset Component", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8" }, "suggest": { "symfony/http-foundation": "" }, "require-dev": { "symfony/http-foundation": "~2.8|~3.0|~4.0", "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Asset\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Component/Asset/phpunit.xml.dist000066400000000000000000000015001324732107100236530ustar00rootroot00000000000000 ./Tests/ ./ ./Tests ./vendor symfony-3.4.6/src/Symfony/Component/BrowserKit/000077500000000000000000000000001324732107100215205ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/BrowserKit/.gitignore000066400000000000000000000000421324732107100235040ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Component/BrowserKit/CHANGELOG.md000066400000000000000000000015311324732107100233310ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * [BC BREAK] Client will skip redirects during history navigation (back and forward calls) according to W3C Browsers recommendation 3.3.0 ----- * [BC BREAK] The request method is dropped from POST to GET when the response status code is 301. 3.2.0 ----- * Client HTTP user agent has been changed to 'Symfony BrowserKit' 2.3.0 ----- * [BC BREAK] `Client::followRedirect()` won't redirect responses with a non-3xx Status Code and `Location` header anymore, as per http://tools.ietf.org/html/rfc2616#section-14.30 * added `Client::getInternalRequest()` and `Client::getInternalResponse()` to have access to the BrowserKit internal request and response objects 2.1.0 ----- * [BC BREAK] The CookieJar internals have changed to allow cookies with the same name on different sub-domains/sub-paths symfony-3.4.6/src/Symfony/Component/BrowserKit/Client.php000066400000000000000000000427421324732107100234600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Link; use Symfony\Component\DomCrawler\Form; use Symfony\Component\Process\PhpProcess; /** * Client simulates a browser. * * To make the actual request, you need to implement the doRequest() method. * * If you want to be able to run requests in their own process (insulated flag), * you need to also implement the getScript() method. * * @author Fabien Potencier */ abstract class Client { protected $history; protected $cookieJar; protected $server = array(); protected $internalRequest; protected $request; protected $internalResponse; protected $response; protected $crawler; protected $insulated = false; protected $redirect; protected $followRedirects = true; private $maxRedirects = -1; private $redirectCount = 0; private $redirects = array(); private $isMainRequest = true; /** * @param array $server The server parameters (equivalent of $_SERVER) * @param History $history A History instance to store the browser history * @param CookieJar $cookieJar A CookieJar instance to store the cookies */ public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null) { $this->setServerParameters($server); $this->history = $history ?: new History(); $this->cookieJar = $cookieJar ?: new CookieJar(); } /** * Sets whether to automatically follow redirects or not. * * @param bool $followRedirect Whether to follow redirects */ public function followRedirects($followRedirect = true) { $this->followRedirects = (bool) $followRedirect; } /** * Returns whether client automatically follows redirects or not. * * @return bool */ public function isFollowingRedirects() { return $this->followRedirects; } /** * Sets the maximum number of requests that crawler can follow. * * @param int $maxRedirects */ public function setMaxRedirects($maxRedirects) { $this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects; $this->followRedirects = -1 != $this->maxRedirects; } /** * Returns the maximum number of requests that crawler can follow. * * @return int */ public function getMaxRedirects() { return $this->maxRedirects; } /** * Sets the insulated flag. * * @param bool $insulated Whether to insulate the requests or not * * @throws \RuntimeException When Symfony Process Component is not installed */ public function insulate($insulated = true) { if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.'); } $this->insulated = (bool) $insulated; } /** * Sets server parameters. * * @param array $server An array of server parameters */ public function setServerParameters(array $server) { $this->server = array_merge(array( 'HTTP_USER_AGENT' => 'Symfony BrowserKit', ), $server); } /** * Sets single server parameter. * * @param string $key A key of the parameter * @param string $value A value of the parameter */ public function setServerParameter($key, $value) { $this->server[$key] = $value; } /** * Gets single server parameter for specified key. * * @param string $key A key of the parameter to get * @param string $default A default value when key is undefined * * @return string A value of the parameter */ public function getServerParameter($key, $default = '') { return isset($this->server[$key]) ? $this->server[$key] : $default; } /** * Returns the History instance. * * @return History A History instance */ public function getHistory() { return $this->history; } /** * Returns the CookieJar instance. * * @return CookieJar A CookieJar instance */ public function getCookieJar() { return $this->cookieJar; } /** * Returns the current Crawler instance. * * @return Crawler|null A Crawler instance */ public function getCrawler() { return $this->crawler; } /** * Returns the current BrowserKit Response instance. * * @return Response|null A BrowserKit Response instance */ public function getInternalResponse() { return $this->internalResponse; } /** * Returns the current origin response instance. * * The origin response is the response instance that is returned * by the code that handles requests. * * @return object|null A response instance * * @see doRequest() */ public function getResponse() { return $this->response; } /** * Returns the current BrowserKit Request instance. * * @return Request|null A BrowserKit Request instance */ public function getInternalRequest() { return $this->internalRequest; } /** * Returns the current origin Request instance. * * The origin request is the request instance that is sent * to the code that handles requests. * * @return object|null A Request instance * * @see doRequest() */ public function getRequest() { return $this->request; } /** * Clicks on a given link. * * @return Crawler */ public function click(Link $link) { if ($link instanceof Form) { return $this->submit($link); } return $this->request($link->getMethod(), $link->getUri()); } /** * Submits a form. * * @param Form $form A Form instance * @param array $values An array of form field values * * @return Crawler */ public function submit(Form $form, array $values = array()) { $form->setValues($values); return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles()); } /** * Calls a URI. * * @param string $method The request method * @param string $uri The URI to fetch * @param array $parameters The Request parameters * @param array $files The files * @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does) * @param string $content The raw body data * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) * * @return Crawler */ public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) { if ($this->isMainRequest) { $this->redirectCount = 0; } else { ++$this->redirectCount; } $uri = $this->getAbsoluteUri($uri); $server = array_merge($this->server, $server); if (isset($server['HTTPS'])) { $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } if (!$this->history->isEmpty()) { $server['HTTP_REFERER'] = $this->history->current()->getUri(); } if (empty($server['HTTP_HOST'])) { $server['HTTP_HOST'] = $this->extractHost($uri); } $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); $this->request = $this->filterRequest($this->internalRequest); if (true === $changeHistory) { $this->history->add($this->internalRequest); } if ($this->insulated) { $this->response = $this->doRequestInProcess($this->request); } else { $this->response = $this->doRequest($this->request); } $this->internalResponse = $this->filterResponse($this->response); $this->cookieJar->updateFromResponse($this->internalResponse, $uri); $status = $this->internalResponse->getStatus(); if ($status >= 300 && $status < 400) { $this->redirect = $this->internalResponse->getHeader('Location'); } else { $this->redirect = null; } if ($this->followRedirects && $this->redirect) { $this->redirects[serialize($this->history->current())] = true; return $this->crawler = $this->followRedirect(); } return $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type')); } /** * Makes a request in another process. * * @param object $request An origin request instance * * @return object An origin response instance * * @throws \RuntimeException When processing returns exit code */ protected function doRequestInProcess($request) { $deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec'); putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile); $_ENV['SYMFONY_DEPRECATIONS_SERIALIZE'] = $deprecationsFile; $process = new PhpProcess($this->getScript($request), null, null); $process->run(); if (file_exists($deprecationsFile)) { $deprecations = file_get_contents($deprecationsFile); unlink($deprecationsFile); foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { if ($deprecation[0]) { trigger_error($deprecation[1], E_USER_DEPRECATED); } else { @trigger_error($deprecation[1], E_USER_DEPRECATED); } } } if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) { throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput())); } return unserialize($process->getOutput()); } /** * Makes a request. * * @param object $request An origin request instance * * @return object An origin response instance */ abstract protected function doRequest($request); /** * Returns the script to execute when the request must be insulated. * * @param object $request An origin request instance * * @throws \LogicException When this abstract class is not implemented */ protected function getScript($request) { throw new \LogicException('To insulate requests, you need to override the getScript() method.'); } /** * Filters the BrowserKit request to the origin one. * * @param Request $request The BrowserKit Request to filter * * @return object An origin request instance */ protected function filterRequest(Request $request) { return $request; } /** * Filters the origin response to the BrowserKit one. * * @param object $response The origin response to filter * * @return Response An BrowserKit Response instance */ protected function filterResponse($response) { return $response; } /** * Creates a crawler. * * This method returns null if the DomCrawler component is not available. * * @param string $uri A URI * @param string $content Content for the crawler to use * @param string $type Content type * * @return Crawler|null */ protected function createCrawlerFromContent($uri, $content, $type) { if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { return; } $crawler = new Crawler(null, $uri); $crawler->addContent($content, $type); return $crawler; } /** * Goes back in the browser history. * * @return Crawler */ public function back() { do { $request = $this->history->back(); } while (array_key_exists(serialize($request), $this->redirects)); return $this->requestFromRequest($request, false); } /** * Goes forward in the browser history. * * @return Crawler */ public function forward() { do { $request = $this->history->forward(); } while (array_key_exists(serialize($request), $this->redirects)); return $this->requestFromRequest($request, false); } /** * Reloads the current browser. * * @return Crawler */ public function reload() { return $this->requestFromRequest($this->history->current(), false); } /** * Follow redirects? * * @return Crawler * * @throws \LogicException If request was not a redirect */ public function followRedirect() { if (empty($this->redirect)) { throw new \LogicException('The request was not redirected.'); } if (-1 !== $this->maxRedirects) { if ($this->redirectCount > $this->maxRedirects) { $this->redirectCount = 0; throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects)); } } $request = $this->internalRequest; if (in_array($this->internalResponse->getStatus(), array(301, 302, 303))) { $method = 'GET'; $files = array(); $content = null; } else { $method = $request->getMethod(); $files = $request->getFiles(); $content = $request->getContent(); } if ('GET' === strtoupper($method)) { // Don't forward parameters for GET request as it should reach the redirection URI $parameters = array(); } else { $parameters = $request->getParameters(); } $server = $request->getServer(); $server = $this->updateServerFromUri($server, $this->redirect); $this->isMainRequest = false; $response = $this->request($method, $this->redirect, $parameters, $files, $server, $content); $this->isMainRequest = true; return $response; } /** * Restarts the client. * * It flushes history and all cookies. */ public function restart() { $this->cookieJar->clear(); $this->history->clear(); } /** * Takes a URI and converts it to absolute if it is not already absolute. * * @param string $uri A URI * * @return string An absolute URI */ protected function getAbsoluteUri($uri) { // already absolute? if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) { return $uri; } if (!$this->history->isEmpty()) { $currentUri = $this->history->current()->getUri(); } else { $currentUri = sprintf('http%s://%s/', isset($this->server['HTTPS']) ? 's' : '', isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost' ); } // protocol relative URL if (0 === strpos($uri, '//')) { return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri; } // anchor or query string parameters? if (!$uri || '#' == $uri[0] || '?' == $uri[0]) { return preg_replace('/[#?].*?$/', '', $currentUri).$uri; } if ('/' !== $uri[0]) { $path = parse_url($currentUri, PHP_URL_PATH); if ('/' !== substr($path, -1)) { $path = substr($path, 0, strrpos($path, '/') + 1); } $uri = $path.$uri; } return preg_replace('#^(.*?//[^/]+)\/.*$#', '$1', $currentUri).$uri; } /** * Makes a request from a Request object directly. * * @param Request $request A Request instance * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) * * @return Crawler */ protected function requestFromRequest(Request $request, $changeHistory = true) { return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory); } private function updateServerFromUri($server, $uri) { $server['HTTP_HOST'] = $this->extractHost($uri); $scheme = parse_url($uri, PHP_URL_SCHEME); $server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme; unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']); return $server; } private function extractHost($uri) { $host = parse_url($uri, PHP_URL_HOST); if ($port = parse_url($uri, PHP_URL_PORT)) { return $host.':'.$port; } return $host; } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Cookie.php000066400000000000000000000201431324732107100234420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; /** * Cookie represents an HTTP cookie. * * @author Fabien Potencier */ class Cookie { /** * Handles dates as defined by RFC 2616 section 3.3.1, and also some other * non-standard, but common formats. */ private static $dateFormats = array( 'D, d M Y H:i:s T', 'D, d-M-y H:i:s T', 'D, d-M-Y H:i:s T', 'D, d-m-y H:i:s T', 'D, d-m-Y H:i:s T', 'D M j G:i:s Y', 'D M d H:i:s Y T', ); protected $name; protected $value; protected $expires; protected $path; protected $domain; protected $secure; protected $httponly; protected $rawValue; /** * Sets a cookie. * * @param string $name The cookie name * @param string $value The value of the cookie * @param string $expires The time the cookie expires * @param string $path The path on the server in which the cookie will be available on * @param string $domain The domain that the cookie is available * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client * @param bool $httponly The cookie httponly flag * @param bool $encodedValue Whether the value is encoded or not */ public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false) { if ($encodedValue) { $this->value = urldecode($value); $this->rawValue = $value; } else { $this->value = $value; $this->rawValue = rawurlencode($value); } $this->name = $name; $this->path = empty($path) ? '/' : $path; $this->domain = $domain; $this->secure = (bool) $secure; $this->httponly = (bool) $httponly; if (null !== $expires) { $timestampAsDateTime = \DateTime::createFromFormat('U', $expires); if (false === $timestampAsDateTime) { throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires)); } $this->expires = $timestampAsDateTime->format('U'); } } /** * Returns the HTTP representation of the Cookie. */ public function __toString() { $cookie = sprintf('%s=%s', $this->name, $this->rawValue); if (null !== $this->expires) { $dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT')); $cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0])); } if ('' !== $this->domain) { $cookie .= '; domain='.$this->domain; } if ($this->path) { $cookie .= '; path='.$this->path; } if ($this->secure) { $cookie .= '; secure'; } if ($this->httponly) { $cookie .= '; httponly'; } return $cookie; } /** * Creates a Cookie instance from a Set-Cookie header value. * * @param string $cookie A Set-Cookie header value * @param string $url The base URL * * @return static * * @throws \InvalidArgumentException */ public static function fromString($cookie, $url = null) { $parts = explode(';', $cookie); if (false === strpos($parts[0], '=')) { throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0])); } list($name, $value) = explode('=', array_shift($parts), 2); $values = array( 'name' => trim($name), 'value' => trim($value), 'expires' => null, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => false, 'passedRawValue' => true, ); if (null !== $url) { if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) { throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url)); } $values['domain'] = $urlParts['host']; $values['path'] = isset($urlParts['path']) ? substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')) : ''; } foreach ($parts as $part) { $part = trim($part); if ('secure' === strtolower($part)) { // Ignore the secure flag if the original URI is not given or is not HTTPS if (!$url || !isset($urlParts['scheme']) || 'https' != $urlParts['scheme']) { continue; } $values['secure'] = true; continue; } if ('httponly' === strtolower($part)) { $values['httponly'] = true; continue; } if (2 === count($elements = explode('=', $part, 2))) { if ('expires' === strtolower($elements[0])) { $elements[1] = self::parseDate($elements[1]); } $values[strtolower($elements[0])] = $elements[1]; } } return new static( $values['name'], $values['value'], $values['expires'], $values['path'], $values['domain'], $values['secure'], $values['httponly'], $values['passedRawValue'] ); } private static function parseDate($dateValue) { // trim single quotes around date if present if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) { $dateValue = substr($dateValue, 1, -1); } foreach (self::$dateFormats as $dateFormat) { if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { return $date->format('U'); } } // attempt a fallback for unusual formatting if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { return $date->format('U'); } } /** * Gets the name of the cookie. * * @return string The cookie name */ public function getName() { return $this->name; } /** * Gets the value of the cookie. * * @return string The cookie value */ public function getValue() { return $this->value; } /** * Gets the raw value of the cookie. * * @return string The cookie value */ public function getRawValue() { return $this->rawValue; } /** * Gets the expires time of the cookie. * * @return string The cookie expires time */ public function getExpiresTime() { return $this->expires; } /** * Gets the path of the cookie. * * @return string The cookie path */ public function getPath() { return $this->path; } /** * Gets the domain of the cookie. * * @return string The cookie domain */ public function getDomain() { return $this->domain; } /** * Returns the secure flag of the cookie. * * @return bool The cookie secure flag */ public function isSecure() { return $this->secure; } /** * Returns the httponly flag of the cookie. * * @return bool The cookie httponly flag */ public function isHttpOnly() { return $this->httponly; } /** * Returns true if the cookie has expired. * * @return bool true if the cookie has expired, false otherwise */ public function isExpired() { return null !== $this->expires && 0 != $this->expires && $this->expires < time(); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/CookieJar.php000066400000000000000000000163151324732107100241050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; /** * CookieJar. * * @author Fabien Potencier */ class CookieJar { protected $cookieJar = array(); public function set(Cookie $cookie) { $this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; } /** * Gets a cookie by name. * * You should never use an empty domain, but if you do so, * this method returns the first cookie for the given name/path * (this behavior ensures a BC behavior with previous versions of * Symfony). * * @param string $name The cookie name * @param string $path The cookie path * @param string $domain The cookie domain * * @return Cookie|null A Cookie instance or null if the cookie does not exist */ public function get($name, $path = '/', $domain = null) { $this->flushExpiredCookies(); if (!empty($domain)) { foreach ($this->cookieJar as $cookieDomain => $pathCookies) { if ($cookieDomain) { $cookieDomain = '.'.ltrim($cookieDomain, '.'); if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) { continue; } } foreach ($pathCookies as $cookiePath => $namedCookies) { if ($cookiePath != substr($path, 0, strlen($cookiePath))) { continue; } if (isset($namedCookies[$name])) { return $namedCookies[$name]; } } } return; } // avoid relying on this behavior that is mainly here for BC reasons foreach ($this->cookieJar as $cookies) { if (isset($cookies[$path][$name])) { return $cookies[$path][$name]; } } } /** * Removes a cookie by name. * * You should never use an empty domain, but if you do so, * all cookies for the given name/path expire (this behavior * ensures a BC behavior with previous versions of Symfony). * * @param string $name The cookie name * @param string $path The cookie path * @param string $domain The cookie domain */ public function expire($name, $path = '/', $domain = null) { if (null === $path) { $path = '/'; } if (empty($domain)) { // an empty domain means any domain // this should never happen but it allows for a better BC $domains = array_keys($this->cookieJar); } else { $domains = array($domain); } foreach ($domains as $domain) { unset($this->cookieJar[$domain][$path][$name]); if (empty($this->cookieJar[$domain][$path])) { unset($this->cookieJar[$domain][$path]); if (empty($this->cookieJar[$domain])) { unset($this->cookieJar[$domain]); } } } } /** * Removes all the cookies from the jar. */ public function clear() { $this->cookieJar = array(); } /** * Updates the cookie jar from a response Set-Cookie headers. * * @param array $setCookies Set-Cookie headers from an HTTP response * @param string $uri The base URL */ public function updateFromSetCookie(array $setCookies, $uri = null) { $cookies = array(); foreach ($setCookies as $cookie) { foreach (explode(',', $cookie) as $i => $part) { if (0 === $i || preg_match('/^(?P\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) { $cookies[] = ltrim($part); } else { $cookies[count($cookies) - 1] .= ','.$part; } } } foreach ($cookies as $cookie) { try { $this->set(Cookie::fromString($cookie, $uri)); } catch (\InvalidArgumentException $e) { // invalid cookies are just ignored } } } /** * Updates the cookie jar from a Response object. * * @param Response $response A Response object * @param string $uri The base URL */ public function updateFromResponse(Response $response, $uri = null) { $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri); } /** * Returns not yet expired cookies. * * @return Cookie[] An array of cookies */ public function all() { $this->flushExpiredCookies(); $flattenedCookies = array(); foreach ($this->cookieJar as $path) { foreach ($path as $cookies) { foreach ($cookies as $cookie) { $flattenedCookies[] = $cookie; } } } return $flattenedCookies; } /** * Returns not yet expired cookie values for the given URI. * * @param string $uri A URI * @param bool $returnsRawValue Returns raw value or urldecoded value * * @return array An array of cookie values */ public function allValues($uri, $returnsRawValue = false) { $this->flushExpiredCookies(); $parts = array_replace(array('path' => '/'), parse_url($uri)); $cookies = array(); foreach ($this->cookieJar as $domain => $pathCookies) { if ($domain) { $domain = '.'.ltrim($domain, '.'); if ($domain != substr('.'.$parts['host'], -strlen($domain))) { continue; } } foreach ($pathCookies as $path => $namedCookies) { if ($path != substr($parts['path'], 0, strlen($path))) { continue; } foreach ($namedCookies as $cookie) { if ($cookie->isSecure() && 'https' != $parts['scheme']) { continue; } $cookies[$cookie->getName()] = $returnsRawValue ? $cookie->getRawValue() : $cookie->getValue(); } } } return $cookies; } /** * Returns not yet expired raw cookie values for the given URI. * * @param string $uri A URI * * @return array An array of cookie values */ public function allRawValues($uri) { return $this->allValues($uri, true); } /** * Removes all expired cookies. */ public function flushExpiredCookies() { foreach ($this->cookieJar as $domain => $pathCookies) { foreach ($pathCookies as $path => $namedCookies) { foreach ($namedCookies as $name => $cookie) { if ($cookie->isExpired()) { unset($this->cookieJar[$domain][$path][$name]); } } } } } } symfony-3.4.6/src/Symfony/Component/BrowserKit/History.php000066400000000000000000000043421324732107100236750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; /** * History. * * @author Fabien Potencier */ class History { protected $stack = array(); protected $position = -1; /** * Clears the history. */ public function clear() { $this->stack = array(); $this->position = -1; } /** * Adds a Request to the history. */ public function add(Request $request) { $this->stack = array_slice($this->stack, 0, $this->position + 1); $this->stack[] = clone $request; $this->position = count($this->stack) - 1; } /** * Returns true if the history is empty. * * @return bool true if the history is empty, false otherwise */ public function isEmpty() { return 0 == count($this->stack); } /** * Goes back in the history. * * @return Request A Request instance * * @throws \LogicException if the stack is already on the first page */ public function back() { if ($this->position < 1) { throw new \LogicException('You are already on the first page.'); } return clone $this->stack[--$this->position]; } /** * Goes forward in the history. * * @return Request A Request instance * * @throws \LogicException if the stack is already on the last page */ public function forward() { if ($this->position > count($this->stack) - 2) { throw new \LogicException('You are already on the last page.'); } return clone $this->stack[++$this->position]; } /** * Returns the current element in the history. * * @return Request A Request instance * * @throws \LogicException if the stack is empty */ public function current() { if (-1 == $this->position) { throw new \LogicException('The page history is empty.'); } return clone $this->stack[$this->position]; } } symfony-3.4.6/src/Symfony/Component/BrowserKit/LICENSE000066400000000000000000000020511324732107100225230ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Component/BrowserKit/README.md000066400000000000000000000011151324732107100227750ustar00rootroot00000000000000BrowserKit Component ==================== The BrowserKit component simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically. Resources --------- * [Documentation](https://symfony.com/doc/current/components/browser_kit/introduction.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Component/BrowserKit/Request.php000066400000000000000000000050361324732107100236650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; /** * @author Fabien Potencier */ class Request { protected $uri; protected $method; protected $parameters; protected $files; protected $cookies; protected $server; protected $content; /** * @param string $uri The request URI * @param string $method The HTTP method request * @param array $parameters The request parameters * @param array $files An array of uploaded files * @param array $cookies An array of cookies * @param array $server An array of server parameters * @param string $content The raw body data */ public function __construct($uri, $method, array $parameters = array(), array $files = array(), array $cookies = array(), array $server = array(), $content = null) { $this->uri = $uri; $this->method = $method; $this->parameters = $parameters; $this->files = $files; $this->cookies = $cookies; $this->server = $server; $this->content = $content; } /** * Gets the request URI. * * @return string The request URI */ public function getUri() { return $this->uri; } /** * Gets the request HTTP method. * * @return string The request HTTP method */ public function getMethod() { return $this->method; } /** * Gets the request parameters. * * @return array The request parameters */ public function getParameters() { return $this->parameters; } /** * Gets the request server files. * * @return array The request files */ public function getFiles() { return $this->files; } /** * Gets the request cookies. * * @return array The request cookies */ public function getCookies() { return $this->cookies; } /** * Gets the request server parameters. * * @return array The request server parameters */ public function getServer() { return $this->server; } /** * Gets the request raw body data. * * @return string The request raw body data */ public function getContent() { return $this->content; } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Response.php000066400000000000000000000063121324732107100240310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit; /** * @author Fabien Potencier */ class Response { protected $content; protected $status; protected $headers; /** * The headers array is a set of key/value pairs. If a header is present multiple times * then the value is an array of all the values. * * @param string $content The content of the response * @param int $status The response status code * @param array $headers An array of headers */ public function __construct($content = '', $status = 200, array $headers = array()) { $this->content = $content; $this->status = $status; $this->headers = $headers; } /** * Converts the response object to string containing all headers and the response content. * * @return string The response with headers and content */ public function __toString() { $headers = ''; foreach ($this->headers as $name => $value) { if (is_string($value)) { $headers .= $this->buildHeader($name, $value); } else { foreach ($value as $headerValue) { $headers .= $this->buildHeader($name, $headerValue); } } } return $headers."\n".$this->content; } /** * Returns the build header line. * * @param string $name The header name * @param string $value The header value * * @return string The built header line */ protected function buildHeader($name, $value) { return sprintf("%s: %s\n", $name, $value); } /** * Gets the response content. * * @return string The response content */ public function getContent() { return $this->content; } /** * Gets the response status code. * * @return int The response status code */ public function getStatus() { return $this->status; } /** * Gets the response headers. * * @return array The response headers */ public function getHeaders() { return $this->headers; } /** * Gets a response header. * * @param string $header The header name * @param bool $first Whether to return the first value or all header values * * @return string|array The first header value if $first is true, an array of values otherwise */ public function getHeader($header, $first = true) { $normalizedHeader = str_replace('-', '_', strtolower($header)); foreach ($this->headers as $key => $value) { if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) { if ($first) { return is_array($value) ? (count($value) ? $value[0] : '') : $value; } return is_array($value) ? $value : array($value); } } return $first ? null : array(); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/000077500000000000000000000000001324732107100226225ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/ClientTest.php000066400000000000000000001002111324732107100254040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\Response; class SpecialResponse extends Response { } class TestClient extends Client { protected $nextResponse = null; protected $nextScript = null; public function setNextResponse(Response $response) { $this->nextResponse = $response; } public function setNextScript($script) { $this->nextScript = $script; } protected function doRequest($request) { if (null === $this->nextResponse) { return new Response(); } $response = $this->nextResponse; $this->nextResponse = null; return $response; } protected function filterResponse($response) { if ($response instanceof SpecialResponse) { return new Response($response->getContent(), $response->getStatus(), $response->getHeaders()); } return $response; } protected function getScript($request) { $r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); $path = $r->getFileName(); return <<nextScript); EOF; } } class ClientTest extends TestCase { public function testGetHistory() { $client = new TestClient(array(), $history = new History()); $this->assertSame($history, $client->getHistory(), '->getHistory() returns the History'); } public function testGetCookieJar() { $client = new TestClient(array(), null, $cookieJar = new CookieJar()); $this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar'); } public function testGetRequest() { $client = new TestClient(); $client->request('GET', 'http://example.com/'); $this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request'); } public function testGetRequestWithIpAsHttpHost() { $client = new TestClient(); $client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1')); $this->assertEquals('https://example.com/foo', $client->getRequest()->getUri()); $headers = $client->getRequest()->getServer(); $this->assertEquals('127.0.0.1', $headers['HTTP_HOST']); } public function testGetResponse() { $client = new TestClient(); $client->setNextResponse(new Response('foo')); $client->request('GET', 'http://example.com/'); $this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request'); } public function testGetInternalResponse() { $client = new TestClient(); $client->setNextResponse(new SpecialResponse('foo')); $client->request('GET', 'http://example.com/'); $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); $this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse()); $this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse()); } public function testGetContent() { $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; $client = new TestClient(); $client->request('POST', 'http://example.com/jsonrpc', array(), array(), array(), $json); $this->assertEquals($json, $client->getRequest()->getContent()); } public function testGetCrawler() { $client = new TestClient(); $client->setNextResponse(new Response('foo')); $crawler = $client->request('GET', 'http://example.com/'); $this->assertSame($crawler, $client->getCrawler(), '->getCrawler() returns the Crawler of the last request'); } public function testRequestHttpHeaders() { $client = new TestClient(); $client->request('GET', '/'); $headers = $client->getRequest()->getServer(); $this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); $client = new TestClient(); $client->request('GET', 'http://www.example.com'); $headers = $client->getRequest()->getServer(); $this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); $client->request('GET', 'https://www.example.com'); $headers = $client->getRequest()->getServer(); $this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header'); $client = new TestClient(); $client->request('GET', 'http://www.example.com:8080'); $headers = $client->getRequest()->getServer(); $this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port'); } public function testRequestURIConversion() { $client = new TestClient(); $client->request('GET', '/foo'); $this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one'); $client = new TestClient(); $client->request('GET', 'http://www.example.com'); $this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/'); $client->request('GET', '/foo'); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', '#'); $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client->request('GET', '#'); $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client->request('GET', '#foo'); $this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/'); $client->request('GET', 'bar'); $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/'); $client->request('GET', 'http'); $this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', 'http/bar'); $this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/'); $client->request('GET', 'http'); $this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', '?'); $this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); $client->request('GET', '?'); $this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); $client->request('GET', '?foo=bar'); $this->assertEquals('http://www.example.com/foo?foo=bar', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); } public function testRequestReferer() { $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $server = $client->getRequest()->getServer(); $this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer'); } public function testRequestHistory() { $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History'); $this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History'); } public function testRequestCookies() { $client = new TestClient(); $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); $client->request('GET', 'bar'); $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); } public function testRequestSecureCookies() { $client = new TestClient(); $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar; path=/; secure'))); $client->request('GET', 'https://www.example.com/foo/foobar'); $this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure()); } public function testClick() { $client = new TestClient(); $client->setNextResponse(new Response('foo')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); $client->click($crawler->filter('a')->link()); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); } public function testClickForm() { $client = new TestClient(); $client->setNextResponse(new Response('
    ')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); $client->click($crawler->filter('input')->form()); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms'); } public function testSubmit() { $client = new TestClient(); $client->setNextResponse(new Response('
    ')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); $client->submit($crawler->filter('input')->form()); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); } public function testSubmitPreserveAuth() { $client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar')); $client->setNextResponse(new Response('
    ')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('PHP_AUTH_USER', $server); $this->assertEquals('foo', $server['PHP_AUTH_USER']); $this->assertArrayHasKey('PHP_AUTH_PW', $server); $this->assertEquals('bar', $server['PHP_AUTH_PW']); $client->submit($crawler->filter('input')->form()); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('PHP_AUTH_USER', $server); $this->assertEquals('foo', $server['PHP_AUTH_USER']); $this->assertArrayHasKey('PHP_AUTH_PW', $server); $this->assertEquals('bar', $server['PHP_AUTH_PW']); } public function testFollowRedirect() { $client = new TestClient(); $client->followRedirects(false); $client->request('GET', 'http://www.example.com/foo/foobar'); try { $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was not redirected'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); } $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->followRedirect(); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = new TestClient(); $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); $client = new TestClient(); $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); $client = new TestClient(); $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); $client->followRedirects(false); $client->request('GET', 'http://www.example.com/foo/foobar'); try { $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } } public function testFollowRelativeRedirect() { $client = new TestClient(); $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = new TestClient(); $client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); } public function testFollowRedirectWithMaxRedirects() { $client = new TestClient(); $client->setMaxRedirects(1); $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2'))); try { $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); $client = new TestClient(); $client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/'))); $client->request('GET', 'https://www.example.com/'); $this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); $client = new TestClient(); $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); $client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar')); $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() uses a GET for 302'); $this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); } public function testFollowRedirectWithCookies() { $client = new TestClient(); $client->followRedirects(false); $client->setNextResponse(new Response('', 302, array( 'Location' => 'http://www.example.com/redirected', 'Set-Cookie' => 'foo=bar', ))); $client->request('GET', 'http://www.example.com/'); $this->assertEquals(array(), $client->getRequest()->getCookies()); $client->followRedirect(); $this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies()); } public function testFollowRedirectWithHeaders() { $headers = array( 'HTTP_HOST' => 'www.example.com', 'HTTP_USER_AGENT' => 'Symfony BrowserKit', 'CONTENT_TYPE' => 'application/vnd.custom+xml', 'HTTPS' => false, ); $client = new TestClient(); $client->followRedirects(false); $client->setNextResponse(new Response('', 302, array( 'Location' => 'http://www.example.com/redirected', ))); $client->request('GET', 'http://www.example.com/', array(), array(), array( 'CONTENT_TYPE' => 'application/vnd.custom+xml', )); $this->assertEquals($headers, $client->getRequest()->getServer()); $client->followRedirect(); $headers['HTTP_REFERER'] = 'http://www.example.com/'; $this->assertEquals($headers, $client->getRequest()->getServer()); } public function testFollowRedirectWithPort() { $headers = array( 'HTTP_HOST' => 'www.example.com:8080', 'HTTP_USER_AGENT' => 'Symfony BrowserKit', 'HTTPS' => false, 'HTTP_REFERER' => 'http://www.example.com:8080/', ); $client = new TestClient(); $client->setNextResponse(new Response('', 302, array( 'Location' => 'http://www.example.com:8080/redirected', ))); $client->request('GET', 'http://www.example.com:8080/'); $this->assertEquals($headers, $client->getRequest()->getServer()); } public function testIsFollowingRedirects() { $client = new TestClient(); $this->assertTrue($client->isFollowingRedirects(), '->getFollowRedirects() returns default value'); $client->followRedirects(false); $this->assertFalse($client->isFollowingRedirects(), '->getFollowRedirects() returns assigned value'); } public function testGetMaxRedirects() { $client = new TestClient(); $this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value'); $client->setMaxRedirects(3); $this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value'); } public function testFollowRedirectWithPostMethod() { $parameters = array('foo' => 'bar'); $files = array('myfile.foo' => 'baz'); $server = array('X_TEST_FOO' => 'bazbar'); $content = 'foobarbaz'; $client = new TestClient(); $client->setNextResponse(new Response('', 307, array('Location' => 'http://www.example.com/redirected'))); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->followRedirect() keeps parameters with POST method'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->followRedirect() keeps files with POST method'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method'); $this->assertEquals($content, $client->getRequest()->getContent(), '->followRedirect() keeps content with POST method'); $this->assertEquals('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method'); } public function testFollowRedirectDropPostMethod() { $parameters = array('foo' => 'bar'); $files = array('myfile.foo' => 'baz'); $server = array('X_TEST_FOO' => 'bazbar'); $content = 'foobarbaz'; $client = new TestClient(); foreach (array(301, 302, 303) as $code) { $client->setNextResponse(new Response('', $code, array('Location' => 'http://www.example.com/redirected'))); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getParameters(), '->followRedirect() drops parameters with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getFiles(), '->followRedirect() drops files with POST method on response code: '.$code.'.'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getContent(), '->followRedirect() drops content with POST method on response code: '.$code.'.'); $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() drops request method to GET on response code: '.$code.'.'); } } public function testBack() { $client = new TestClient(); $parameters = array('foo' => 'bar'); $files = array('myfile.foo' => 'baz'); $server = array('X_TEST_FOO' => 'bazbar'); $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $client->request('GET', 'http://www.example.com/foo'); $client->back(); $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->back() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->back() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->back() keeps $_SERVER'); $this->assertEquals($content, $client->getRequest()->getContent(), '->back() keeps content'); } public function testForward() { $client = new TestClient(); $parameters = array('foo' => 'bar'); $files = array('myfile.foo' => 'baz'); $server = array('X_TEST_FOO' => 'bazbar'); $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'http://www.example.com/foo', $parameters, $files, $server, $content); $client->back(); $client->forward(); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->forward() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->forward() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->forward() keeps $_SERVER'); $this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content'); } public function testBackAndFrowardWithRedirects() { $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo'); $client->setNextResponse(new Response('', 301, array('Location' => 'http://www.example.com/redirected'))); $client->request('GET', 'http://www.example.com/bar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), 'client followed redirect'); $client->back(); $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->back() goes back in the history skipping redirects'); $client->forward(); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->forward() goes forward in the history skipping redirects'); } public function testReload() { $client = new TestClient(); $parameters = array('foo' => 'bar'); $files = array('myfile.foo' => 'baz'); $server = array('X_TEST_FOO' => 'bazbar'); $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $client->reload(); $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER'); $this->assertEquals($content, $client->getRequest()->getContent(), '->reload() keeps content'); } public function testRestart() { $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->restart(); $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history'); $this->assertEquals(array(), $client->getCookieJar()->all(), '->restart() clears the cookies'); } public function testInsulatedRequests() { $client = new TestClient(); $client->insulate(); $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')"); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process'); $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar)"); try { $client->request('GET', 'http://www.example.com/foo/foobar'); $this->fail('->request() throws a \RuntimeException if the script has an error'); } catch (\Exception $e) { $this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error'); } } public function testGetServerParameter() { $client = new TestClient(); $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue')); } public function testSetServerParameter() { $client = new TestClient(); $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->setServerParameter('HTTP_HOST', 'testhost'); $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST')); $client->setServerParameter('HTTP_USER_AGENT', 'testua'); $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT')); } public function testSetServerParameterInRequest() { $client = new TestClient(); $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, 'NEW_SERVER_KEY' => 'new-server-key-value', )); $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $this->assertEquals('http://www.example.com/https/www.example.com', $client->getRequest()->getUri()); $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('HTTP_USER_AGENT', $server); $this->assertEquals('testua', $server['HTTP_USER_AGENT']); $this->assertArrayHasKey('HTTP_HOST', $server); $this->assertEquals('testhost', $server['HTTP_HOST']); $this->assertArrayHasKey('NEW_SERVER_KEY', $server); $this->assertEquals('new-server-key-value', $server['NEW_SERVER_KEY']); $this->assertArrayHasKey('HTTPS', $server); $this->assertFalse($server['HTTPS']); } public function testInternalRequest() { $client = new TestClient(); $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, 'NEW_SERVER_KEY' => 'new-server-key-value', )); $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); } public function testInternalRequestNull() { $client = new TestClient(); $this->assertNull($client->getInternalRequest()); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php000066400000000000000000000253421324732107100260470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\Response; class CookieJarTest extends TestCase { public function testSetGet() { $cookieJar = new CookieJar(); $cookieJar->set($cookie = new Cookie('foo', 'bar')); $this->assertEquals($cookie, $cookieJar->get('foo'), '->set() sets a cookie'); $this->assertNull($cookieJar->get('foobar'), '->get() returns null if the cookie does not exist'); $cookieJar->set($cookie = new Cookie('foo', 'bar', time() - 86400)); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); } public function testExpire() { $cookieJar = new CookieJar(); $cookieJar->set($cookie = new Cookie('foo', 'bar')); $cookieJar->expire('foo'); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); } public function testAll() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar')); $cookieJar->set($cookie2 = new Cookie('bar', 'foo')); $this->assertEquals(array($cookie1, $cookie2), $cookieJar->all(), '->all() returns all cookies in the jar'); } public function testClear() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar')); $cookieJar->set($cookie2 = new Cookie('bar', 'foo')); $cookieJar->clear(); $this->assertEquals(array(), $cookieJar->all(), '->clear() expires all cookies'); } public function testUpdateFromResponse() { $response = new Response('', 200, array('Set-Cookie' => 'foo=foo')); $cookieJar = new CookieJar(); $cookieJar->updateFromResponse($response); $this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromResponse() updates cookies from a Response objects'); } public function testUpdateFromSetCookie() { $setCookies = array('foo=foo'); $cookieJar = new CookieJar(); $cookieJar->set(new Cookie('bar', 'bar')); $cookieJar->updateFromSetCookie($setCookies); $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo')); $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar')); $this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header'); $this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies'); } public function testUpdateFromEmptySetCookie() { $cookieJar = new CookieJar(); $cookieJar->updateFromSetCookie(array('')); $this->assertEquals(array(), $cookieJar->all()); } public function testUpdateFromSetCookieWithMultipleCookies() { $timestamp = time() + 3600; $date = gmdate('D, d M Y H:i:s \G\M\T', $timestamp); $setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%1$s', $date)); $cookieJar = new CookieJar(); $cookieJar->updateFromSetCookie($setCookies); $fooCookie = $cookieJar->get('foo', '/', '.symfony.com'); $barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com'); $phpCookie = $cookieJar->get('PHPSESSID'); $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie); $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie); $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie); $this->assertEquals('foo', $fooCookie->getValue()); $this->assertEquals('bar', $barCookie->getValue()); $this->assertEquals('id', $phpCookie->getValue()); $this->assertEquals($timestamp, $fooCookie->getExpiresTime()); $this->assertNull($barCookie->getExpiresTime()); $this->assertEquals($timestamp, $phpCookie->getExpiresTime()); } /** * @dataProvider provideAllValuesValues */ public function testAllValues($uri, $values) { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo_nothing', 'foo')); $cookieJar->set($cookie2 = new Cookie('foo_expired', 'foo', time() - 86400)); $cookieJar->set($cookie3 = new Cookie('foo_path', 'foo', null, '/foo')); $cookieJar->set($cookie4 = new Cookie('foo_domain', 'foo', null, '/', '.example.com')); $cookieJar->set($cookie4 = new Cookie('foo_strict_domain', 'foo', null, '/', '.www4.example.com')); $cookieJar->set($cookie5 = new Cookie('foo_secure', 'foo', null, '/', '', true)); $this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI'); } public function provideAllValuesValues() { return array( array('http://www.example.com', array('foo_nothing', 'foo_domain')), array('http://www.example.com/', array('foo_nothing', 'foo_domain')), array('http://foo.example.com/', array('foo_nothing', 'foo_domain')), array('http://foo.example1.com/', array('foo_nothing')), array('https://foo.example.com/', array('foo_nothing', 'foo_secure', 'foo_domain')), array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')), array('http://www4.example.com/', array('foo_nothing', 'foo_domain', 'foo_strict_domain')), ); } public function testEncodedValues() { $cookieJar = new CookieJar(); $cookieJar->set($cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true)); $this->assertEquals(array('foo' => 'bar=baz'), $cookieJar->allValues('/')); $this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/')); } public function testCookieExpireWithSameNameButDifferentPaths() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo')); $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar')); $cookieJar->expire('foo', '/foo'); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); $this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo')); $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); } public function testCookieExpireWithNullPaths() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/')); $cookieJar->expire('foo', null); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); } public function testCookieExpireWithDomain() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo', 'http://example2.com/')); $cookieJar->expire('foo', '/foo', 'http://example2.com/'); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example2.com/'))); } public function testCookieWithSameNameButDifferentPaths() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo')); $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar')); $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://example.com/foo')); $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); } public function testCookieWithSameNameButDifferentDomains() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/', 'foo.example.com')); $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/', 'bar.example.com')); $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://foo.example.com/')); $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/')); } public function testCookieGetWithSubdomain() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/', '.example.com')); $cookieJar->set($cookie2 = new Cookie('foo1', 'bar', null, '/', 'test.example.com')); $this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'foo.example.com')); $this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'example.com')); $this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com')); } public function testCookieGetWithWrongSubdomain() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo1', 'bar', null, '/', 'test.example.com')); $this->assertNull($cookieJar->get('foo1', '/', 'foo.example.com')); } public function testCookieGetWithSubdirectory() { $cookieJar = new CookieJar(); $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/test', '.example.com')); $cookieJar->set($cookie2 = new Cookie('foo1', 'bar1', null, '/', '.example.com')); $this->assertNull($cookieJar->get('foo', '/', '.example.com')); $this->assertNull($cookieJar->get('foo', '/bar', '.example.com')); $this->assertEquals($cookie1, $cookieJar->get('foo', '/test', 'example.com')); $this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'example.com')); $this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar', 'example.com')); } public function testCookieWithWildcardDomain() { $cookieJar = new CookieJar(); $cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com')); $this->assertEquals(array('foo' => 'bar'), $cookieJar->allValues('http://www.example.com')); $this->assertEmpty($cookieJar->allValues('http://wwwexample.com')); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/CookieTest.php000066400000000000000000000217141324732107100254110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Cookie; class CookieTest extends TestCase { public function testToString() { $cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); $this->assertEquals('foo=bar; expires=Fri, 20 May 2011 15:25:52 GMT; domain=.myfoodomain.com; path=/; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie'); $cookie = new Cookie('foo', 'bar with white spaces', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); $this->assertEquals('foo=bar%20with%20white%20spaces; expires=Fri, 20 May 2011 15:25:52 GMT; domain=.myfoodomain.com; path=/; secure; httponly', (string) $cookie, '->__toString() encodes the value of the cookie according to RFC 3986 (white space = %20)'); $cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com'); $this->assertEquals('foo=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=.myfoodomain.com; path=/admin/; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL'); $cookie = new Cookie('foo', 'bar', 0, '/', ''); $this->assertEquals('foo=bar; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; httponly', (string) $cookie); } /** * @dataProvider getTestsForToFromString */ public function testToFromString($cookie, $url = null) { $this->assertEquals($cookie, (string) Cookie::fromString($cookie, $url)); } public function getTestsForToFromString() { return array( array('foo=bar; path=/'), array('foo=bar; path=/foo'), array('foo=bar; domain=google.com; path=/'), array('foo=bar; domain=example.com; path=/; secure', 'https://example.com/'), array('foo=bar; path=/; httponly'), array('foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'), array('foo=bar=baz; path=/'), array('foo=bar%3Dbaz; path=/'), ); } public function testFromStringIgnoreSecureFlag() { $this->assertFalse(Cookie::fromString('foo=bar; secure')->isSecure()); $this->assertFalse(Cookie::fromString('foo=bar; secure', 'http://example.com/')->isSecure()); } /** * @dataProvider getExpireCookieStrings */ public function testFromStringAcceptsSeveralExpiresDateFormats($cookie) { $this->assertEquals(1596185377, Cookie::fromString($cookie)->getExpiresTime()); } public function getExpireCookieStrings() { return array( array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'), array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'), array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'), array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'), array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'), array('foo=bar; expires=Fri Jul 31 08:49:37 2020'), array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''), array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'), ); } public function testFromStringWithCapitalization() { $this->assertEquals('Foo=Bar; path=/', (string) Cookie::fromString('Foo=Bar')); $this->assertEquals('foo=bar; expires=Fri, 31 Dec 2010 23:59:59 GMT; path=/', (string) Cookie::fromString('foo=bar; Expires=Fri, 31 Dec 2010 23:59:59 GMT')); $this->assertEquals('foo=bar; domain=www.example.org; path=/; httponly', (string) Cookie::fromString('foo=bar; DOMAIN=www.example.org; HttpOnly')); } public function testFromStringWithUrl() { $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com/')); $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com')); $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com?foo')); $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::fromString('foo=bar', 'http://www.example.com/foo/bar')); $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); $this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::fromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); } public function testFromStringThrowsAnExceptionIfCookieIsNotValid() { $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException'); Cookie::fromString('foo'); } public function testFromStringIgnoresInvalidExpiresDate() { $cookie = Cookie::fromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT'); $this->assertFalse($cookie->isExpired()); } public function testFromStringThrowsAnExceptionIfUrlIsNotValid() { $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException'); Cookie::fromString('foo=bar', 'foobar'); } public function testGetName() { $cookie = new Cookie('foo', 'bar'); $this->assertEquals('foo', $cookie->getName(), '->getName() returns the cookie name'); } public function testGetValue() { $cookie = new Cookie('foo', 'bar'); $this->assertEquals('bar', $cookie->getValue(), '->getValue() returns the cookie value'); $cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value $this->assertEquals('bar=baz', $cookie->getValue(), '->getValue() returns the urldecoded cookie value'); } public function testGetRawValue() { $cookie = new Cookie('foo', 'bar=baz'); // decoded value $this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the urlencoded cookie value'); $cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value $this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the non-urldecoded cookie value'); } public function testGetPath() { $cookie = new Cookie('foo', 'bar', 0); $this->assertEquals('/', $cookie->getPath(), '->getPath() returns / is no path is defined'); $cookie = new Cookie('foo', 'bar', 0, '/foo'); $this->assertEquals('/foo', $cookie->getPath(), '->getPath() returns the cookie path'); } public function testGetDomain() { $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com'); $this->assertEquals('foo.com', $cookie->getDomain(), '->getDomain() returns the cookie domain'); } public function testIsSecure() { $cookie = new Cookie('foo', 'bar'); $this->assertFalse($cookie->isSecure(), '->isSecure() returns false if not defined'); $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', true); $this->assertTrue($cookie->isSecure(), '->isSecure() returns the cookie secure flag'); } public function testIsHttponly() { $cookie = new Cookie('foo', 'bar'); $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns false if not defined'); $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', false, true); $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns the cookie httponly flag'); } public function testGetExpiresTime() { $cookie = new Cookie('foo', 'bar'); $this->assertNull($cookie->getExpiresTime(), '->getExpiresTime() returns the expires time'); $cookie = new Cookie('foo', 'bar', $time = time() - 86400); $this->assertEquals($time, $cookie->getExpiresTime(), '->getExpiresTime() returns the expires time'); } public function testIsExpired() { $cookie = new Cookie('foo', 'bar'); $this->assertFalse($cookie->isExpired(), '->isExpired() returns false when the cookie never expires (null as expires time)'); $cookie = new Cookie('foo', 'bar', time() - 86400); $this->assertTrue($cookie->isExpired(), '->isExpired() returns true when the cookie is expired'); $cookie = new Cookie('foo', 'bar', 0); $this->assertFalse($cookie->isExpired()); } /** * @expectedException \UnexpectedValueException * @expectedExceptionMessage The cookie expiration time "string" is not valid. */ public function testConstructException() { $cookie = new Cookie('foo', 'bar', 'string'); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php000066400000000000000000000073741324732107100256470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\Request; class HistoryTest extends TestCase { public function testAdd() { $history = new History(); $history->add(new Request('http://www.example1.com/', 'get')); $this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->add() adds a request to the history'); $history->add(new Request('http://www.example2.com/', 'get')); $this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history'); $history->add(new Request('http://www.example3.com/', 'get')); $history->back(); $history->add(new Request('http://www.example4.com/', 'get')); $this->assertSame('http://www.example4.com/', $history->current()->getUri(), '->add() adds a request to the history'); $history->back(); $this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history'); } public function testClearIsEmpty() { $history = new History(); $history->add(new Request('http://www.example.com/', 'get')); $this->assertFalse($history->isEmpty(), '->isEmpty() returns false if the history is not empty'); $history->clear(); $this->assertTrue($history->isEmpty(), '->isEmpty() true if the history is empty'); } public function testCurrent() { $history = new History(); try { $history->current(); $this->fail('->current() throws a \LogicException if the history is empty'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is empty'); } $history->add(new Request('http://www.example.com/', 'get')); $this->assertSame('http://www.example.com/', $history->current()->getUri(), '->current() returns the current request in the history'); } public function testBack() { $history = new History(); $history->add(new Request('http://www.example.com/', 'get')); try { $history->back(); $this->fail('->back() throws a \LogicException if the history is already on the first page'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page'); } $history->add(new Request('http://www.example1.com/', 'get')); $history->back(); $this->assertSame('http://www.example.com/', $history->current()->getUri(), '->back() returns the previous request in the history'); } public function testForward() { $history = new History(); $history->add(new Request('http://www.example.com/', 'get')); $history->add(new Request('http://www.example1.com/', 'get')); try { $history->forward(); $this->fail('->forward() throws a \LogicException if the history is already on the last page'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page'); } $history->back(); $history->forward(); $this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->forward() returns the next request in the history'); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/RequestTest.php000066400000000000000000000037221324732107100256270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Request; class RequestTest extends TestCase { public function testGetUri() { $request = new Request('http://www.example.com/', 'get'); $this->assertEquals('http://www.example.com/', $request->getUri(), '->getUri() returns the URI of the request'); } public function testGetMethod() { $request = new Request('http://www.example.com/', 'get'); $this->assertEquals('get', $request->getMethod(), '->getMethod() returns the method of the request'); } public function testGetParameters() { $request = new Request('http://www.example.com/', 'get', array('foo' => 'bar')); $this->assertEquals(array('foo' => 'bar'), $request->getParameters(), '->getParameters() returns the parameters of the request'); } public function testGetFiles() { $request = new Request('http://www.example.com/', 'get', array(), array('foo' => 'bar')); $this->assertEquals(array('foo' => 'bar'), $request->getFiles(), '->getFiles() returns the uploaded files of the request'); } public function testGetCookies() { $request = new Request('http://www.example.com/', 'get', array(), array(), array('foo' => 'bar')); $this->assertEquals(array('foo' => 'bar'), $request->getCookies(), '->getCookies() returns the cookies of the request'); } public function testGetServer() { $request = new Request('http://www.example.com/', 'get', array(), array(), array(), array('foo' => 'bar')); $this->assertEquals(array('foo' => 'bar'), $request->getServer(), '->getServer() returns the server parameters of the request'); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php000066400000000000000000000060511324732107100257730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Response; class ResponseTest extends TestCase { public function testGetUri() { $response = new Response('foo'); $this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response'); } public function testGetStatus() { $response = new Response('foo', 304); $this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response'); } public function testGetHeaders() { $response = new Response('foo', 200, array('foo' => 'bar')); $this->assertEquals(array('foo' => 'bar'), $response->getHeaders(), '->getHeaders() returns the headers of the response'); } public function testGetHeader() { $response = new Response('foo', 200, array( 'Content-Type' => 'text/html', 'Set-Cookie' => array('foo=bar', 'bar=foo'), )); $this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response'); $this->assertEquals('text/html', $response->getHeader('content-type'), '->getHeader() returns a header of the response'); $this->assertEquals('text/html', $response->getHeader('content_type'), '->getHeader() returns a header of the response'); $this->assertEquals('foo=bar', $response->getHeader('Set-Cookie'), '->getHeader() returns the first header value'); $this->assertEquals(array('foo=bar', 'bar=foo'), $response->getHeader('Set-Cookie', false), '->getHeader() returns all header values if first is false'); $this->assertNull($response->getHeader('foo'), '->getHeader() returns null if the header is not defined'); $this->assertEquals(array(), $response->getHeader('foo', false), '->getHeader() returns an empty array if the header is not defined and first is set to false'); } public function testMagicToString() { $response = new Response('foo', 304, array('foo' => 'bar')); $this->assertEquals("foo: bar\n\nfoo", $response->__toString(), '->__toString() returns the headers and the content as a string'); } public function testMagicToStringWithMultipleSetCookieHeader() { $headers = array( 'content-type' => 'text/html; charset=utf-8', 'set-cookie' => array('foo=bar', 'bar=foo'), ); $expected = 'content-type: text/html; charset=utf-8'."\n"; $expected .= 'set-cookie: foo=bar'."\n"; $expected .= 'set-cookie: bar=foo'."\n\n"; $expected .= 'foo'; $response = new Response('foo', 304, $headers); $this->assertEquals($expected, $response->__toString(), '->__toString() returns the headers and the content as a string'); } } symfony-3.4.6/src/Symfony/Component/BrowserKit/composer.json000066400000000000000000000017501324732107100242450ustar00rootroot00000000000000{ "name": "symfony/browser-kit", "type": "library", "description": "Symfony BrowserKit Component", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/dom-crawler": "~2.8|~3.0|~4.0" }, "require-dev": { "symfony/process": "~2.8|~3.0|~4.0", "symfony/css-selector": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/process": "" }, "autoload": { "psr-4": { "Symfony\\Component\\BrowserKit\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Component/BrowserKit/phpunit.xml.dist000066400000000000000000000015701324732107100246760ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Component/Cache/000077500000000000000000000000001324732107100204305ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/.gitignore000066400000000000000000000000421324732107100224140ustar00rootroot00000000000000composer.lock phpunit.xml vendor/ symfony-3.4.6/src/Symfony/Component/Cache/Adapter/000077500000000000000000000000001324732107100220105ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php000066400000000000000000000225531324732107100255740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\AbstractTrait; /** * @author Nicolas Grekas */ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface, ResettableInterface { use AbstractTrait; private static $apcuSupported; private static $phpFilesSupported; private $createCacheItem; private $mergeByLifetime; /** * @param string $namespace * @param int $defaultLifetime */ protected function __construct($namespace = '', $defaultLifetime = 0) { $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace)); } $this->createCacheItem = \Closure::bind( function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $value; $item->isHit = $isHit; $item->defaultLifetime = $defaultLifetime; return $item; }, null, CacheItem::class ); $getId = function ($key) { return $this->getId((string) $key); }; $this->mergeByLifetime = \Closure::bind( function ($deferred, $namespace, &$expiredIds) use ($getId) { $byLifetime = array(); $now = time(); $expiredIds = array(); foreach ($deferred as $key => $item) { if (null === $item->expiry) { $byLifetime[0 < $item->defaultLifetime ? $item->defaultLifetime : 0][$getId($key)] = $item->value; } elseif ($item->expiry > $now) { $byLifetime[$item->expiry - $now][$getId($key)] = $item->value; } else { $expiredIds[] = $getId($key); } } return $byLifetime; }, null, CacheItem::class ); } /** * @param string $namespace * @param int $defaultLifetime * @param string $version * @param string $directory * @param LoggerInterface|null $logger * * @return AdapterInterface */ public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) { if (null === self::$apcuSupported) { self::$apcuSupported = ApcuAdapter::isSupported(); } if (!self::$apcuSupported && null === self::$phpFilesSupported) { self::$phpFilesSupported = PhpFilesAdapter::isSupported(); } if (self::$phpFilesSupported) { $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory); if (null !== $logger) { $opcache->setLogger($logger); } return $opcache; } $fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory); if (null !== $logger) { $fs->setLogger($logger); } if (!self::$apcuSupported) { return $fs; } $apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version); if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) { $apcu->setLogger(new NullLogger()); } elseif (null !== $logger) { $apcu->setLogger($logger); } return new ChainAdapter(array($apcu, $fs)); } public static function createConnection($dsn, array $options = array()) { if (!is_string($dsn)) { throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, gettype($dsn))); } if (0 === strpos($dsn, 'redis://')) { return RedisAdapter::createConnection($dsn, $options); } if (0 === strpos($dsn, 'memcached://')) { return MemcachedAdapter::createConnection($dsn, $options); } throw new InvalidArgumentException(sprintf('Unsupported DSN: %s.', $dsn)); } /** * {@inheritdoc} */ public function getItem($key) { if ($this->deferred) { $this->commit(); } $id = $this->getId($key); $f = $this->createCacheItem; $isHit = false; $value = null; try { foreach ($this->doFetch(array($id)) as $value) { $isHit = true; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e)); } return $f($key, $value, $isHit); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { if ($this->deferred) { $this->commit(); } $ids = array(); foreach ($keys as $key) { $ids[] = $this->getId($key); } try { $items = $this->doFetch($ids); } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => $keys, 'exception' => $e)); $items = array(); } $ids = array_combine($ids, $keys); return $this->generateItems($items, $ids); } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { if (!$item instanceof CacheItem) { return false; } $this->deferred[$item->getKey()] = $item; return $this->commit(); } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { if (!$item instanceof CacheItem) { return false; } $this->deferred[$item->getKey()] = $item; return true; } /** * {@inheritdoc} */ public function commit() { $ok = true; $byLifetime = $this->mergeByLifetime; $byLifetime = $byLifetime($this->deferred, $this->namespace, $expiredIds); $retry = $this->deferred = array(); if ($expiredIds) { $this->doDelete($expiredIds); } foreach ($byLifetime as $lifetime => $values) { try { $e = $this->doSave($values, $lifetime); } catch (\Exception $e) { } if (true === $e || array() === $e) { continue; } if (is_array($e) || 1 === count($values)) { foreach (is_array($e) ? $e : array_keys($values) as $id) { $ok = false; $v = $values[$id]; $type = is_object($v) ? get_class($v) : gettype($v); CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null)); } } else { foreach ($values as $id => $v) { $retry[$lifetime][] = $id; } } } // When bulk-save failed, retry each item individually foreach ($retry as $lifetime => $ids) { foreach ($ids as $id) { try { $v = $byLifetime[$lifetime][$id]; $e = $this->doSave(array($id => $v), $lifetime); } catch (\Exception $e) { } if (true === $e || array() === $e) { continue; } $ok = false; $type = is_object($v) ? get_class($v) : gettype($v); CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null)); } } return $ok; } public function __destruct() { if ($this->deferred) { $this->commit(); } } private function generateItems($items, &$keys) { $f = $this->createCacheItem; try { foreach ($items as $id => $value) { if (!isset($keys[$id])) { $id = key($keys); } $key = $keys[$id]; unset($keys[$id]); yield $key => $f($key, $value, true); } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => array_values($keys), 'exception' => $e)); } foreach ($keys as $key) { yield $key => $f($key, null, false); } } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/AdapterInterface.php000066400000000000000000000014261324732107100257250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; /** * Interface for adapters managing instances of Symfony's CacheItem. * * @author Kévin Dunglas */ interface AdapterInterface extends CacheItemPoolInterface { /** * {@inheritdoc} * * @return CacheItem */ public function getItem($key); /** * {@inheritdoc} * * @return \Traversable|CacheItem[] */ public function getItems(array $keys = array()); } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php000066400000000000000000000013531324732107100247140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Traits\ApcuTrait; class ApcuAdapter extends AbstractAdapter { use ApcuTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $version * * @throws CacheException if APCu is not enabled */ public function __construct($namespace = '', $defaultLifetime = 0, $version = null) { $this->init($namespace, $defaultLifetime, $version); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php000066400000000000000000000101611324732107100250770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerAwareInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ArrayTrait; /** * @author Nicolas Grekas */ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, ResettableInterface { use ArrayTrait; private $createCacheItem; /** * @param int $defaultLifetime * @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise */ public function __construct($defaultLifetime = 0, $storeSerialized = true) { $this->storeSerialized = $storeSerialized; $this->createCacheItem = \Closure::bind( function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $value; $item->isHit = $isHit; $item->defaultLifetime = $defaultLifetime; return $item; }, null, CacheItem::class ); } /** * {@inheritdoc} */ public function getItem($key) { $isHit = $this->hasItem($key); try { if (!$isHit) { $this->values[$key] = $value = null; } elseif (!$this->storeSerialized) { $value = $this->values[$key]; } elseif ('b:0;' === $value = $this->values[$key]) { $value = false; } elseif (false === $value = unserialize($value)) { $this->values[$key] = $value = null; $isHit = false; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e)); $this->values[$key] = $value = null; $isHit = false; } $f = $this->createCacheItem; return $f($key, $value, $isHit); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { foreach ($keys as $key) { CacheItem::validateKey($key); } return $this->generateItems($keys, time(), $this->createCacheItem); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { foreach ($keys as $key) { $this->deleteItem($key); } return true; } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { if (!$item instanceof CacheItem) { return false; } $item = (array) $item; $key = $item["\0*\0key"]; $value = $item["\0*\0value"]; $expiry = $item["\0*\0expiry"]; if (null !== $expiry && $expiry <= time()) { $this->deleteItem($key); return true; } if ($this->storeSerialized) { try { $value = serialize($value); } catch (\Exception $e) { $type = is_object($value) ? get_class($value) : gettype($value); CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e)); return false; } } if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) { $expiry = time() + $item["\0*\0defaultLifetime"]; } $this->values[$key] = $value; $this->expiries[$key] = null !== $expiry ? $expiry : PHP_INT_MAX; return true; } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { return $this->save($item); } /** * {@inheritdoc} */ public function commit() { return true; } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/ChainAdapter.php000066400000000000000000000145401324732107100250500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * Chains several adapters together. * * Cached items are fetched from the first adapter having them in its data store. * They are saved and deleted in all adapters at once. * * @author Kévin Dunglas */ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { private $adapters = array(); private $adapterCount; private $saveUp; /** * @param CacheItemPoolInterface[] $adapters The ordered list of adapters used to fetch cached items * @param int $maxLifetime The max lifetime of items propagated from lower adapters to upper ones */ public function __construct(array $adapters, $maxLifetime = 0) { if (!$adapters) { throw new InvalidArgumentException('At least one adapter must be specified.'); } foreach ($adapters as $adapter) { if (!$adapter instanceof CacheItemPoolInterface) { throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_class($adapter), CacheItemPoolInterface::class)); } if ($adapter instanceof AdapterInterface) { $this->adapters[] = $adapter; } else { $this->adapters[] = new ProxyAdapter($adapter); } } $this->adapterCount = count($this->adapters); $this->saveUp = \Closure::bind( function ($adapter, $item) use ($maxLifetime) { $origDefaultLifetime = $item->defaultLifetime; if (0 < $maxLifetime && ($origDefaultLifetime <= 0 || $maxLifetime < $origDefaultLifetime)) { $item->defaultLifetime = $maxLifetime; } $adapter->save($item); $item->defaultLifetime = $origDefaultLifetime; }, null, CacheItem::class ); } /** * {@inheritdoc} */ public function getItem($key) { $saveUp = $this->saveUp; foreach ($this->adapters as $i => $adapter) { $item = $adapter->getItem($key); if ($item->isHit()) { while (0 <= --$i) { $saveUp($this->adapters[$i], $item); } return $item; } } return $item; } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { return $this->generateItems($this->adapters[0]->getItems($keys), 0); } private function generateItems($items, $adapterIndex) { $missing = array(); $nextAdapterIndex = $adapterIndex + 1; $nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null; foreach ($items as $k => $item) { if (!$nextAdapter || $item->isHit()) { yield $k => $item; } else { $missing[] = $k; } } if ($missing) { $saveUp = $this->saveUp; $adapter = $this->adapters[$adapterIndex]; $items = $this->generateItems($nextAdapter->getItems($missing), $nextAdapterIndex); foreach ($items as $k => $item) { if ($item->isHit()) { $saveUp($adapter, $item); } yield $k => $item; } } } /** * {@inheritdoc} */ public function hasItem($key) { foreach ($this->adapters as $adapter) { if ($adapter->hasItem($key)) { return true; } } return false; } /** * {@inheritdoc} */ public function clear() { $cleared = true; $i = $this->adapterCount; while ($i--) { $cleared = $this->adapters[$i]->clear() && $cleared; } return $cleared; } /** * {@inheritdoc} */ public function deleteItem($key) { $deleted = true; $i = $this->adapterCount; while ($i--) { $deleted = $this->adapters[$i]->deleteItem($key) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function deleteItems(array $keys) { $deleted = true; $i = $this->adapterCount; while ($i--) { $deleted = $this->adapters[$i]->deleteItems($keys) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { $saved = true; $i = $this->adapterCount; while ($i--) { $saved = $this->adapters[$i]->save($item) && $saved; } return $saved; } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { $saved = true; $i = $this->adapterCount; while ($i--) { $saved = $this->adapters[$i]->saveDeferred($item) && $saved; } return $saved; } /** * {@inheritdoc} */ public function commit() { $committed = true; $i = $this->adapterCount; while ($i--) { $committed = $this->adapters[$i]->commit() && $committed; } return $committed; } /** * {@inheritdoc} */ public function prune() { $pruned = true; foreach ($this->adapters as $adapter) { if ($adapter instanceof PruneableInterface) { $pruned = $adapter->prune() && $pruned; } } return $pruned; } /** * {@inheritdoc} */ public function reset() { foreach ($this->adapters as $adapter) { if ($adapter instanceof ResettableInterface) { $adapter->reset(); } } } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php000066400000000000000000000014731324732107100255760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Doctrine\Common\Cache\CacheProvider; use Symfony\Component\Cache\Traits\DoctrineTrait; class DoctrineAdapter extends AbstractAdapter { use DoctrineTrait; /** * @param CacheProvider $provider * @param string $namespace * @param int $defaultLifetime */ public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0) { parent::__construct('', $defaultLifetime); $this->provider = $provider; $provider->setNamespace($namespace); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php000066400000000000000000000014661324732107100261550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\FilesystemTrait; class FilesystemAdapter extends AbstractAdapter implements PruneableInterface { use FilesystemTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $directory */ public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) { parent::__construct('', $defaultLifetime); $this->init($namespace, $directory); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php000066400000000000000000000022311324732107100256660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Traits\MemcachedTrait; class MemcachedAdapter extends AbstractAdapter { use MemcachedTrait; protected $maxIdLength = 250; /** * Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged. * Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that: * - the Memcached::OPT_BINARY_PROTOCOL must be enabled * (that's the default when using MemcachedAdapter::createConnection()); * - tags eviction by Memcached's LRU algorithm will break by-tags invalidation; * your Memcached memory should be large enough to never trigger LRU. * * Using a MemcachedAdapter as a pure items store is fine. */ public function __construct(\Memcached $client, $namespace = '', $defaultLifetime = 0) { $this->init($client, $namespace, $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/NullAdapter.php000066400000000000000000000040631324732107100247370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\CacheItem; /** * @author Titouan Galopin */ class NullAdapter implements AdapterInterface { private $createCacheItem; public function __construct() { $this->createCacheItem = \Closure::bind( function ($key) { $item = new CacheItem(); $item->key = $key; $item->isHit = false; return $item; }, $this, CacheItem::class ); } /** * {@inheritdoc} */ public function getItem($key) { $f = $this->createCacheItem; return $f($key); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { return $this->generateItems($keys); } /** * {@inheritdoc} */ public function hasItem($key) { return false; } /** * {@inheritdoc} */ public function clear() { return true; } /** * {@inheritdoc} */ public function deleteItem($key) { return true; } /** * {@inheritdoc} */ public function deleteItems(array $keys) { return true; } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { return false; } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { return false; } /** * {@inheritdoc} */ public function commit() { return false; } private function generateItems(array $keys) { $f = $this->createCacheItem; foreach ($keys as $key) { yield $key => $f($key); } } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/PdoAdapter.php000066400000000000000000000042551324732107100245520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Doctrine\DBAL\Connection; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\PdoTrait; class PdoAdapter extends AbstractAdapter implements PruneableInterface { use PdoTrait; protected $maxIdLength = 255; /** * You can either pass an existing database connection as PDO instance or * a Doctrine DBAL Connection or a DSN string that will be used to * lazy-connect to the database when the cache is actually used. * * List of available options: * * db_table: The name of the table [default: cache_items] * * db_id_col: The column where to store the cache id [default: item_id] * * db_data_col: The column where to store the cache data [default: item_data] * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime] * * db_time_col: The column where to store the timestamp [default: item_time] * * db_username: The username when lazy-connect [default: ''] * * db_password: The password when lazy-connect [default: ''] * * db_connection_options: An array of driver-specific connection options [default: array()] * * @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null * @param string $namespace * @param int $defaultLifetime * @param array $options An associative array of options * * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION * @throws InvalidArgumentException When namespace contains invalid characters */ public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = array()) { $this->init($connOrDsn, $namespace, $defaultLifetime, $options); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php000066400000000000000000000215131324732107100255520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\PhpArrayTrait; /** * Caches items at warm up time using a PHP array that is stored in shared memory by OPCache since PHP 7.0. * Warmed up items are read-only and run-time discovered items are cached using a fallback adapter. * * @author Titouan Galopin * @author Nicolas Grekas */ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { use PhpArrayTrait; private $createCacheItem; /** * @param string $file The PHP file were values are cached * @param AdapterInterface $fallbackPool A pool to fallback on when an item is not hit */ public function __construct($file, AdapterInterface $fallbackPool) { $this->file = $file; $this->pool = $fallbackPool; $this->zendDetectUnicode = ini_get('zend.detect_unicode'); $this->createCacheItem = \Closure::bind( function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $value; $item->isHit = $isHit; return $item; }, null, CacheItem::class ); } /** * This adapter should only be used on PHP 7.0+ to take advantage of how PHP * stores arrays in its latest versions. This factory method decorates the given * fallback pool with this adapter only if the current PHP version is supported. * * @param string $file The PHP file were values are cached * @param CacheItemPoolInterface $fallbackPool Fallback for old PHP versions or opcache disabled * * @return CacheItemPoolInterface */ public static function create($file, CacheItemPoolInterface $fallbackPool) { // Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) { if (!$fallbackPool instanceof AdapterInterface) { $fallbackPool = new ProxyAdapter($fallbackPool); } return new static($file, $fallbackPool); } return $fallbackPool; } /** * {@inheritdoc} */ public function getItem($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } if (!isset($this->values[$key])) { return $this->pool->getItem($key); } $value = $this->values[$key]; $isHit = true; if ('N;' === $value) { $value = null; } elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) { try { $e = null; $value = unserialize($value); } catch (\Error $e) { } catch (\Exception $e) { } if (null !== $e) { $value = null; $isHit = false; } } $f = $this->createCacheItem; return $f($key, $value, $isHit); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { foreach ($keys as $key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } } if (null === $this->values) { $this->initialize(); } return $this->generateItems($keys); } /** * {@inheritdoc} */ public function hasItem($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } return isset($this->values[$key]) || $this->pool->hasItem($key); } /** * {@inheritdoc} */ public function deleteItem($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } return !isset($this->values[$key]) && $this->pool->deleteItem($key); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { $deleted = true; $fallbackKeys = array(); foreach ($keys as $key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (isset($this->values[$key])) { $deleted = false; } else { $fallbackKeys[] = $key; } } if (null === $this->values) { $this->initialize(); } if ($fallbackKeys) { $deleted = $this->pool->deleteItems($fallbackKeys) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { if (null === $this->values) { $this->initialize(); } return !isset($this->values[$item->getKey()]) && $this->pool->save($item); } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { if (null === $this->values) { $this->initialize(); } return !isset($this->values[$item->getKey()]) && $this->pool->saveDeferred($item); } /** * {@inheritdoc} */ public function commit() { return $this->pool->commit(); } /** * @return \Generator */ private function generateItems(array $keys) { $f = $this->createCacheItem; $fallbackKeys = array(); foreach ($keys as $key) { if (isset($this->values[$key])) { $value = $this->values[$key]; if ('N;' === $value) { yield $key => $f($key, null, true); } elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) { try { yield $key => $f($key, unserialize($value), true); } catch (\Error $e) { yield $key => $f($key, null, false); } catch (\Exception $e) { yield $key => $f($key, null, false); } } else { yield $key => $f($key, $value, true); } } else { $fallbackKeys[] = $key; } } if ($fallbackKeys) { foreach ($this->pool->getItems($fallbackKeys) as $key => $item) { yield $key => $item; } } } /** * @throws \ReflectionException When $class is not found and is required * * @internal */ public static function throwOnRequiredClass($class) { $e = new \ReflectionException("Class $class does not exist"); $trace = $e->getTrace(); $autoloadFrame = array( 'function' => 'spl_autoload_call', 'args' => array($class), ); $i = 1 + array_search($autoloadFrame, $trace, true); if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) { switch ($trace[$i]['function']) { case 'get_class_methods': case 'get_class_vars': case 'get_parent_class': case 'is_a': case 'is_subclass_of': case 'class_exists': case 'class_implements': case 'class_parents': case 'trait_exists': case 'defined': case 'interface_exists': case 'method_exists': case 'property_exists': case 'is_callable': return; } } throw $e; } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php000066400000000000000000000022741324732107100255410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\PhpFilesTrait; class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface { use PhpFilesTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $directory * * @throws CacheException if OPcache is not enabled */ public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) { if (!static::isSupported()) { throw new CacheException('OPcache is not enabled'); } parent::__construct('', $defaultLifetime); $this->init($namespace, $directory); $e = new \Exception(); $this->includeHandler = function () use ($e) { throw $e; }; $this->zendDetectUnicode = ini_get('zend.detect_unicode'); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php000066400000000000000000000111411324732107100251410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ProxyTrait; /** * @author Nicolas Grekas */ class ProxyAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { use ProxyTrait; private $namespace; private $namespaceLen; private $createCacheItem; private $poolHash; /** * @param CacheItemPoolInterface $pool * @param string $namespace * @param int $defaultLifetime */ public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0) { $this->pool = $pool; $this->poolHash = $poolHash = spl_object_hash($pool); $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace); $this->namespaceLen = strlen($namespace); $this->createCacheItem = \Closure::bind( function ($key, $innerItem) use ($defaultLifetime, $poolHash) { $item = new CacheItem(); $item->key = $key; $item->value = $innerItem->get(); $item->isHit = $innerItem->isHit(); $item->defaultLifetime = $defaultLifetime; $item->innerItem = $innerItem; $item->poolHash = $poolHash; $innerItem->set(null); return $item; }, null, CacheItem::class ); } /** * {@inheritdoc} */ public function getItem($key) { $f = $this->createCacheItem; $item = $this->pool->getItem($this->getId($key)); return $f($key, $item); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { if ($this->namespaceLen) { foreach ($keys as $i => $key) { $keys[$i] = $this->getId($key); } } return $this->generateItems($this->pool->getItems($keys)); } /** * {@inheritdoc} */ public function hasItem($key) { return $this->pool->hasItem($this->getId($key)); } /** * {@inheritdoc} */ public function clear() { return $this->pool->clear(); } /** * {@inheritdoc} */ public function deleteItem($key) { return $this->pool->deleteItem($this->getId($key)); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { if ($this->namespaceLen) { foreach ($keys as $i => $key) { $keys[$i] = $this->getId($key); } } return $this->pool->deleteItems($keys); } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { return $this->doSave($item, __FUNCTION__); } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { return $this->doSave($item, __FUNCTION__); } /** * {@inheritdoc} */ public function commit() { return $this->pool->commit(); } private function doSave(CacheItemInterface $item, $method) { if (!$item instanceof CacheItem) { return false; } $item = (array) $item; $expiry = $item["\0*\0expiry"]; if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) { $expiry = time() + $item["\0*\0defaultLifetime"]; } $innerItem = $item["\0*\0poolHash"] === $this->poolHash ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]); $innerItem->set($item["\0*\0value"]); $innerItem->expiresAt(null !== $expiry ? \DateTime::createFromFormat('U', $expiry) : null); return $this->pool->$method($innerItem); } private function generateItems($items) { $f = $this->createCacheItem; foreach ($items as $key => $item) { if ($this->namespaceLen) { $key = substr($key, $this->namespaceLen); } yield $key => $f($key, $item); } } private function getId($key) { CacheItem::validateKey($key); return $this->namespace.$key; } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/RedisAdapter.php000066400000000000000000000015511324732107100250720ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Traits\RedisTrait; class RedisAdapter extends AbstractAdapter { use RedisTrait; /** * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client * @param string $namespace The default namespace * @param int $defaultLifetime The default lifetime */ public function __construct($redisClient, $namespace = '', $defaultLifetime = 0) { $this->init($redisClient, $namespace, $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php000066400000000000000000000033371324732107100262050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ProxyTrait; /** * @author Nicolas Grekas */ class SimpleCacheAdapter extends AbstractAdapter implements PruneableInterface, ResettableInterface { use ProxyTrait; private $miss; public function __construct(CacheInterface $pool, $namespace = '', $defaultLifetime = 0) { parent::__construct($namespace, $defaultLifetime); $this->pool = $pool; $this->miss = new \stdClass(); } /** * {@inheritdoc} */ protected function doFetch(array $ids) { foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) { if ($this->miss !== $value) { yield $key => $value; } } } /** * {@inheritdoc} */ protected function doHave($id) { return $this->pool->has($id); } /** * {@inheritdoc} */ protected function doClear($namespace) { return $this->pool->clear(); } /** * {@inheritdoc} */ protected function doDelete(array $ids) { return $this->pool->deleteMultiple($ids); } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php000066400000000000000000000213061324732107100255170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Cache\InvalidArgumentException; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ProxyTrait; /** * @author Nicolas Grekas */ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, ResettableInterface { const TAGS_PREFIX = "\0tags\0"; use ProxyTrait; private $deferred = array(); private $createCacheItem; private $setCacheItemTags; private $getTagsByKey; private $invalidateTags; private $tags; public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsPool = null) { $this->pool = $itemsPool; $this->tags = $tagsPool ?: $itemsPool; $this->createCacheItem = \Closure::bind( function ($key, $value, CacheItem $protoItem) { $item = new CacheItem(); $item->key = $key; $item->value = $value; $item->defaultLifetime = $protoItem->defaultLifetime; $item->expiry = $protoItem->expiry; $item->innerItem = $protoItem->innerItem; $item->poolHash = $protoItem->poolHash; return $item; }, null, CacheItem::class ); $this->setCacheItemTags = \Closure::bind( function (CacheItem $item, $key, array &$itemTags) { if (!$item->isHit) { return $item; } if (isset($itemTags[$key])) { foreach ($itemTags[$key] as $tag => $version) { $item->prevTags[$tag] = $tag; } unset($itemTags[$key]); } else { $item->value = null; $item->isHit = false; } return $item; }, null, CacheItem::class ); $this->getTagsByKey = \Closure::bind( function ($deferred) { $tagsByKey = array(); foreach ($deferred as $key => $item) { $tagsByKey[$key] = $item->tags; } return $tagsByKey; }, null, CacheItem::class ); $this->invalidateTags = \Closure::bind( function (AdapterInterface $tagsAdapter, array $tags) { foreach ($tagsAdapter->getItems($tags) as $v) { $v->set(1 + (int) $v->get()); $v->defaultLifetime = 0; $v->expiry = null; $tagsAdapter->saveDeferred($v); } return $tagsAdapter->commit(); }, null, CacheItem::class ); } /** * {@inheritdoc} */ public function invalidateTags(array $tags) { foreach ($tags as $k => $tag) { if ('' !== $tag && is_string($tag)) { $tags[$k] = $tag.static::TAGS_PREFIX; } } $f = $this->invalidateTags; return $f($this->tags, $tags); } /** * {@inheritdoc} */ public function hasItem($key) { if ($this->deferred) { $this->commit(); } if (!$this->pool->hasItem($key)) { return false; } if (!$itemTags = $this->pool->getItem(static::TAGS_PREFIX.$key)->get()) { return true; } foreach ($this->getTagVersions(array($itemTags)) as $tag => $version) { if ($itemTags[$tag] !== $version) { return false; } } return true; } /** * {@inheritdoc} */ public function getItem($key) { foreach ($this->getItems(array($key)) as $item) { return $item; } } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { if ($this->deferred) { $this->commit(); } $tagKeys = array(); foreach ($keys as $key) { if ('' !== $key && is_string($key)) { $key = static::TAGS_PREFIX.$key; $tagKeys[$key] = $key; } } try { $items = $this->pool->getItems($tagKeys + $keys); } catch (InvalidArgumentException $e) { $this->pool->getItems($keys); // Should throw an exception throw $e; } return $this->generateItems($items, $tagKeys); } /** * {@inheritdoc} */ public function clear() { $this->deferred = array(); return $this->pool->clear(); } /** * {@inheritdoc} */ public function deleteItem($key) { return $this->deleteItems(array($key)); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { foreach ($keys as $key) { if ('' !== $key && is_string($key)) { $keys[] = static::TAGS_PREFIX.$key; } } return $this->pool->deleteItems($keys); } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { if (!$item instanceof CacheItem) { return false; } $this->deferred[$item->getKey()] = $item; return $this->commit(); } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { if (!$item instanceof CacheItem) { return false; } $this->deferred[$item->getKey()] = $item; return true; } /** * {@inheritdoc} */ public function commit() { $ok = true; if ($this->deferred) { $items = $this->deferred; foreach ($items as $key => $item) { if (!$this->pool->saveDeferred($item)) { unset($this->deferred[$key]); $ok = false; } } $f = $this->getTagsByKey; $tagsByKey = $f($items); $this->deferred = array(); $tagVersions = $this->getTagVersions($tagsByKey); $f = $this->createCacheItem; foreach ($tagsByKey as $key => $tags) { $this->pool->saveDeferred($f(static::TAGS_PREFIX.$key, array_intersect_key($tagVersions, $tags), $items[$key])); } } return $this->pool->commit() && $ok; } public function __destruct() { $this->commit(); } private function generateItems($items, array $tagKeys) { $bufferedItems = $itemTags = array(); $f = $this->setCacheItemTags; foreach ($items as $key => $item) { if (!$tagKeys) { yield $key => $f($item, static::TAGS_PREFIX.$key, $itemTags); continue; } if (!isset($tagKeys[$key])) { $bufferedItems[$key] = $item; continue; } unset($tagKeys[$key]); $itemTags[$key] = $item->get() ?: array(); if (!$tagKeys) { $tagVersions = $this->getTagVersions($itemTags); foreach ($itemTags as $key => $tags) { foreach ($tags as $tag => $version) { if ($tagVersions[$tag] !== $version) { unset($itemTags[$key]); continue 2; } } } $tagVersions = $tagKeys = null; foreach ($bufferedItems as $key => $item) { yield $key => $f($item, static::TAGS_PREFIX.$key, $itemTags); } $bufferedItems = null; } } } private function getTagVersions(array $tagsByKey) { $tagVersions = array(); foreach ($tagsByKey as $tags) { $tagVersions += $tags; } if ($tagVersions) { $tags = array(); foreach ($tagVersions as $tag => $version) { $tagVersions[$tag] = $tag.static::TAGS_PREFIX; $tags[$tag.static::TAGS_PREFIX] = $tag; } foreach ($this->tags->getItems($tagVersions) as $tag => $version) { $tagVersions[$tags[$tag]] = $version->get() ?: 0; } } return $tagVersions; } } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/TagAwareAdapterInterface.php000066400000000000000000000014211324732107100273340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\InvalidArgumentException; /** * Interface for invalidating cached items using tags. * * @author Nicolas Grekas */ interface TagAwareAdapterInterface extends AdapterInterface { /** * Invalidates cached items using tags. * * @param string[] $tags An array of tags to invalidate * * @return bool True on success * * @throws InvalidArgumentException When $tags is not valid */ public function invalidateTags(array $tags); } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php000066400000000000000000000122411324732107100257040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * An adapter that collects data about all cache calls. * * @author Aaron Scherer * @author Tobias Nyholm * @author Nicolas Grekas */ class TraceableAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { protected $pool; private $calls = array(); public function __construct(AdapterInterface $pool) { $this->pool = $pool; } /** * {@inheritdoc} */ public function getItem($key) { $event = $this->start(__FUNCTION__); try { $item = $this->pool->getItem($key); } finally { $event->end = microtime(true); } if ($event->result[$key] = $item->isHit()) { ++$event->hits; } else { ++$event->misses; } return $item; } /** * {@inheritdoc} */ public function hasItem($key) { $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->hasItem($key); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function deleteItem($key) { $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->deleteItem($key); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { $event = $this->start(__FUNCTION__); try { return $event->result[$item->getKey()] = $this->pool->save($item); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { $event = $this->start(__FUNCTION__); try { return $event->result[$item->getKey()] = $this->pool->saveDeferred($item); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { $event = $this->start(__FUNCTION__); try { $result = $this->pool->getItems($keys); } finally { $event->end = microtime(true); } $f = function () use ($result, $event) { $event->result = array(); foreach ($result as $key => $item) { if ($event->result[$key] = $item->isHit()) { ++$event->hits; } else { ++$event->misses; } yield $key => $item; } }; return $f(); } /** * {@inheritdoc} */ public function clear() { $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->clear(); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function deleteItems(array $keys) { $event = $this->start(__FUNCTION__); $event->result['keys'] = $keys; try { return $event->result['result'] = $this->pool->deleteItems($keys); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function commit() { $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->commit(); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function prune() { if (!$this->pool instanceof PruneableInterface) { return false; } $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->prune(); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function reset() { if (!$this->pool instanceof ResettableInterface) { return; } $event = $this->start(__FUNCTION__); try { $this->pool->reset(); } finally { $event->end = microtime(true); } } public function getCalls() { return $this->calls; } public function clearCalls() { $this->calls = array(); } protected function start($name) { $this->calls[] = $event = new TraceableAdapterEvent(); $event->name = $name; $event->start = microtime(true); return $event; } } class TraceableAdapterEvent { public $name; public $start; public $end; public $result; public $hits = 0; public $misses = 0; } symfony-3.4.6/src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php000066400000000000000000000015211324732107100273170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; /** * @author Robin Chalas */ class TraceableTagAwareAdapter extends TraceableAdapter implements TagAwareAdapterInterface { public function __construct(TagAwareAdapterInterface $pool) { parent::__construct($pool); } /** * {@inheritdoc} */ public function invalidateTags(array $tags) { $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->invalidateTags($tags); } finally { $event->end = microtime(true); } } } symfony-3.4.6/src/Symfony/Component/Cache/CHANGELOG.md000066400000000000000000000026621324732107100222470ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added using options from Memcached DSN * added PruneableInterface so PSR-6 or PSR-16 cache implementations can declare support for manual stale cache pruning * added prune logic to FilesystemTrait, PhpFilesTrait, PdoTrait, TagAwareAdapter and ChainTrait * now FilesystemAdapter, PhpFilesAdapter, FilesystemCache, PhpFilesCache, PdoAdapter, PdoCache, ChainAdapter, and ChainCache implement PruneableInterface and support manual stale cache pruning 3.3.0 ----- * [EXPERIMENTAL] added CacheItem::getPreviousTags() to get bound tags coming from the pool storage if any * added PSR-16 "Simple Cache" implementations for all existing PSR-6 adapters * added Psr6Cache and SimpleCacheAdapter for bidirectional interoperability between PSR-6 and PSR-16 * added MemcachedAdapter (PSR-6) and MemcachedCache (PSR-16) * added TraceableAdapter (PSR-6) and TraceableCache (PSR-16) 3.2.0 ----- * added TagAwareAdapter for tags-based invalidation * added PdoAdapter with PDO and Doctrine DBAL support * added PhpArrayAdapter and PhpFilesAdapter for OPcache-backed shared memory storage (PHP 7+ only) * added NullAdapter 3.1.0 ----- * added the component with strict PSR-6 implementations * added ApcuAdapter, ArrayAdapter, FilesystemAdapter and RedisAdapter * added AbstractAdapter, ChainAdapter and ProxyAdapter * added DoctrineAdapter and DoctrineProvider for bidirectional interoperability with Doctrine Cache symfony-3.4.6/src/Symfony/Component/Cache/CacheItem.php000066400000000000000000000117761324732107100227770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache; use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Nicolas Grekas */ final class CacheItem implements CacheItemInterface { protected $key; protected $value; protected $isHit = false; protected $expiry; protected $defaultLifetime; protected $tags = array(); protected $prevTags = array(); protected $innerItem; protected $poolHash; /** * {@inheritdoc} */ public function getKey() { return $this->key; } /** * {@inheritdoc} */ public function get() { return $this->value; } /** * {@inheritdoc} */ public function isHit() { return $this->isHit; } /** * {@inheritdoc} */ public function set($value) { $this->value = $value; return $this; } /** * {@inheritdoc} */ public function expiresAt($expiration) { if (null === $expiration) { $this->expiry = $this->defaultLifetime > 0 ? time() + $this->defaultLifetime : null; } elseif ($expiration instanceof \DateTimeInterface) { $this->expiry = (int) $expiration->format('U'); } else { throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', is_object($expiration) ? get_class($expiration) : gettype($expiration))); } return $this; } /** * {@inheritdoc} */ public function expiresAfter($time) { if (null === $time) { $this->expiry = $this->defaultLifetime > 0 ? time() + $this->defaultLifetime : null; } elseif ($time instanceof \DateInterval) { $this->expiry = (int) \DateTime::createFromFormat('U', time())->add($time)->format('U'); } elseif (is_int($time)) { $this->expiry = $time + time(); } else { throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($time) ? get_class($time) : gettype($time))); } return $this; } /** * Adds a tag to a cache item. * * @param string|string[] $tags A tag or array of tags * * @return static * * @throws InvalidArgumentException When $tag is not valid */ public function tag($tags) { if (!is_array($tags)) { $tags = array($tags); } foreach ($tags as $tag) { if (!is_string($tag)) { throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given', is_object($tag) ? get_class($tag) : gettype($tag))); } if (isset($this->tags[$tag])) { continue; } if (!isset($tag[0])) { throw new InvalidArgumentException('Cache tag length must be greater than zero'); } if (false !== strpbrk($tag, '{}()/\@:')) { throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters {}()/\@:', $tag)); } $this->tags[$tag] = $tag; } return $this; } /** * Returns the list of tags bound to the value coming from the pool storage if any. * * @return array */ public function getPreviousTags() { return $this->prevTags; } /** * Validates a cache key according to PSR-6. * * @param string $key The key to validate * * @return string * * @throws InvalidArgumentException When $key is not valid */ public static function validateKey($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', is_object($key) ? get_class($key) : gettype($key))); } if (!isset($key[0])) { throw new InvalidArgumentException('Cache key length must be greater than zero'); } if (false !== strpbrk($key, '{}()/\@:')) { throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key)); } return $key; } /** * Internal logging helper. * * @internal */ public static function log(LoggerInterface $logger = null, $message, $context = array()) { if ($logger) { $logger->warning($message, $context); } else { $replace = array(); foreach ($context as $k => $v) { if (is_scalar($v)) { $replace['{'.$k.'}'] = $v; } } @trigger_error(strtr($message, $replace), E_USER_WARNING); } } } symfony-3.4.6/src/Symfony/Component/Cache/DataCollector/000077500000000000000000000000001324732107100231505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php000066400000000000000000000130631324732107100273300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\DataCollector; use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapterEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; /** * @author Aaron Scherer * @author Tobias Nyholm */ class CacheDataCollector extends DataCollector implements LateDataCollectorInterface { /** * @var TraceableAdapter[] */ private $instances = array(); /** * @param string $name * @param TraceableAdapter $instance */ public function addInstance($name, TraceableAdapter $instance) { $this->instances[$name] = $instance; } /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { $empty = array('calls' => array(), 'config' => array(), 'options' => array(), 'statistics' => array()); $this->data = array('instances' => $empty, 'total' => $empty); foreach ($this->instances as $name => $instance) { $this->data['instances']['calls'][$name] = $instance->getCalls(); } $this->data['instances']['statistics'] = $this->calculateStatistics(); $this->data['total']['statistics'] = $this->calculateTotalStatistics(); } public function reset() { $this->data = array(); foreach ($this->instances as $instance) { $instance->clearCalls(); } } public function lateCollect() { $this->data = $this->cloneVar($this->data); } /** * {@inheritdoc} */ public function getName() { return 'cache'; } /** * Method returns amount of logged Cache reads: "get" calls. * * @return array */ public function getStatistics() { return $this->data['instances']['statistics']; } /** * Method returns the statistic totals. * * @return array */ public function getTotals() { return $this->data['total']['statistics']; } /** * Method returns all logged Cache call objects. * * @return mixed */ public function getCalls() { return $this->data['instances']['calls']; } /** * @return array */ private function calculateStatistics() { $statistics = array(); foreach ($this->data['instances']['calls'] as $name => $calls) { $statistics[$name] = array( 'calls' => 0, 'time' => 0, 'reads' => 0, 'writes' => 0, 'deletes' => 0, 'hits' => 0, 'misses' => 0, ); /** @var TraceableAdapterEvent $call */ foreach ($calls as $call) { $statistics[$name]['calls'] += 1; $statistics[$name]['time'] += $call->end - $call->start; if ('getItem' === $call->name) { $statistics[$name]['reads'] += 1; if ($call->hits) { $statistics[$name]['hits'] += 1; } else { $statistics[$name]['misses'] += 1; } } elseif ('getItems' === $call->name) { $count = $call->hits + $call->misses; $statistics[$name]['reads'] += $count; $statistics[$name]['hits'] += $call->hits; $statistics[$name]['misses'] += $count - $call->misses; } elseif ('hasItem' === $call->name) { $statistics[$name]['reads'] += 1; if (false === $call->result) { $statistics[$name]['misses'] += 1; } else { $statistics[$name]['hits'] += 1; } } elseif ('save' === $call->name) { $statistics[$name]['writes'] += 1; } elseif ('deleteItem' === $call->name) { $statistics[$name]['deletes'] += 1; } } if ($statistics[$name]['reads']) { $statistics[$name]['hit_read_ratio'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2); } else { $statistics[$name]['hit_read_ratio'] = null; } } return $statistics; } /** * @return array */ private function calculateTotalStatistics() { $statistics = $this->getStatistics(); $totals = array( 'calls' => 0, 'time' => 0, 'reads' => 0, 'writes' => 0, 'deletes' => 0, 'hits' => 0, 'misses' => 0, ); foreach ($statistics as $name => $values) { foreach ($totals as $key => $value) { $totals[$key] += $statistics[$name][$key]; } } if ($totals['reads']) { $totals['hit_read_ratio'] = round(100 * $totals['hits'] / $totals['reads'], 2); } else { $totals['hit_read_ratio'] = null; } return $totals; } } symfony-3.4.6/src/Symfony/Component/Cache/DoctrineProvider.php000066400000000000000000000037311324732107100244270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache; use Doctrine\Common\Cache\CacheProvider; use Psr\Cache\CacheItemPoolInterface; /** * @author Nicolas Grekas */ class DoctrineProvider extends CacheProvider implements PruneableInterface, ResettableInterface { private $pool; public function __construct(CacheItemPoolInterface $pool) { $this->pool = $pool; } /** * {@inheritdoc} */ public function prune() { return $this->pool instanceof PruneableInterface && $this->pool->prune(); } /** * {@inheritdoc} */ public function reset() { if ($this->pool instanceof ResettableInterface) { $this->pool->reset(); } $this->setNamespace($this->getNamespace()); } /** * {@inheritdoc} */ protected function doFetch($id) { $item = $this->pool->getItem(rawurlencode($id)); return $item->isHit() ? $item->get() : false; } /** * {@inheritdoc} */ protected function doContains($id) { return $this->pool->hasItem(rawurlencode($id)); } /** * {@inheritdoc} */ protected function doSave($id, $data, $lifeTime = 0) { $item = $this->pool->getItem(rawurlencode($id)); if (0 < $lifeTime) { $item->expiresAfter($lifeTime); } return $this->pool->save($item->set($data)); } /** * {@inheritdoc} */ protected function doDelete($id) { return $this->pool->deleteItem(rawurlencode($id)); } /** * {@inheritdoc} */ protected function doFlush() { $this->pool->clear(); } /** * {@inheritdoc} */ protected function doGetStats() { } } symfony-3.4.6/src/Symfony/Component/Cache/Exception/000077500000000000000000000000001324732107100223665ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Exception/CacheException.php000066400000000000000000000007551324732107100257700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Exception; use Psr\Cache\CacheException as Psr6CacheInterface; use Psr\SimpleCache\CacheException as SimpleCacheInterface; class CacheException extends \Exception implements Psr6CacheInterface, SimpleCacheInterface { } symfony-3.4.6/src/Symfony/Component/Cache/Exception/InvalidArgumentException.php000066400000000000000000000010321324732107100300430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Exception; use Psr\Cache\InvalidArgumentException as Psr6CacheInterface; use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInterface; class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface, SimpleCacheInterface { } symfony-3.4.6/src/Symfony/Component/Cache/LICENSE000066400000000000000000000020511324732107100214330ustar00rootroot00000000000000Copyright (c) 2016-2018 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. symfony-3.4.6/src/Symfony/Component/Cache/PruneableInterface.php000066400000000000000000000007451324732107100247050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache; /** * Interface extends psr-6 and psr-16 caches to allow for pruning (deletion) of all expired cache items. */ interface PruneableInterface { /** * @return bool */ public function prune(); } symfony-3.4.6/src/Symfony/Component/Cache/README.md000066400000000000000000000016321324732107100217110ustar00rootroot00000000000000Symfony PSR-6 implementation for caching ======================================== This component provides an extended [PSR-6](http://www.php-fig.org/psr/psr-6/) implementation for adding cache to your applications. It is designed to have a low overhead so that caching is fastest. It ships with a few caching adapters for the most widespread and suited to caching backends. It also provides a `doctrine/cache` proxy adapter to cover more advanced caching needs and a proxy adapter for greater interoperability between PSR-6 implementations. Resources --------- * [Documentation](https://symfony.com/doc/current/components/cache.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Component/Cache/ResettableInterface.php000066400000000000000000000005711324732107100250570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache; /** * Resets a pool's local state. */ interface ResettableInterface { public function reset(); } symfony-3.4.6/src/Symfony/Component/Cache/Simple/000077500000000000000000000000001324732107100216615ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Simple/AbstractCache.php000066400000000000000000000133301324732107100250610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\Log\LoggerAwareInterface; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\AbstractTrait; use Symfony\Component\Cache\ResettableInterface; /** * @author Nicolas Grekas */ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, ResettableInterface { use AbstractTrait { deleteItems as private; AbstractTrait::deleteItem as delete; AbstractTrait::hasItem as has; } private $defaultLifetime; /** * @param string $namespace * @param int $defaultLifetime */ protected function __construct($namespace = '', $defaultLifetime = 0) { $this->defaultLifetime = max(0, (int) $defaultLifetime); $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace)); } } /** * {@inheritdoc} */ public function get($key, $default = null) { $id = $this->getId($key); try { foreach ($this->doFetch(array($id)) as $value) { return $value; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e)); } return $default; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { CacheItem::validateKey($key); return $this->setMultiple(array($key => $value), $ttl); } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } $ids = array(); foreach ($keys as $key) { $ids[] = $this->getId($key); } try { $values = $this->doFetch($ids); } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch requested values', array('keys' => $keys, 'exception' => $e)); $values = array(); } $ids = array_combine($ids, $keys); return $this->generateValues($values, $ids, $default); } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { if (!is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values))); } $valuesById = array(); foreach ($values as $key => $value) { if (is_int($key)) { $key = (string) $key; } $valuesById[$this->getId($key)] = $value; } if (false === $ttl = $this->normalizeTtl($ttl)) { return $this->doDelete(array_keys($valuesById)); } try { $e = $this->doSave($valuesById, $ttl); } catch (\Exception $e) { } if (true === $e || array() === $e) { return true; } $keys = array(); foreach (is_array($e) ? $e : array_keys($valuesById) as $id) { $keys[] = substr($id, strlen($this->namespace)); } CacheItem::log($this->logger, 'Failed to save values', array('keys' => $keys, 'exception' => $e instanceof \Exception ? $e : null)); return false; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } return $this->deleteItems($keys); } private function normalizeTtl($ttl) { if (null === $ttl) { return $this->defaultLifetime; } if ($ttl instanceof \DateInterval) { $ttl = (int) \DateTime::createFromFormat('U', 0)->add($ttl)->format('U'); } if (is_int($ttl)) { return 0 < $ttl ? $ttl : false; } throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($ttl) ? get_class($ttl) : gettype($ttl))); } private function generateValues($values, &$keys, $default) { try { foreach ($values as $id => $value) { if (!isset($keys[$id])) { $id = key($keys); } $key = $keys[$id]; unset($keys[$id]); yield $key => $value; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to fetch requested values', array('keys' => array_values($keys), 'exception' => $e)); } foreach ($keys as $key) { yield $key => $default; } } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/ApcuCache.php000066400000000000000000000012521324732107100242060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\Traits\ApcuTrait; class ApcuCache extends AbstractCache { use ApcuTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $version */ public function __construct($namespace = '', $defaultLifetime = 0, $version = null) { $this->init($namespace, $defaultLifetime, $version); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/ArrayCache.php000066400000000000000000000111011324732107100243660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\Log\LoggerAwareInterface; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ArrayTrait; /** * @author Nicolas Grekas */ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInterface { use ArrayTrait { ArrayTrait::deleteItem as delete; ArrayTrait::hasItem as has; } private $defaultLifetime; /** * @param int $defaultLifetime * @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise */ public function __construct($defaultLifetime = 0, $storeSerialized = true) { $this->defaultLifetime = (int) $defaultLifetime; $this->storeSerialized = $storeSerialized; } /** * {@inheritdoc} */ public function get($key, $default = null) { foreach ($this->getMultiple(array($key), $default) as $v) { return $v; } } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } foreach ($keys as $key) { CacheItem::validateKey($key); } return $this->generateItems($keys, time(), function ($k, $v, $hit) use ($default) { return $hit ? $v : $default; }); } /** * {@inheritdoc} */ public function deleteMultiple($keys) { if (!is_array($keys) && !$keys instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } foreach ($keys as $key) { $this->delete($key); } return true; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { CacheItem::validateKey($key); return $this->setMultiple(array($key => $value), $ttl); } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { if (!is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values))); } $valuesArray = array(); foreach ($values as $key => $value) { is_int($key) || CacheItem::validateKey($key); $valuesArray[$key] = $value; } if (false === $ttl = $this->normalizeTtl($ttl)) { return $this->deleteMultiple(array_keys($valuesArray)); } if ($this->storeSerialized) { foreach ($valuesArray as $key => $value) { try { $valuesArray[$key] = serialize($value); } catch (\Exception $e) { $type = is_object($value) ? get_class($value) : gettype($value); CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e)); return false; } } } $expiry = 0 < $ttl ? time() + $ttl : PHP_INT_MAX; foreach ($valuesArray as $key => $value) { $this->values[$key] = $value; $this->expiries[$key] = $expiry; } return true; } private function normalizeTtl($ttl) { if (null === $ttl) { return $this->defaultLifetime; } if ($ttl instanceof \DateInterval) { $ttl = (int) \DateTime::createFromFormat('U', 0)->add($ttl)->format('U'); } if (is_int($ttl)) { return 0 < $ttl ? $ttl : false; } throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($ttl) ? get_class($ttl) : gettype($ttl))); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/ChainCache.php000066400000000000000000000144561324732107100243520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * Chains several caches together. * * Cached items are fetched from the first cache having them in its data store. * They are saved and deleted in all caches at once. * * @author Nicolas Grekas */ class ChainCache implements CacheInterface, PruneableInterface, ResettableInterface { private $miss; private $caches = array(); private $defaultLifetime; private $cacheCount; /** * @param CacheInterface[] $caches The ordered list of caches used to fetch cached items * @param int $defaultLifetime The lifetime of items propagated from lower caches to upper ones */ public function __construct(array $caches, $defaultLifetime = 0) { if (!$caches) { throw new InvalidArgumentException('At least one cache must be specified.'); } foreach ($caches as $cache) { if (!$cache instanceof CacheInterface) { throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_class($cache), CacheInterface::class)); } } $this->miss = new \stdClass(); $this->caches = array_values($caches); $this->cacheCount = count($this->caches); $this->defaultLifetime = 0 < $defaultLifetime ? (int) $defaultLifetime : null; } /** * {@inheritdoc} */ public function get($key, $default = null) { $miss = null !== $default && is_object($default) ? $default : $this->miss; foreach ($this->caches as $i => $cache) { $value = $cache->get($key, $miss); if ($miss !== $value) { while (0 <= --$i) { $this->caches[$i]->set($key, $value, $this->defaultLifetime); } return $value; } } return $default; } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { $miss = null !== $default && is_object($default) ? $default : $this->miss; return $this->generateItems($this->caches[0]->getMultiple($keys, $miss), 0, $miss, $default); } private function generateItems($values, $cacheIndex, $miss, $default) { $missing = array(); $nextCacheIndex = $cacheIndex + 1; $nextCache = isset($this->caches[$nextCacheIndex]) ? $this->caches[$nextCacheIndex] : null; foreach ($values as $k => $value) { if ($miss !== $value) { yield $k => $value; } elseif (!$nextCache) { yield $k => $default; } else { $missing[] = $k; } } if ($missing) { $cache = $this->caches[$cacheIndex]; $values = $this->generateItems($nextCache->getMultiple($missing, $miss), $nextCacheIndex, $miss, $default); foreach ($values as $k => $value) { if ($miss !== $value) { $cache->set($k, $value, $this->defaultLifetime); yield $k => $value; } else { yield $k => $default; } } } } /** * {@inheritdoc} */ public function has($key) { foreach ($this->caches as $cache) { if ($cache->has($key)) { return true; } } return false; } /** * {@inheritdoc} */ public function clear() { $cleared = true; $i = $this->cacheCount; while ($i--) { $cleared = $this->caches[$i]->clear() && $cleared; } return $cleared; } /** * {@inheritdoc} */ public function delete($key) { $deleted = true; $i = $this->cacheCount; while ($i--) { $deleted = $this->caches[$i]->delete($key) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } $deleted = true; $i = $this->cacheCount; while ($i--) { $deleted = $this->caches[$i]->deleteMultiple($keys) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { $saved = true; $i = $this->cacheCount; while ($i--) { $saved = $this->caches[$i]->set($key, $value, $ttl) && $saved; } return $saved; } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { if ($values instanceof \Traversable) { $valuesIterator = $values; $values = function () use ($valuesIterator, &$values) { $generatedValues = array(); foreach ($valuesIterator as $key => $value) { yield $key => $value; $generatedValues[$key] = $value; } $values = $generatedValues; }; $values = $values(); } $saved = true; $i = $this->cacheCount; while ($i--) { $saved = $this->caches[$i]->setMultiple($values, $ttl) && $saved; } return $saved; } /** * {@inheritdoc} */ public function prune() { $pruned = true; foreach ($this->caches as $cache) { if ($cache instanceof PruneableInterface) { $pruned = $cache->prune() && $pruned; } } return $pruned; } /** * {@inheritdoc} */ public function reset() { foreach ($this->caches as $cache) { if ($cache instanceof ResettableInterface) { $cache->reset(); } } } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/DoctrineCache.php000066400000000000000000000014661324732107100250740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Doctrine\Common\Cache\CacheProvider; use Symfony\Component\Cache\Traits\DoctrineTrait; class DoctrineCache extends AbstractCache { use DoctrineTrait; /** * @param CacheProvider $provider * @param string $namespace * @param int $defaultLifetime */ public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0) { parent::__construct('', $defaultLifetime); $this->provider = $provider; $provider->setNamespace($namespace); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/FilesystemCache.php000066400000000000000000000014611324732107100254440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\FilesystemTrait; class FilesystemCache extends AbstractCache implements PruneableInterface { use FilesystemTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $directory */ public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) { parent::__construct('', $defaultLifetime); $this->init($namespace, $directory); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/MemcachedCache.php000066400000000000000000000013321324732107100251630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\Traits\MemcachedTrait; class MemcachedCache extends AbstractCache { use MemcachedTrait; protected $maxIdLength = 250; /** * @param \Memcached $client * @param string $namespace * @param int $defaultLifetime */ public function __construct(\Memcached $client, $namespace = '', $defaultLifetime = 0) { $this->init($client, $namespace, $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/NullCache.php000066400000000000000000000025541324732107100242360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\SimpleCache\CacheInterface; /** * @author Nicolas Grekas */ class NullCache implements CacheInterface { /** * {@inheritdoc} */ public function get($key, $default = null) { return $default; } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { foreach ($keys as $key) { yield $key => $default; } } /** * {@inheritdoc} */ public function has($key) { return false; } /** * {@inheritdoc} */ public function clear() { return true; } /** * {@inheritdoc} */ public function delete($key) { return true; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { return true; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { return false; } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { return false; } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/PdoCache.php000066400000000000000000000042121324732107100240370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\PdoTrait; class PdoCache extends AbstractCache implements PruneableInterface { use PdoTrait; protected $maxIdLength = 255; /** * You can either pass an existing database connection as PDO instance or * a Doctrine DBAL Connection or a DSN string that will be used to * lazy-connect to the database when the cache is actually used. * * List of available options: * * db_table: The name of the table [default: cache_items] * * db_id_col: The column where to store the cache id [default: item_id] * * db_data_col: The column where to store the cache data [default: item_data] * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime] * * db_time_col: The column where to store the timestamp [default: item_time] * * db_username: The username when lazy-connect [default: ''] * * db_password: The password when lazy-connect [default: ''] * * db_connection_options: An array of driver-specific connection options [default: array()] * * @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null * @param string $namespace * @param int $defaultLifetime * @param array $options An associative array of options * * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION * @throws InvalidArgumentException When namespace contains invalid characters */ public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = array()) { $this->init($connOrDsn, $namespace, $defaultLifetime, $options); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/PhpArrayCache.php000066400000000000000000000200211324732107100250370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\PhpArrayTrait; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * Caches items at warm up time using a PHP array that is stored in shared memory by OPCache since PHP 7.0. * Warmed up items are read-only and run-time discovered items are cached using a fallback adapter. * * @author Titouan Galopin * @author Nicolas Grekas */ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInterface { use PhpArrayTrait; /** * @param string $file The PHP file were values are cached * @param CacheInterface $fallbackPool A pool to fallback on when an item is not hit */ public function __construct($file, CacheInterface $fallbackPool) { $this->file = $file; $this->pool = $fallbackPool; $this->zendDetectUnicode = ini_get('zend.detect_unicode'); } /** * This adapter should only be used on PHP 7.0+ to take advantage of how PHP * stores arrays in its latest versions. This factory method decorates the given * fallback pool with this adapter only if the current PHP version is supported. * * @param string $file The PHP file were values are cached * * @return CacheInterface */ public static function create($file, CacheInterface $fallbackPool) { // Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) { return new static($file, $fallbackPool); } return $fallbackPool; } /** * {@inheritdoc} */ public function get($key, $default = null) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } if (!isset($this->values[$key])) { return $this->pool->get($key, $default); } $value = $this->values[$key]; if ('N;' === $value) { $value = null; } elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) { try { $e = null; $value = unserialize($value); } catch (\Error $e) { } catch (\Exception $e) { } if (null !== $e) { return $default; } } return $value; } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } foreach ($keys as $key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } } if (null === $this->values) { $this->initialize(); } return $this->generateItems($keys, $default); } /** * {@inheritdoc} */ public function has($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } return isset($this->values[$key]) || $this->pool->has($key); } /** * {@inheritdoc} */ public function delete($key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } return !isset($this->values[$key]) && $this->pool->delete($key); } /** * {@inheritdoc} */ public function deleteMultiple($keys) { if (!is_array($keys) && !$keys instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } $deleted = true; $fallbackKeys = array(); foreach ($keys as $key) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (isset($this->values[$key])) { $deleted = false; } else { $fallbackKeys[] = $key; } } if (null === $this->values) { $this->initialize(); } if ($fallbackKeys) { $deleted = $this->pool->deleteMultiple($fallbackKeys) && $deleted; } return $deleted; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (null === $this->values) { $this->initialize(); } return !isset($this->values[$key]) && $this->pool->set($key, $value, $ttl); } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { if (!is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values))); } $saved = true; $fallbackValues = array(); foreach ($values as $key => $value) { if (!is_string($key) && !is_int($key)) { throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if (isset($this->values[$key])) { $saved = false; } else { $fallbackValues[$key] = $value; } } if ($fallbackValues) { $saved = $this->pool->setMultiple($fallbackValues, $ttl) && $saved; } return $saved; } private function generateItems(array $keys, $default) { $fallbackKeys = array(); foreach ($keys as $key) { if (isset($this->values[$key])) { $value = $this->values[$key]; if ('N;' === $value) { yield $key => null; } elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) { try { yield $key => unserialize($value); } catch (\Error $e) { yield $key => $default; } catch (\Exception $e) { yield $key => $default; } } else { yield $key => $value; } } else { $fallbackKeys[] = $key; } } if ($fallbackKeys) { foreach ($this->pool->getMultiple($fallbackKeys, $default) as $key => $item) { yield $key => $item; } } } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/PhpFilesCache.php000066400000000000000000000022671324732107100250370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Traits\PhpFilesTrait; class PhpFilesCache extends AbstractCache implements PruneableInterface { use PhpFilesTrait; /** * @param string $namespace * @param int $defaultLifetime * @param string|null $directory * * @throws CacheException if OPcache is not enabled */ public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) { if (!static::isSupported()) { throw new CacheException('OPcache is not enabled'); } parent::__construct('', $defaultLifetime); $this->init($namespace, $directory); $e = new \Exception(); $this->includeHandler = function () use ($e) { throw $e; }; $this->zendDetectUnicode = ini_get('zend.detect_unicode'); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/Psr6Cache.php000066400000000000000000000152301324732107100241510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheException as Psr6CacheException; use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheException as SimpleCacheException; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ProxyTrait; /** * @author Nicolas Grekas */ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterface { use ProxyTrait; private $createCacheItem; public function __construct(CacheItemPoolInterface $pool) { $this->pool = $pool; if ($pool instanceof AbstractAdapter) { $this->createCacheItem = \Closure::bind( function ($key, $value, $allowInt = false) { if ($allowInt && is_int($key)) { $key = (string) $key; } else { CacheItem::validateKey($key); } $f = $this->createCacheItem; return $f($key, $value, false); }, $pool, AbstractAdapter::class ); } } /** * {@inheritdoc} */ public function get($key, $default = null) { try { $item = $this->pool->getItem($key); } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } return $item->isHit() ? $item->get() : $default; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { try { if (null !== $f = $this->createCacheItem) { $item = $f($key, $value); } else { $item = $this->pool->getItem($key)->set($value); } } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } if (null !== $ttl) { $item->expiresAfter($ttl); } return $this->pool->save($item); } /** * {@inheritdoc} */ public function delete($key) { try { return $this->pool->deleteItem($key); } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } } /** * {@inheritdoc} */ public function clear() { return $this->pool->clear(); } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } try { $items = $this->pool->getItems($keys); } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } $values = array(); foreach ($items as $key => $item) { $values[$key] = $item->isHit() ? $item->get() : $default; } return $values; } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { $valuesIsArray = is_array($values); if (!$valuesIsArray && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', is_object($values) ? get_class($values) : gettype($values))); } $items = array(); try { if (null !== $f = $this->createCacheItem) { $valuesIsArray = false; foreach ($values as $key => $value) { $items[$key] = $f($key, $value, true); } } elseif ($valuesIsArray) { $items = array(); foreach ($values as $key => $value) { $items[] = (string) $key; } $items = $this->pool->getItems($items); } else { foreach ($values as $key => $value) { if (is_int($key)) { $key = (string) $key; } $items[$key] = $this->pool->getItem($key)->set($value); } } } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } $ok = true; foreach ($items as $key => $item) { if ($valuesIsArray) { $item->set($values[$key]); } if (null !== $ttl) { $item->expiresAfter($ttl); } $ok = $this->pool->saveDeferred($item) && $ok; } return $this->pool->commit() && $ok; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', is_object($keys) ? get_class($keys) : gettype($keys))); } try { return $this->pool->deleteItems($keys); } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } } /** * {@inheritdoc} */ public function has($key) { try { return $this->pool->hasItem($key); } catch (SimpleCacheException $e) { throw $e; } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/RedisCache.php000066400000000000000000000014361324732107100243700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Symfony\Component\Cache\Traits\RedisTrait; class RedisCache extends AbstractCache { use RedisTrait; /** * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient * @param string $namespace * @param int $defaultLifetime */ public function __construct($redisClient, $namespace = '', $defaultLifetime = 0) { $this->init($redisClient, $namespace, $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Simple/TraceableCache.php000066400000000000000000000133301324732107100252000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * An adapter that collects data about all cache calls. * * @author Nicolas Grekas */ class TraceableCache implements CacheInterface, PruneableInterface, ResettableInterface { private $pool; private $miss; private $calls = array(); public function __construct(CacheInterface $pool) { $this->pool = $pool; $this->miss = new \stdClass(); } /** * {@inheritdoc} */ public function get($key, $default = null) { $miss = null !== $default && is_object($default) ? $default : $this->miss; $event = $this->start(__FUNCTION__); try { $value = $this->pool->get($key, $miss); } finally { $event->end = microtime(true); } if ($event->result[$key] = $miss !== $value) { ++$event->hits; } else { ++$event->misses; $value = $default; } return $value; } /** * {@inheritdoc} */ public function has($key) { $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->has($key); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function delete($key) { $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->delete($key); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->set($key, $value, $ttl); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { $event = $this->start(__FUNCTION__); $event->result['keys'] = array(); if ($values instanceof \Traversable) { $values = function () use ($values, $event) { foreach ($values as $k => $v) { $event->result['keys'][] = $k; yield $k => $v; } }; $values = $values(); } elseif (is_array($values)) { $event->result['keys'] = array_keys($values); } try { return $event->result['result'] = $this->pool->setMultiple($values, $ttl); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { $miss = null !== $default && is_object($default) ? $default : $this->miss; $event = $this->start(__FUNCTION__); try { $result = $this->pool->getMultiple($keys, $miss); } finally { $event->end = microtime(true); } $f = function () use ($result, $event, $miss, $default) { $event->result = array(); foreach ($result as $key => $value) { if ($event->result[$key] = $miss !== $value) { ++$event->hits; } else { ++$event->misses; $value = $default; } yield $key => $value; } }; return $f(); } /** * {@inheritdoc} */ public function clear() { $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->clear(); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function deleteMultiple($keys) { $event = $this->start(__FUNCTION__); if ($keys instanceof \Traversable) { $keys = $event->result['keys'] = iterator_to_array($keys, false); } else { $event->result['keys'] = $keys; } try { return $event->result['result'] = $this->pool->deleteMultiple($keys); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function prune() { if (!$this->pool instanceof PruneableInterface) { return false; } $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->prune(); } finally { $event->end = microtime(true); } } /** * {@inheritdoc} */ public function reset() { if (!$this->pool instanceof ResettableInterface) { return; } $event = $this->start(__FUNCTION__); try { $this->pool->reset(); } finally { $event->end = microtime(true); } } public function getCalls() { try { return $this->calls; } finally { $this->calls = array(); } } private function start($name) { $this->calls[] = $event = new TraceableCacheEvent(); $event->name = $name; $event->start = microtime(true); return $event; } } class TraceableCacheEvent { public $name; public $start; public $end; public $result; public $hits = 0; public $misses = 0; } symfony-3.4.6/src/Symfony/Component/Cache/Tests/000077500000000000000000000000001324732107100215325ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/000077500000000000000000000000001324732107100231125ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php000066400000000000000000000025001324732107100305130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\RedisAdapter; abstract class AbstractRedisAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testExpiration' => 'Testing expiration slows down the test suite', 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); protected static $redis; public function createCachePool($defaultLifetime = 0) { return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); } public static function setupBeforeClass() { if (!extension_loaded('redis')) { self::markTestSkipped('Extension redis required.'); } if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { $e = error_get_last(); self::markTestSkipped($e['message']); } } public static function tearDownAfterClass() { self::$redis = null; } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php000066400000000000000000000127551324732107100266510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Cache\IntegrationTests\CachePoolTest; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\PruneableInterface; abstract class AdapterTestCase extends CachePoolTest { protected function setUp() { parent::setUp(); if (!array_key_exists('testDeferredSaveWithoutCommit', $this->skippedTests) && defined('HHVM_VERSION')) { $this->skippedTests['testDeferredSaveWithoutCommit'] = 'Destructors are called late on HHVM.'; } if (!array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) { $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; } } public function testDefaultLifeTime() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = $this->createCachePool(2); $item = $cache->getItem('key.dlt'); $item->set('value'); $cache->save($item); sleep(1); $item = $cache->getItem('key.dlt'); $this->assertTrue($item->isHit()); sleep(2); $item = $cache->getItem('key.dlt'); $this->assertFalse($item->isHit()); } public function testExpiration() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = $this->createCachePool(); $cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2)); $cache->save($cache->getItem('k2')->set('v2')->expiresAfter(366 * 86400)); sleep(3); $item = $cache->getItem('k1'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit() is false."); $item = $cache->getItem('k2'); $this->assertTrue($item->isHit()); $this->assertSame('v2', $item->get()); } public function testNotUnserializable() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = $this->createCachePool(); $item = $cache->getItem('foo'); $cache->save($item->set(new NotUnserializable())); $item = $cache->getItem('foo'); $this->assertFalse($item->isHit()); foreach ($cache->getItems(array('foo')) as $item) { } $cache->save($item->set(new NotUnserializable())); foreach ($cache->getItems(array('foo')) as $item) { } $this->assertFalse($item->isHit()); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } if (!method_exists($this, 'isPruned')) { $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); } /** @var PruneableInterface|CacheItemPoolInterface $cache */ $cache = $this->createCachePool(); $doSet = function ($name, $value, \DateInterval $expiresAfter = null) use ($cache) { $item = $cache->getItem($name); $item->set($value); if ($expiresAfter) { $item->expiresAfter($expiresAfter); } $cache->save($item); }; $doSet('foo', 'foo-val', new \DateInterval('PT05S')); $doSet('bar', 'bar-val', new \DateInterval('PT10S')); $doSet('baz', 'baz-val', new \DateInterval('PT15S')); $doSet('qux', 'qux-val', new \DateInterval('PT20S')); sleep(30); $cache->prune(); $this->assertTrue($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'bar')); $this->assertTrue($this->isPruned($cache, 'baz')); $this->assertTrue($this->isPruned($cache, 'qux')); $doSet('foo', 'foo-val'); $doSet('bar', 'bar-val', new \DateInterval('PT20S')); $doSet('baz', 'baz-val', new \DateInterval('PT40S')); $doSet('qux', 'qux-val', new \DateInterval('PT80S')); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertFalse($this->isPruned($cache, 'bar')); $this->assertFalse($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'bar')); $this->assertFalse($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'qux')); } } class NotUnserializable implements \Serializable { public function serialize() { return serialize(123); } public function unserialize($ser) { throw new \Exception(__CLASS__); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php000066400000000000000000000073651324732107100266670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Log\NullLogger; use Symfony\Component\Cache\Adapter\ApcuAdapter; class ApcuAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testExpiration' => 'Testing expiration slows down the test suite', 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); public function createCachePool($defaultLifetime = 0) { if (!function_exists('apcu_fetch') || !ini_get('apc.enabled')) { $this->markTestSkipped('APCu extension is required.'); } if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) { if ('testWithCliSapi' !== $this->getName()) { $this->markTestSkipped('apc.enable_cli=1 is required.'); } } if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Fails transiently on Windows.'); } return new ApcuAdapter(str_replace('\\', '.', __CLASS__), $defaultLifetime); } public function testUnserializable() { $pool = $this->createCachePool(); $item = $pool->getItem('foo'); $item->set(function () {}); $this->assertFalse($pool->save($item)); $item = $pool->getItem('foo'); $this->assertFalse($item->isHit()); } public function testVersion() { $namespace = str_replace('\\', '.', get_class($this)); $pool1 = new ApcuAdapter($namespace, 0, 'p1'); $item = $pool1->getItem('foo'); $this->assertFalse($item->isHit()); $this->assertTrue($pool1->save($item->set('bar'))); $item = $pool1->getItem('foo'); $this->assertTrue($item->isHit()); $this->assertSame('bar', $item->get()); $pool2 = new ApcuAdapter($namespace, 0, 'p2'); $item = $pool2->getItem('foo'); $this->assertFalse($item->isHit()); $this->assertNull($item->get()); $item = $pool1->getItem('foo'); $this->assertFalse($item->isHit()); $this->assertNull($item->get()); } public function testNamespace() { $namespace = str_replace('\\', '.', get_class($this)); $pool1 = new ApcuAdapter($namespace.'_1', 0, 'p1'); $item = $pool1->getItem('foo'); $this->assertFalse($item->isHit()); $this->assertTrue($pool1->save($item->set('bar'))); $item = $pool1->getItem('foo'); $this->assertTrue($item->isHit()); $this->assertSame('bar', $item->get()); $pool2 = new ApcuAdapter($namespace.'_2', 0, 'p1'); $item = $pool2->getItem('foo'); $this->assertFalse($item->isHit()); $this->assertNull($item->get()); $item = $pool1->getItem('foo'); $this->assertTrue($item->isHit()); $this->assertSame('bar', $item->get()); } public function testWithCliSapi() { try { // disable PHPUnit error handler to mimic a production environment $isCalled = false; set_error_handler(function () use (&$isCalled) { $isCalled = true; }); $pool = new ApcuAdapter(str_replace('\\', '.', __CLASS__)); $pool->setLogger(new NullLogger()); $item = $pool->getItem('foo'); $item->isHit(); $pool->save($item->set('bar')); $this->assertFalse($isCalled); } finally { restore_error_handler(); } } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php000066400000000000000000000030121324732107100270360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; /** * @group time-sensitive */ class ArrayAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', ); public function createCachePool($defaultLifetime = 0) { return new ArrayAdapter($defaultLifetime); } public function testGetValuesHitAndMiss() { /** @var ArrayAdapter $cache */ $cache = $this->createCachePool(); // Hit $item = $cache->getItem('foo'); $item->set('4711'); $cache->save($item); $fooItem = $cache->getItem('foo'); $this->assertTrue($fooItem->isHit()); $this->assertEquals('4711', $fooItem->get()); // Miss (should be present as NULL in $values) $cache->getItem('bar'); $values = $cache->getValues(); $this->assertCount(2, $values); $this->assertArrayHasKey('foo', $values); $this->assertSame(serialize('4711'), $values['foo']); $this->assertArrayHasKey('bar', $values); $this->assertNull($values['bar']); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php000066400000000000000000000064241324732107100270140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ChainAdapter; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; /** * @author Kévin Dunglas * @group time-sensitive */ class ChainAdapterTest extends AdapterTestCase { public function createCachePool($defaultLifetime = 0) { return new ChainAdapter(array(new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage At least one adapter must be specified. */ public function testEmptyAdaptersException() { new ChainAdapter(array()); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage The class "stdClass" does not implement */ public function testInvalidAdapterException() { new ChainAdapter(array(new \stdClass())); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = new ChainAdapter(array( $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), )); $this->assertTrue($cache->prune()); $cache = new ChainAdapter(array( $this->getPruneableMock(), $this->getFailingPruneableMock(), $this->getPruneableMock(), )); $this->assertFalse($cache->prune()); } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(true)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getFailingPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(false)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|AdapterInterface */ private function getNonPruneableMock() { return $this ->getMockBuilder(AdapterInterface::class) ->getMock(); } } interface PruneableCacheInterface extends PruneableInterface, AdapterInterface { } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php000066400000000000000000000016521324732107100275370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Doctrine\Common\Cache\ArrayCache; use Symfony\Component\Cache\Adapter\DoctrineAdapter; /** * @group time-sensitive */ class DoctrineAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.', 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', ); public function createCachePool($defaultLifetime = 0) { return new DoctrineAdapter(new ArrayCache($defaultLifetime), '', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php000066400000000000000000000032461324732107100301150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; /** * @group time-sensitive */ class FilesystemAdapterTest extends AdapterTestCase { public function createCachePool($defaultLifetime = 0) { return new FilesystemAdapter('', $defaultLifetime); } public static function tearDownAfterClass() { self::rmdir(sys_get_temp_dir().'/symfony-cache'); } public static function rmdir($dir) { if (!file_exists($dir)) { return; } if (!$dir || 0 !== strpos(dirname($dir), sys_get_temp_dir())) { throw new \Exception(__METHOD__."() operates only on subdirs of system's temp dir"); } $children = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); foreach ($children as $child) { if ($child->isDir()) { rmdir($child); } else { unlink($child); } } rmdir($dir); } protected function isPruned(CacheItemPoolInterface $cache, $name) { $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); $getFileMethod->setAccessible(true); return !file_exists($getFileMethod->invoke($cache, $name)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php000066400000000000000000000032441324732107100301330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\AbstractAdapter; class MaxIdLengthAdapterTest extends TestCase { public function testLongKey() { $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) ->setConstructorArgs(array(str_repeat('-', 10))) ->setMethods(array('doHave', 'doFetch', 'doDelete', 'doSave', 'doClear')) ->getMock(); $cache->expects($this->exactly(2)) ->method('doHave') ->withConsecutive( array($this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')), array($this->equalTo('----------:---------------------------------------')) ); $cache->hasItem(str_repeat('-', 40)); $cache->hasItem(str_repeat('-', 39)); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Namespace must be 26 chars max, 40 given ("----------------------------------------") */ public function testTooLongNamespace() { $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) ->setConstructorArgs(array(str_repeat('-', 40))) ->getMock(); } } abstract class MaxIdLengthAdapter extends AbstractAdapter { protected $maxIdLength = 50; public function __construct($ns) { parent::__construct($ns); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php000066400000000000000000000151571324732107100276430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\MemcachedAdapter; class MemcachedAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); protected static $client; public static function setupBeforeClass() { if (!MemcachedAdapter::isSupported()) { self::markTestSkipped('Extension memcached >=2.2.0 required.'); } self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)); self::$client->get('foo'); $code = self::$client->getResultCode(); if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); } } public function createCachePool($defaultLifetime = 0) { $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client; return new MemcachedAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); } public function testOptions() { $client = MemcachedAdapter::createConnection(array(), array( 'libketama_compatible' => false, 'distribution' => 'modula', 'compression' => true, 'serializer' => 'php', 'hash' => 'md5', )); $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); } /** * @dataProvider provideBadOptions * @expectedException \ErrorException * @expectedExceptionMessage constant(): Couldn't find constant Memcached:: */ public function testBadOptions($name, $value) { MemcachedAdapter::createConnection(array(), array($name => $value)); } public function provideBadOptions() { return array( array('foo', 'bar'), array('hash', 'zyx'), array('serializer', 'zyx'), array('distribution', 'zyx'), ); } public function testDefaultOptions() { $this->assertTrue(MemcachedAdapter::isSupported()); $client = MemcachedAdapter::createConnection(array()); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); $this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); } /** * @expectedException \Symfony\Component\Cache\Exception\CacheException * @expectedExceptionMessage MemcachedAdapter: "serializer" option must be "php" or "igbinary". */ public function testOptionSerializer() { if (!\Memcached::HAVE_JSON) { $this->markTestSkipped('Memcached::HAVE_JSON required'); } new MemcachedAdapter(MemcachedAdapter::createConnection(array(), array('serializer' => 'json'))); } /** * @dataProvider provideServersSetting */ public function testServersSetting($dsn, $host, $port) { $client1 = MemcachedAdapter::createConnection($dsn); $client2 = MemcachedAdapter::createConnection(array($dsn)); $client3 = MemcachedAdapter::createConnection(array(array($host, $port))); $expect = array( 'host' => $host, 'port' => $port, ); $f = function ($s) { return array('host' => $s['host'], 'port' => $s['port']); }; $this->assertSame(array($expect), array_map($f, $client1->getServerList())); $this->assertSame(array($expect), array_map($f, $client2->getServerList())); $this->assertSame(array($expect), array_map($f, $client3->getServerList())); } public function provideServersSetting() { yield array( 'memcached://127.0.0.1/50', '127.0.0.1', 11211, ); yield array( 'memcached://localhost:11222?weight=25', 'localhost', 11222, ); if (ini_get('memcached.use_sasl')) { yield array( 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', 11211, ); } yield array( 'memcached:///var/run/memcached.sock?weight=25', '/var/run/memcached.sock', 0, ); yield array( 'memcached:///var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, ); if (ini_get('memcached.use_sasl')) { yield array( 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, ); } } /** * @dataProvider provideDsnWithOptions */ public function testDsnWithOptions($dsn, array $options, array $expectedOptions) { $client = MemcachedAdapter::createConnection($dsn, $options); foreach ($expectedOptions as $option => $expect) { $this->assertSame($expect, $client->getOption($option)); } } public function provideDsnWithOptions() { if (!class_exists('\Memcached')) { self::markTestSkipped('Extension memcached required.'); } yield array( 'memcached://localhost:11222?retry_timeout=10', array(\Memcached::OPT_RETRY_TIMEOUT => 8), array(\Memcached::OPT_RETRY_TIMEOUT => 10), ); yield array( 'memcached://localhost:11222?socket_recv_size=1&socket_send_size=2', array(\Memcached::OPT_RETRY_TIMEOUT => 8), array(\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8), ); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php000066400000000000000000000012101324732107100310600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; /** * @group time-sensitive */ class NamespacedProxyAdapterTest extends ProxyAdapterTest { public function createCachePool($defaultLifetime = 0) { return new ProxyAdapter(new ArrayAdapter($defaultLifetime), 'foo', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php000066400000000000000000000064631324732107100267070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\NullAdapter; /** * @group time-sensitive */ class NullAdapterTest extends TestCase { public function createCachePool() { return new NullAdapter(); } public function testGetItem() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); } public function testHasItem() { $this->assertFalse($this->createCachePool()->hasItem('key')); } public function testGetItems() { $adapter = $this->createCachePool(); $keys = array('foo', 'bar', 'baz', 'biz'); /** @var CacheItemInterface[] $items */ $items = $adapter->getItems($keys); $count = 0; foreach ($items as $key => $item) { $itemKey = $item->getKey(); $this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items'); $this->assertContains($key, $keys, 'Cache key can not change.'); $this->assertFalse($item->isHit()); // Remove $key for $keys foreach ($keys as $k => $v) { if ($v === $key) { unset($keys[$k]); } } ++$count; } $this->assertSame(4, $count); } public function testIsHit() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); } public function testClear() { $this->assertTrue($this->createCachePool()->clear()); } public function testDeleteItem() { $this->assertTrue($this->createCachePool()->deleteItem('key')); } public function testDeleteItems() { $this->assertTrue($this->createCachePool()->deleteItems(array('key', 'foo', 'bar'))); } public function testSave() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->save($item)); } public function testDeferredSave() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->saveDeferred($item)); } public function testCommit() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->saveDeferred($item)); $this->assertFalse($this->createCachePool()->commit()); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php000066400000000000000000000035561324732107100265170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoAdapterTest extends AdapterTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter('sqlite:'.self::$dbFile); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createCachePool($defaultLifetime = 0) { return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } public function testCleanupExpiredItems() { $pdo = new \PDO('sqlite:'.self::$dbFile); $getCacheItemCount = function () use ($pdo) { return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN); }; $this->assertSame(0, $getCacheItemCount()); $cache = $this->createCachePool(); $item = $cache->getItem('some_nice_key'); $item->expiresAfter(1); $item->set(1); $cache->save($item); $this->assertSame(1, $getCacheItemCount()); sleep(2); $newItem = $cache->getItem($item->getKey()); $this->assertFalse($newItem->isHit()); $this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items'); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php000066400000000000000000000024101324732107100272660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Doctrine\DBAL\DriverManager; use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoDbalAdapterTest extends AdapterTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile))); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createCachePool($defaultLifetime = 0) { return new PdoAdapter(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile)), '', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php000066400000000000000000000115031324732107100275120ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; /** * @group time-sensitive */ class PhpArrayAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testBasicUsage' => 'PhpArrayAdapter is read-only.', 'testBasicUsageWithLongKey' => 'PhpArrayAdapter is read-only.', 'testClear' => 'PhpArrayAdapter is read-only.', 'testClearWithDeferredItems' => 'PhpArrayAdapter is read-only.', 'testDeleteItem' => 'PhpArrayAdapter is read-only.', 'testSaveExpired' => 'PhpArrayAdapter is read-only.', 'testSaveWithoutExpire' => 'PhpArrayAdapter is read-only.', 'testDeferredSave' => 'PhpArrayAdapter is read-only.', 'testDeferredSaveWithoutCommit' => 'PhpArrayAdapter is read-only.', 'testDeleteItems' => 'PhpArrayAdapter is read-only.', 'testDeleteDeferredItem' => 'PhpArrayAdapter is read-only.', 'testCommit' => 'PhpArrayAdapter is read-only.', 'testSaveDeferredWhenChangingValues' => 'PhpArrayAdapter is read-only.', 'testSaveDeferredOverwrite' => 'PhpArrayAdapter is read-only.', 'testIsHitDeferred' => 'PhpArrayAdapter is read-only.', 'testExpiresAt' => 'PhpArrayAdapter does not support expiration.', 'testExpiresAtWithNull' => 'PhpArrayAdapter does not support expiration.', 'testExpiresAfterWithNull' => 'PhpArrayAdapter does not support expiration.', 'testDeferredExpired' => 'PhpArrayAdapter does not support expiration.', 'testExpiration' => 'PhpArrayAdapter does not support expiration.', 'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDefaultLifeTime' => 'PhpArrayAdapter does not allow configuring a default lifetime.', 'testPrune' => 'PhpArrayAdapter just proxies', ); protected static $file; public static function setupBeforeClass() { self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; } protected function tearDown() { if (file_exists(sys_get_temp_dir().'/symfony-cache')) { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } } public function createCachePool() { return new PhpArrayAdapterWrapper(self::$file, new NullAdapter()); } public function testStore() { $arrayWithRefs = array(); $arrayWithRefs[0] = 123; $arrayWithRefs[1] = &$arrayWithRefs[0]; $object = (object) array( 'foo' => 'bar', 'foo2' => 'bar2', ); $expected = array( 'null' => null, 'serializedString' => serialize($object), 'arrayWithRefs' => $arrayWithRefs, 'object' => $object, 'arrayWithObject' => array('bar' => $object), ); $adapter = $this->createCachePool(); $adapter->warmUp($expected); foreach ($expected as $key => $value) { $this->assertSame(serialize($value), serialize($adapter->getItem($key)->get()), 'Warm up should create a PHP file that OPCache can load in memory'); } } public function testStoredFile() { $expected = array( 'integer' => 42, 'float' => 42.42, 'boolean' => true, 'array_simple' => array('foo', 'bar'), 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), ); $adapter = $this->createCachePool(); $adapter->warmUp($expected); $values = eval(substr(file_get_contents(self::$file), 6)); $this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory'); } } class PhpArrayAdapterWrapper extends PhpArrayAdapter { public function save(CacheItemInterface $item) { call_user_func(\Closure::bind(function () use ($item) { $this->values[$item->getKey()] = $item->get(); $this->warmUp($this->values); $this->values = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayAdapter::class)); return true; } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php000066400000000000000000000031551324732107100317720ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; /** * @group time-sensitive */ class PhpArrayAdapterWithFallbackTest extends AdapterTestCase { protected $skippedTests = array( 'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testPrune' => 'PhpArrayAdapter just proxies', ); protected static $file; public static function setupBeforeClass() { self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; } protected function tearDown() { if (file_exists(sys_get_temp_dir().'/symfony-cache')) { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } } public function createCachePool($defaultLifetime = 0) { return new PhpArrayAdapter(self::$file, new FilesystemAdapter('php-array-fallback', $defaultLifetime)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php000066400000000000000000000023451324732107100275020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; /** * @group time-sensitive */ class PhpFilesAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.', ); public function createCachePool() { if (!PhpFilesAdapter::isSupported()) { $this->markTestSkipped('OPcache extension is not enabled.'); } return new PhpFilesAdapter('sf-cache'); } public static function tearDownAfterClass() { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } protected function isPruned(CacheItemPoolInterface $cache, $name) { $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); $getFileMethod->setAccessible(true); return !file_exists($getFileMethod->invoke($cache, $name)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php000066400000000000000000000030701324732107100272120ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Predis\Connection\StreamConnection; use Symfony\Component\Cache\Adapter\RedisAdapter; class PredisAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = new \Predis\Client(array('host' => getenv('REDIS_HOST'))); } public function testCreateConnection() { $redisHost = getenv('REDIS_HOST'); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', array('class' => \Predis\Client::class, 'timeout' => 3)); $this->assertInstanceOf(\Predis\Client::class, $redis); $connection = $redis->getConnection(); $this->assertInstanceOf(StreamConnection::class, $connection); $params = array( 'scheme' => 'tcp', 'host' => $redisHost, 'path' => '', 'dbindex' => '1', 'port' => 6379, 'class' => 'Predis\Client', 'timeout' => 3, 'persistent' => 0, 'persistent_id' => null, 'read_timeout' => 0, 'retry_interval' => 0, 'lazy' => false, 'database' => '1', 'password' => null, ); $this->assertSame($params, $connection->getParameters()->toArray()); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php000066400000000000000000000011651324732107100305570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; class PredisClusterAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = new \Predis\Client(array(array('host' => getenv('REDIS_HOST')))); } public static function tearDownAfterClass() { self::$redis = null; } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php000066400000000000000000000033501324732107100271060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\CacheItem; /** * @group time-sensitive */ class ProxyAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', 'testPrune' => 'ProxyAdapter just proxies', ); public function createCachePool($defaultLifetime = 0) { return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime); } /** * @expectedException \Exception * @expectedExceptionMessage OK bar */ public function testProxyfiedItem() { $item = new CacheItem(); $pool = new ProxyAdapter(new TestingArrayAdapter($item)); $proxyItem = $pool->getItem('foo'); $this->assertNotSame($item, $proxyItem); $pool->save($proxyItem->set('bar')); } } class TestingArrayAdapter extends ArrayAdapter { private $item; public function __construct(CacheItemInterface $item) { $this->item = $item; } public function getItem($key) { return $this->item; } public function save(CacheItemInterface $item) { if ($item === $this->item) { throw new \Exception('OK '.$item->get()); } } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php000066400000000000000000000054741324732107100270440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Traits\RedisProxy; class RedisAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), array('lazy' => true)); } public function createCachePool($defaultLifetime = 0) { $adapter = parent::createCachePool($defaultLifetime); $this->assertInstanceOf(RedisProxy::class, self::$redis); return $adapter; } public function testCreateConnection() { $redisHost = getenv('REDIS_HOST'); $redis = RedisAdapter::createConnection('redis://'.$redisHost); $this->assertInstanceOf(\Redis::class, $redis); $this->assertTrue($redis->isConnected()); $this->assertSame(0, $redis->getDbNum()); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('timeout' => 3)); $this->assertEquals(3, $redis->getTimeout()); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); $this->assertEquals(5, $redis->getReadTimeout()); } /** * @dataProvider provideFailedCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Redis connection failed */ public function testFailedCreateConnection($dsn) { RedisAdapter::createConnection($dsn); } public function provideFailedCreateConnection() { return array( array('redis://localhost:1234'), array('redis://foo@localhost'), array('redis://localhost/123'), ); } /** * @dataProvider provideInvalidCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid Redis DSN */ public function testInvalidCreateConnection($dsn) { RedisAdapter::createConnection($dsn); } public function provideInvalidCreateConnection() { return array( array('foo://localhost'), array('redis://'), ); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php000066400000000000000000000012401324732107100300260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; class RedisArrayAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() { parent::setupBeforeClass(); if (!class_exists('RedisArray')) { self::markTestSkipped('The RedisArray class is required.'); } self::$redis = new \RedisArray(array(getenv('REDIS_HOST')), array('lazy_connect' => true)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php000066400000000000000000000013411324732107100301400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Simple\FilesystemCache; use Symfony\Component\Cache\Adapter\SimpleCacheAdapter; /** * @group time-sensitive */ class SimpleCacheAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testPrune' => 'SimpleCache just proxies', ); public function createCachePool($defaultLifetime = 0) { return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php000066400000000000000000000116151324732107100274630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; /** * @group time-sensitive */ class TagAwareAdapterTest extends AdapterTestCase { public function createCachePool($defaultLifetime = 0) { return new TagAwareAdapter(new FilesystemAdapter('', $defaultLifetime)); } public static function tearDownAfterClass() { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } /** * @expectedException \Psr\Cache\InvalidArgumentException */ public function testInvalidTag() { $pool = $this->createCachePool(); $item = $pool->getItem('foo'); $item->tag(':'); } public function testInvalidateTags() { $pool = $this->createCachePool(); $i0 = $pool->getItem('i0'); $i1 = $pool->getItem('i1'); $i2 = $pool->getItem('i2'); $i3 = $pool->getItem('i3'); $foo = $pool->getItem('foo'); $pool->save($i0->tag('bar')); $pool->save($i1->tag('foo')); $pool->save($i2->tag('foo')->tag('bar')); $pool->save($i3->tag('foo')->tag('baz')); $pool->save($foo); $pool->invalidateTags(array('bar')); $this->assertFalse($pool->getItem('i0')->isHit()); $this->assertTrue($pool->getItem('i1')->isHit()); $this->assertFalse($pool->getItem('i2')->isHit()); $this->assertTrue($pool->getItem('i3')->isHit()); $this->assertTrue($pool->getItem('foo')->isHit()); $pool->invalidateTags(array('foo')); $this->assertFalse($pool->getItem('i1')->isHit()); $this->assertFalse($pool->getItem('i3')->isHit()); $this->assertTrue($pool->getItem('foo')->isHit()); } public function testTagsAreCleanedOnSave() { $pool = $this->createCachePool(); $i = $pool->getItem('k'); $pool->save($i->tag('foo')); $i = $pool->getItem('k'); $pool->save($i->tag('bar')); $pool->invalidateTags(array('foo')); $this->assertTrue($pool->getItem('k')->isHit()); } public function testTagsAreCleanedOnDelete() { $pool = $this->createCachePool(); $i = $pool->getItem('k'); $pool->save($i->tag('foo')); $pool->deleteItem('k'); $pool->save($pool->getItem('k')); $pool->invalidateTags(array('foo')); $this->assertTrue($pool->getItem('k')->isHit()); } public function testTagItemExpiry() { $pool = $this->createCachePool(10); $item = $pool->getItem('foo'); $item->tag(array('baz')); $item->expiresAfter(100); $pool->save($item); $pool->invalidateTags(array('baz')); $this->assertFalse($pool->getItem('foo')->isHit()); sleep(20); $this->assertFalse($pool->getItem('foo')->isHit()); } public function testGetPreviousTags() { $pool = $this->createCachePool(); $i = $pool->getItem('k'); $pool->save($i->tag('foo')); $i = $pool->getItem('k'); $this->assertSame(array('foo' => 'foo'), $i->getPreviousTags()); } public function testPrune() { $cache = new TagAwareAdapter($this->getPruneableMock()); $this->assertTrue($cache->prune()); $cache = new TagAwareAdapter($this->getNonPruneableMock()); $this->assertFalse($cache->prune()); $cache = new TagAwareAdapter($this->getFailingPruneableMock()); $this->assertFalse($cache->prune()); } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(true)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getFailingPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(false)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|AdapterInterface */ private function getNonPruneableMock() { return $this ->getMockBuilder(AdapterInterface::class) ->getMock(); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php000066400000000000000000000134301324732107100276470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapter; /** * @group time-sensitive */ class TraceableAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testPrune' => 'TraceableAdapter just proxies', ); public function createCachePool($defaultLifetime = 0) { return new TraceableAdapter(new FilesystemAdapter('', $defaultLifetime)); } public function testGetItemMissTrace() { $pool = $this->createCachePool(); $pool->getItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('getItem', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testGetItemHitTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $pool->getItem('k'); $calls = $pool->getCalls(); $this->assertCount(3, $calls); $call = $calls[2]; $this->assertSame(1, $call->hits); $this->assertSame(0, $call->misses); } public function testGetItemsMissTrace() { $pool = $this->createCachePool(); $arg = array('k0', 'k1'); $items = $pool->getItems($arg); foreach ($items as $item) { } $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('getItems', $call->name); $this->assertSame(array('k0' => false, 'k1' => false), $call->result); $this->assertSame(2, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasItemMissTrace() { $pool = $this->createCachePool(); $pool->hasItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('hasItem', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasItemHitTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $pool->hasItem('k'); $calls = $pool->getCalls(); $this->assertCount(3, $calls); $call = $calls[2]; $this->assertSame('hasItem', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteItemTrace() { $pool = $this->createCachePool(); $pool->deleteItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteItem', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteItemsTrace() { $pool = $this->createCachePool(); $arg = array('k0', 'k1'); $pool->deleteItems($arg); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteItems', $call->name); $this->assertSame(array('keys' => $arg, 'result' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testSaveTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('save', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testSaveDeferredTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->saveDeferred($item); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('saveDeferred', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testCommitTrace() { $pool = $this->createCachePool(); $pool->commit(); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('commit', $call->name); $this->assertTrue($call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php000066400000000000000000000020771324732107100312700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; /** * @group time-sensitive */ class TraceableTagAwareAdapterTest extends TraceableAdapterTest { public function testInvalidateTags() { $pool = new TraceableTagAwareAdapter(new TagAwareAdapter(new FilesystemAdapter())); $pool->invalidateTags(array('foo')); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('invalidateTags', $call->name); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/CacheItemTest.php000066400000000000000000000036401324732107100247300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\CacheItem; class CacheItemTest extends TestCase { public function testValidKey() { $this->assertSame('foo', CacheItem::validateKey('foo')); } /** * @dataProvider provideInvalidKey * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Cache key */ public function testInvalidKey($key) { CacheItem::validateKey($key); } public function provideInvalidKey() { return array( array(''), array('{'), array('}'), array('('), array(')'), array('/'), array('\\'), array('@'), array(':'), array(true), array(null), array(1), array(1.1), array(array(array())), array(new \Exception('foo')), ); } public function testTag() { $item = new CacheItem(); $this->assertSame($item, $item->tag('foo')); $this->assertSame($item, $item->tag(array('bar', 'baz'))); call_user_func(\Closure::bind(function () use ($item) { $this->assertSame(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $item->tags); }, $this, CacheItem::class)); } /** * @dataProvider provideInvalidKey * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Cache tag */ public function testInvalidTag($tag) { $item = new CacheItem(); $item->tag($tag); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/DoctrineProviderTest.php000066400000000000000000000023611324732107100263670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests; use Doctrine\Common\Cache\CacheProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\DoctrineProvider; class DoctrineProviderTest extends TestCase { public function testProvider() { $pool = new ArrayAdapter(); $cache = new DoctrineProvider($pool); $this->assertInstanceOf(CacheProvider::class, $cache); $key = '{}()/\@:'; $this->assertTrue($cache->delete($key)); $this->assertFalse($cache->contains($key)); $this->assertTrue($cache->save($key, 'bar')); $this->assertTrue($cache->contains($key)); $this->assertSame('bar', $cache->fetch($key)); $this->assertTrue($cache->delete($key)); $this->assertFalse($cache->fetch($key)); $this->assertTrue($cache->save($key, 'bar')); $cache->flushAll(); $this->assertFalse($cache->fetch($key)); $this->assertFalse($cache->contains($key)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Fixtures/000077500000000000000000000000001324732107100233435ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php000066400000000000000000000031161324732107100271400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Fixtures; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; /** * Adapter not implementing the {@see \Symfony\Component\Cache\Adapter\AdapterInterface}. * * @author Kévin Dunglas */ class ExternalAdapter implements CacheItemPoolInterface { private $cache; public function __construct() { $this->cache = new ArrayAdapter(); } public function getItem($key) { return $this->cache->getItem($key); } public function getItems(array $keys = array()) { return $this->cache->getItems($keys); } public function hasItem($key) { return $this->cache->hasItem($key); } public function clear() { return $this->cache->clear(); } public function deleteItem($key) { return $this->cache->deleteItem($key); } public function deleteItems(array $keys) { return $this->cache->deleteItems($keys); } public function save(CacheItemInterface $item) { return $this->cache->save($item); } public function saveDeferred(CacheItemInterface $item) { return $this->cache->saveDeferred($item); } public function commit() { return $this->cache->commit(); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/000077500000000000000000000000001324732107100227635ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php000066400000000000000000000024261324732107100300160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\RedisCache; abstract class AbstractRedisCacheTest extends CacheTestCase { protected $skippedTests = array( 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); protected static $redis; public function createSimpleCache($defaultLifetime = 0) { return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); } public static function setupBeforeClass() { if (!extension_loaded('redis')) { self::markTestSkipped('Extension redis required.'); } if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { $e = error_get_last(); self::markTestSkipped($e['message']); } } public static function tearDownAfterClass() { self::$redis = null; } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php000066400000000000000000000021651324732107100261540ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\ApcuCache; class ApcuCacheTest extends CacheTestCase { protected $skippedTests = array( 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); public function createSimpleCache($defaultLifetime = 0) { if (!function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === PHP_SAPI && !ini_get('apc.enable_cli'))) { $this->markTestSkipped('APCu extension is required.'); } if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Fails transiently on Windows.'); } return new ApcuCache(str_replace('\\', '.', __CLASS__), $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php000066400000000000000000000010301324732107100263300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\ArrayCache; /** * @group time-sensitive */ class ArrayCacheTest extends CacheTestCase { public function createSimpleCache($defaultLifetime = 0) { return new ArrayCache($defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php000066400000000000000000000103561324732107100261400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Cache\IntegrationTests\SimpleCacheTest; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\PruneableInterface; abstract class CacheTestCase extends SimpleCacheTest { protected function setUp() { parent::setUp(); if (!array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) { $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; } } public static function validKeys() { if (defined('HHVM_VERSION')) { return parent::validKeys(); } return array_merge(parent::validKeys(), array(array("a\0b"))); } public function testDefaultLifeTime() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = $this->createSimpleCache(2); $cache->set('key.dlt', 'value'); sleep(1); $this->assertSame('value', $cache->get('key.dlt')); sleep(2); $this->assertNull($cache->get('key.dlt')); } public function testNotUnserializable() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = $this->createSimpleCache(); $cache->set('foo', new NotUnserializable()); $this->assertNull($cache->get('foo')); $cache->setMultiple(array('foo' => new NotUnserializable())); foreach ($cache->getMultiple(array('foo')) as $value) { } $this->assertNull($value); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } if (!method_exists($this, 'isPruned')) { $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); } /** @var PruneableInterface|CacheInterface $cache */ $cache = $this->createSimpleCache(); $cache->set('foo', 'foo-val', new \DateInterval('PT05S')); $cache->set('bar', 'bar-val', new \DateInterval('PT10S')); $cache->set('baz', 'baz-val', new \DateInterval('PT15S')); $cache->set('qux', 'qux-val', new \DateInterval('PT20S')); sleep(30); $cache->prune(); $this->assertTrue($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'bar')); $this->assertTrue($this->isPruned($cache, 'baz')); $this->assertTrue($this->isPruned($cache, 'qux')); $cache->set('foo', 'foo-val'); $cache->set('bar', 'bar-val', new \DateInterval('PT20S')); $cache->set('baz', 'baz-val', new \DateInterval('PT40S')); $cache->set('qux', 'qux-val', new \DateInterval('PT80S')); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertFalse($this->isPruned($cache, 'bar')); $this->assertFalse($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'bar')); $this->assertFalse($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'baz')); $this->assertFalse($this->isPruned($cache, 'qux')); sleep(30); $cache->prune(); $this->assertFalse($this->isPruned($cache, 'foo')); $this->assertTrue($this->isPruned($cache, 'qux')); } } class NotUnserializable implements \Serializable { public function serialize() { return serialize(123); } public function unserialize($ser) { throw new \Exception(__CLASS__); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php000066400000000000000000000061331324732107100263050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Simple\ArrayCache; use Symfony\Component\Cache\Simple\ChainCache; use Symfony\Component\Cache\Simple\FilesystemCache; /** * @group time-sensitive */ class ChainCacheTest extends CacheTestCase { public function createSimpleCache($defaultLifetime = 0) { return new ChainCache(array(new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)), $defaultLifetime); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage At least one cache must be specified. */ public function testEmptyCachesException() { new ChainCache(array()); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage The class "stdClass" does not implement */ public function testInvalidCacheException() { new ChainCache(array(new \stdClass())); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = new ChainCache(array( $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), )); $this->assertTrue($cache->prune()); $cache = new ChainCache(array( $this->getPruneableMock(), $this->getFailingPruneableMock(), $this->getPruneableMock(), )); $this->assertFalse($cache->prune()); } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(true)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getFailingPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(false)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|CacheInterface */ private function getNonPruneableMock() { return $this ->getMockBuilder(CacheInterface::class) ->getMock(); } } interface PruneableCacheInterface extends PruneableInterface, CacheInterface { } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php000066400000000000000000000015131324732107100270270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Doctrine\Common\Cache\ArrayCache; use Symfony\Component\Cache\Simple\DoctrineCache; /** * @group time-sensitive */ class DoctrineCacheTest extends CacheTestCase { protected $skippedTests = array( 'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize', 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', ); public function createSimpleCache($defaultLifetime = 0) { return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php000066400000000000000000000015341324732107100274070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\FilesystemCache; /** * @group time-sensitive */ class FilesystemCacheTest extends CacheTestCase { public function createSimpleCache($defaultLifetime = 0) { return new FilesystemCache('', $defaultLifetime); } protected function isPruned(CacheInterface $cache, $name) { $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); $getFileMethod->setAccessible(true); return !file_exists($getFileMethod->invoke($cache, $name)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php000066400000000000000000000131441324732107100271310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Simple\MemcachedCache; class MemcachedCacheTest extends CacheTestCase { protected $skippedTests = array( 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ); protected static $client; public static function setupBeforeClass() { if (!MemcachedCache::isSupported()) { self::markTestSkipped('Extension memcached >=2.2.0 required.'); } self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')); self::$client->get('foo'); $code = self::$client->getResultCode(); if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); } } public function createSimpleCache($defaultLifetime = 0) { $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)) : self::$client; return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); } public function testOptions() { $client = MemcachedCache::createConnection(array(), array( 'libketama_compatible' => false, 'distribution' => 'modula', 'compression' => true, 'serializer' => 'php', 'hash' => 'md5', )); $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); } /** * @dataProvider provideBadOptions * @expectedException \ErrorException * @expectedExceptionMessage constant(): Couldn't find constant Memcached:: */ public function testBadOptions($name, $value) { MemcachedCache::createConnection(array(), array($name => $value)); } public function provideBadOptions() { return array( array('foo', 'bar'), array('hash', 'zyx'), array('serializer', 'zyx'), array('distribution', 'zyx'), ); } public function testDefaultOptions() { $this->assertTrue(MemcachedCache::isSupported()); $client = MemcachedCache::createConnection(array()); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); $this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); } /** * @expectedException \Symfony\Component\Cache\Exception\CacheException * @expectedExceptionMessage MemcachedAdapter: "serializer" option must be "php" or "igbinary". */ public function testOptionSerializer() { if (!\Memcached::HAVE_JSON) { $this->markTestSkipped('Memcached::HAVE_JSON required'); } new MemcachedCache(MemcachedCache::createConnection(array(), array('serializer' => 'json'))); } /** * @dataProvider provideServersSetting */ public function testServersSetting($dsn, $host, $port) { $client1 = MemcachedCache::createConnection($dsn); $client2 = MemcachedCache::createConnection(array($dsn)); $client3 = MemcachedCache::createConnection(array(array($host, $port))); $expect = array( 'host' => $host, 'port' => $port, ); $f = function ($s) { return array('host' => $s['host'], 'port' => $s['port']); }; $this->assertSame(array($expect), array_map($f, $client1->getServerList())); $this->assertSame(array($expect), array_map($f, $client2->getServerList())); $this->assertSame(array($expect), array_map($f, $client3->getServerList())); } public function provideServersSetting() { yield array( 'memcached://127.0.0.1/50', '127.0.0.1', 11211, ); yield array( 'memcached://localhost:11222?weight=25', 'localhost', 11222, ); if (ini_get('memcached.use_sasl')) { yield array( 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', 11211, ); } yield array( 'memcached:///var/run/memcached.sock?weight=25', '/var/run/memcached.sock', 0, ); yield array( 'memcached:///var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, ); if (ini_get('memcached.use_sasl')) { yield array( 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, ); } } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php000066400000000000000000000042651324732107100262010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Simple\NullCache; /** * @group time-sensitive */ class NullCacheTest extends TestCase { public function createCachePool() { return new NullCache(); } public function testGetItem() { $cache = $this->createCachePool(); $this->assertNull($cache->get('key')); } public function testHas() { $this->assertFalse($this->createCachePool()->has('key')); } public function testGetMultiple() { $cache = $this->createCachePool(); $keys = array('foo', 'bar', 'baz', 'biz'); $default = new \stdClass(); $items = $cache->getMultiple($keys, $default); $count = 0; foreach ($items as $key => $item) { $this->assertContains($key, $keys, 'Cache key can not change.'); $this->assertSame($default, $item); // Remove $key for $keys foreach ($keys as $k => $v) { if ($v === $key) { unset($keys[$k]); } } ++$count; } $this->assertSame(4, $count); } public function testClear() { $this->assertTrue($this->createCachePool()->clear()); } public function testDelete() { $this->assertTrue($this->createCachePool()->delete('key')); } public function testDeleteMultiple() { $this->assertTrue($this->createCachePool()->deleteMultiple(array('key', 'foo', 'bar'))); } public function testSet() { $cache = $this->createCachePool(); $this->assertFalse($cache->set('key', 'val')); $this->assertNull($cache->get('key')); } public function testSetMultiple() { $cache = $this->createCachePool(); $this->assertFalse($cache->setMultiple(array('key' => 'val'))); $this->assertNull($cache->get('key')); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php000066400000000000000000000021351324732107100260030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\PdoCache; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoCacheTest extends CacheTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoCache('sqlite:'.self::$dbFile); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createSimpleCache($defaultLifetime = 0) { return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php000066400000000000000000000023761324732107100265750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Doctrine\DBAL\DriverManager; use Symfony\Component\Cache\Simple\PdoCache; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoDbalCacheTest extends CacheTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoCache(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile))); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createSimpleCache($defaultLifetime = 0) { return new PdoCache(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile)), '', $defaultLifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php000066400000000000000000000114111324732107100270040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; use Symfony\Component\Cache\Simple\NullCache; use Symfony\Component\Cache\Simple\PhpArrayCache; /** * @group time-sensitive */ class PhpArrayCacheTest extends CacheTestCase { protected $skippedTests = array( 'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes', 'testDelete' => 'PhpArrayCache does no writes', 'testDeleteMultiple' => 'PhpArrayCache does no writes', 'testDeleteMultipleGenerator' => 'PhpArrayCache does no writes', 'testSetTtl' => 'PhpArrayCache does no expiration', 'testSetMultipleTtl' => 'PhpArrayCache does no expiration', 'testSetExpiredTtl' => 'PhpArrayCache does no expiration', 'testSetMultipleExpiredTtl' => 'PhpArrayCache does no expiration', 'testGetInvalidKeys' => 'PhpArrayCache does no validation', 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testSetInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testSetInvalidTtl' => 'PhpArrayCache does no validation', 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', 'testHasInvalidKeys' => 'PhpArrayCache does no validation', 'testSetValidData' => 'PhpArrayCache does no validation', 'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.', 'testPrune' => 'PhpArrayCache just proxies', ); protected static $file; public static function setupBeforeClass() { self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; } protected function tearDown() { if (file_exists(sys_get_temp_dir().'/symfony-cache')) { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } } public function createSimpleCache() { return new PhpArrayCacheWrapper(self::$file, new NullCache()); } public function testStore() { $arrayWithRefs = array(); $arrayWithRefs[0] = 123; $arrayWithRefs[1] = &$arrayWithRefs[0]; $object = (object) array( 'foo' => 'bar', 'foo2' => 'bar2', ); $expected = array( 'null' => null, 'serializedString' => serialize($object), 'arrayWithRefs' => $arrayWithRefs, 'object' => $object, 'arrayWithObject' => array('bar' => $object), ); $cache = new PhpArrayCache(self::$file, new NullCache()); $cache->warmUp($expected); foreach ($expected as $key => $value) { $this->assertSame(serialize($value), serialize($cache->get($key)), 'Warm up should create a PHP file that OPCache can load in memory'); } } public function testStoredFile() { $expected = array( 'integer' => 42, 'float' => 42.42, 'boolean' => true, 'array_simple' => array('foo', 'bar'), 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), ); $cache = new PhpArrayCache(self::$file, new NullCache()); $cache->warmUp($expected); $values = eval(substr(file_get_contents(self::$file), 6)); $this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory'); } } class PhpArrayCacheWrapper extends PhpArrayCache { public function set($key, $value, $ttl = null) { call_user_func(\Closure::bind(function () use ($key, $value) { $this->values[$key] = $value; $this->warmUp($this->values); $this->values = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayCache::class)); return true; } public function setMultiple($values, $ttl = null) { if (!is_array($values) && !$values instanceof \Traversable) { return parent::setMultiple($values, $ttl); } call_user_func(\Closure::bind(function () use ($values) { foreach ($values as $key => $value) { $this->values[$key] = $value; } $this->warmUp($this->values); $this->values = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayCache::class)); return true; } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php000066400000000000000000000035761324732107100312750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\FilesystemCache; use Symfony\Component\Cache\Simple\PhpArrayCache; use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; /** * @group time-sensitive */ class PhpArrayCacheWithFallbackTest extends CacheTestCase { protected $skippedTests = array( 'testGetInvalidKeys' => 'PhpArrayCache does no validation', 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', //'testSetValidData' => 'PhpArrayCache does no validation', 'testSetInvalidKeys' => 'PhpArrayCache does no validation', 'testSetInvalidTtl' => 'PhpArrayCache does no validation', 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', 'testHasInvalidKeys' => 'PhpArrayCache does no validation', 'testPrune' => 'PhpArrayCache just proxies', ); protected static $file; public static function setupBeforeClass() { self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; } protected function tearDown() { if (file_exists(sys_get_temp_dir().'/symfony-cache')) { FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); } } public function createSimpleCache($defaultLifetime = 0) { return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php000066400000000000000000000021071324732107100267720ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\PhpFilesCache; /** * @group time-sensitive */ class PhpFilesCacheTest extends CacheTestCase { protected $skippedTests = array( 'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.', ); public function createSimpleCache() { if (!PhpFilesCache::isSupported()) { $this->markTestSkipped('OPcache extension is not enabled.'); } return new PhpFilesCache('sf-cache'); } protected function isPruned(CacheInterface $cache, $name) { $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); $getFileMethod->setAccessible(true); return !file_exists($getFileMethod->invoke($cache, $name)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php000066400000000000000000000013051324732107100261110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Simple\Psr6Cache; /** * @group time-sensitive */ class Psr6CacheTest extends CacheTestCase { protected $skippedTests = array( 'testPrune' => 'Psr6Cache just proxies', ); public function createSimpleCache($defaultLifetime = 0) { return new Psr6Cache(new FilesystemAdapter('', $defaultLifetime)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php000066400000000000000000000012331324732107100273240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; class RedisArrayCacheTest extends AbstractRedisCacheTest { public static function setupBeforeClass() { parent::setupBeforeClass(); if (!class_exists('RedisArray')) { self::markTestSkipped('The RedisArray class is required.'); } self::$redis = new \RedisArray(array(getenv('REDIS_HOST')), array('lazy_connect' => true)); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php000066400000000000000000000047051324732107100263340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\RedisCache; class RedisCacheTest extends AbstractRedisCacheTest { public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST')); } public function testCreateConnection() { $redisHost = getenv('REDIS_HOST'); $redis = RedisCache::createConnection('redis://'.$redisHost); $this->assertInstanceOf(\Redis::class, $redis); $this->assertTrue($redis->isConnected()); $this->assertSame(0, $redis->getDbNum()); $redis = RedisCache::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); $redis = RedisCache::createConnection('redis://'.$redisHost, array('timeout' => 3)); $this->assertEquals(3, $redis->getTimeout()); $redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); $redis = RedisCache::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); $this->assertEquals(5, $redis->getReadTimeout()); } /** * @dataProvider provideFailedCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Redis connection failed */ public function testFailedCreateConnection($dsn) { RedisCache::createConnection($dsn); } public function provideFailedCreateConnection() { return array( array('redis://localhost:1234'), array('redis://foo@localhost'), array('redis://localhost/123'), ); } /** * @dataProvider provideInvalidCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid Redis DSN */ public function testInvalidCreateConnection($dsn) { RedisCache::createConnection($dsn); } public function provideInvalidCreateConnection() { return array( array('foo://localhost'), array('redis://'), ); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php000066400000000000000000000122111324732107100271370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Symfony\Component\Cache\Simple\FilesystemCache; use Symfony\Component\Cache\Simple\TraceableCache; /** * @group time-sensitive */ class TraceableCacheTest extends CacheTestCase { protected $skippedTests = array( 'testPrune' => 'TraceableCache just proxies', ); public function createSimpleCache($defaultLifetime = 0) { return new TraceableCache(new FilesystemCache('', $defaultLifetime)); } public function testGetMissTrace() { $pool = $this->createSimpleCache(); $pool->get('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('get', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testGetHitTrace() { $pool = $this->createSimpleCache(); $pool->set('k', 'foo'); $pool->get('k'); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame(1, $call->hits); $this->assertSame(0, $call->misses); } public function testGetMultipleMissTrace() { $pool = $this->createSimpleCache(); $pool->set('k1', 123); $values = $pool->getMultiple(array('k0', 'k1')); foreach ($values as $value) { } $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('getMultiple', $call->name); $this->assertSame(array('k1' => true, 'k0' => false), $call->result); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasMissTrace() { $pool = $this->createSimpleCache(); $pool->has('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('has', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasHitTrace() { $pool = $this->createSimpleCache(); $pool->set('k', 'foo'); $pool->has('k'); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('has', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteTrace() { $pool = $this->createSimpleCache(); $pool->delete('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('delete', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteMultipleTrace() { $pool = $this->createSimpleCache(); $arg = array('k0', 'k1'); $pool->deleteMultiple($arg); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteMultiple', $call->name); $this->assertSame(array('keys' => $arg, 'result' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testTraceSetTrace() { $pool = $this->createSimpleCache(); $pool->set('k', 'foo'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('set', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testSetMultipleTrace() { $pool = $this->createSimpleCache(); $pool->setMultiple(array('k' => 'foo')); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('setMultiple', $call->name); $this->assertSame(array('keys' => array('k'), 'result' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } } symfony-3.4.6/src/Symfony/Component/Cache/Tests/Traits/000077500000000000000000000000001324732107100230005ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php000066400000000000000000000017031324732107100270760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Traits; trait PdoPruneableTrait { protected function isPruned($cache, $name) { $o = new \ReflectionObject($cache); if (!$o->hasMethod('getConnection')) { self::fail('Cache does not have "getConnection()" method.'); } $getPdoConn = $o->getMethod('getConnection'); $getPdoConn->setAccessible(true); /** @var \Doctrine\DBAL\Statement $select */ $select = $getPdoConn->invoke($cache)->prepare('SELECT 1 FROM cache_items WHERE item_id LIKE :id'); $select->bindValue(':id', sprintf('%%%s', $name)); $select->execute(); return 0 === count($select->fetchAll(\PDO::FETCH_COLUMN)); } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/000077500000000000000000000000001324732107100216765ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Cache/Traits/AbstractTrait.php000066400000000000000000000161171324732107100251640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; /** * @author Nicolas Grekas * * @internal */ trait AbstractTrait { use LoggerAwareTrait; private $namespace; private $namespaceVersion = ''; private $versioningIsEnabled = false; private $deferred = array(); /** * @var int|null The maximum length to enforce for identifiers or null when no limit applies */ protected $maxIdLength; /** * Fetches several cache items. * * @param array $ids The cache identifiers to fetch * * @return array|\Traversable The corresponding values found in the cache */ abstract protected function doFetch(array $ids); /** * Confirms if the cache contains specified cache item. * * @param string $id The identifier for which to check existence * * @return bool True if item exists in the cache, false otherwise */ abstract protected function doHave($id); /** * Deletes all items in the pool. * * @param string The prefix used for all identifiers managed by this pool * * @return bool True if the pool was successfully cleared, false otherwise */ abstract protected function doClear($namespace); /** * Removes multiple items from the pool. * * @param array $ids An array of identifiers that should be removed from the pool * * @return bool True if the items were successfully removed, false otherwise */ abstract protected function doDelete(array $ids); /** * Persists several cache items immediately. * * @param array $values The values to cache, indexed by their cache identifier * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning * * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not */ abstract protected function doSave(array $values, $lifetime); /** * {@inheritdoc} */ public function hasItem($key) { $id = $this->getId($key); if (isset($this->deferred[$key])) { $this->commit(); } try { return $this->doHave($id); } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached', array('key' => $key, 'exception' => $e)); return false; } } /** * {@inheritdoc} */ public function clear() { if ($cleared = $this->versioningIsEnabled) { $this->namespaceVersion = 2; foreach ($this->doFetch(array('@'.$this->namespace)) as $v) { $this->namespaceVersion = 1 + (int) $v; } $this->namespaceVersion .= ':'; $cleared = $this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0); } $this->deferred = array(); try { return $this->doClear($this->namespace) || $cleared; } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to clear the cache', array('exception' => $e)); return false; } } /** * {@inheritdoc} */ public function deleteItem($key) { return $this->deleteItems(array($key)); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { $ids = array(); foreach ($keys as $key) { $ids[$key] = $this->getId($key); unset($this->deferred[$key]); } try { if ($this->doDelete($ids)) { return true; } } catch (\Exception $e) { } $ok = true; // When bulk-delete failed, retry each item individually foreach ($ids as $key => $id) { try { $e = null; if ($this->doDelete(array($id))) { continue; } } catch (\Exception $e) { } CacheItem::log($this->logger, 'Failed to delete key "{key}"', array('key' => $key, 'exception' => $e)); $ok = false; } return $ok; } /** * Enables/disables versioning of items. * * When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, * but old keys may need garbage collection and extra round-trips to the back-end are required. * * Calling this method also clears the memoized namespace version and thus forces a resynchonization of it. * * @param bool $enable * * @return bool the previous state of versioning */ public function enableVersioning($enable = true) { $wasEnabled = $this->versioningIsEnabled; $this->versioningIsEnabled = (bool) $enable; $this->namespaceVersion = ''; return $wasEnabled; } /** * {@inheritdoc} */ public function reset() { if ($this->deferred) { $this->commit(); } $this->namespaceVersion = ''; } /** * Like the native unserialize() function but throws an exception if anything goes wrong. * * @param string $value * * @return mixed * * @throws \Exception */ protected static function unserialize($value) { if ('b:0;' === $value) { return false; } $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); try { if (false !== $value = unserialize($value)) { return $value; } throw new \DomainException('Failed to unserialize cached value'); } catch (\Error $e) { throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } finally { ini_set('unserialize_callback_func', $unserializeCallbackHandler); } } private function getId($key) { CacheItem::validateKey($key); if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { $this->namespaceVersion = '1:'; foreach ($this->doFetch(array('@'.$this->namespace)) as $v) { $this->namespaceVersion = $v; } } if (null === $this->maxIdLength) { return $this->namespace.$this->namespaceVersion.$key; } if (strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) { $id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -22); } return $id; } /** * @internal */ public static function handleUnserializeCallback($class) { throw new \DomainException('Class not found: '.$class); } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/ApcuTrait.php000066400000000000000000000054201324732107100243040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\CacheException; /** * @author Nicolas Grekas * * @internal */ trait ApcuTrait { public static function isSupported() { return function_exists('apcu_fetch') && ini_get('apc.enabled'); } private function init($namespace, $defaultLifetime, $version) { if (!static::isSupported()) { throw new CacheException('APCu is not enabled'); } if ('cli' === PHP_SAPI) { ini_set('apc.use_request_time', 0); } parent::__construct($namespace, $defaultLifetime); if (null !== $version) { CacheItem::validateKey($version); if (!apcu_exists($version.'@'.$namespace)) { $this->doClear($namespace); apcu_add($version.'@'.$namespace, null); } } } /** * {@inheritdoc} */ protected function doFetch(array $ids) { try { foreach (apcu_fetch($ids, $ok) ?: array() as $k => $v) { if (null !== $v || $ok) { yield $k => $v; } } } catch (\Error $e) { throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } } /** * {@inheritdoc} */ protected function doHave($id) { return apcu_exists($id); } /** * {@inheritdoc} */ protected function doClear($namespace) { return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== PHP_SAPI || ini_get('apc.enable_cli')) ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY)) : apcu_clear_cache(); } /** * {@inheritdoc} */ protected function doDelete(array $ids) { foreach ($ids as $id) { apcu_delete($id); } return true; } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { try { if (false === $failures = apcu_store($values, null, $lifetime)) { $failures = $values; } return array_keys($failures); } catch (\Error $e) { } catch (\Exception $e) { } if (1 === count($values)) { // Workaround https://github.com/krakjoe/apcu/issues/170 apcu_delete(key($values)); } throw $e; } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/ArrayTrait.php000066400000000000000000000050211324732107100244670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; /** * @author Nicolas Grekas * * @internal */ trait ArrayTrait { use LoggerAwareTrait; private $storeSerialized; private $values = array(); private $expiries = array(); /** * Returns all cached values, with cache miss as null. * * @return array */ public function getValues() { return $this->values; } /** * {@inheritdoc} */ public function hasItem($key) { CacheItem::validateKey($key); return isset($this->expiries[$key]) && ($this->expiries[$key] >= time() || !$this->deleteItem($key)); } /** * {@inheritdoc} */ public function clear() { $this->values = $this->expiries = array(); return true; } /** * {@inheritdoc} */ public function deleteItem($key) { CacheItem::validateKey($key); unset($this->values[$key], $this->expiries[$key]); return true; } /** * {@inheritdoc} */ public function reset() { $this->clear(); } private function generateItems(array $keys, $now, $f) { foreach ($keys as $i => $key) { try { if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] >= $now || !$this->deleteItem($key))) { $this->values[$key] = $value = null; } elseif (!$this->storeSerialized) { $value = $this->values[$key]; } elseif ('b:0;' === $value = $this->values[$key]) { $value = false; } elseif (false === $value = unserialize($value)) { $this->values[$key] = $value = null; $isHit = false; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e)); $this->values[$key] = $value = null; $isHit = false; } unset($keys[$i]); yield $key => $f($key, $value, $isHit); } foreach ($keys as $key) { yield $key => $f($key, null, false); } } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/DoctrineTrait.php000066400000000000000000000043231324732107100251640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; /** * @author Nicolas Grekas * * @internal */ trait DoctrineTrait { private $provider; /** * {@inheritdoc} */ public function reset() { parent::reset(); $this->provider->setNamespace($this->provider->getNamespace()); } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $unserializeCallbackHandler = ini_set('unserialize_callback_func', parent::class.'::handleUnserializeCallback'); try { return $this->provider->fetchMultiple($ids); } catch (\Error $e) { $trace = $e->getTrace(); if (isset($trace[0]['function']) && !isset($trace[0]['class'])) { switch ($trace[0]['function']) { case 'unserialize': case 'apcu_fetch': case 'apc_fetch': throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } } throw $e; } finally { ini_set('unserialize_callback_func', $unserializeCallbackHandler); } } /** * {@inheritdoc} */ protected function doHave($id) { return $this->provider->contains($id); } /** * {@inheritdoc} */ protected function doClear($namespace) { $namespace = $this->provider->getNamespace(); return isset($namespace[0]) ? $this->provider->deleteAll() : $this->provider->flushAll(); } /** * {@inheritdoc} */ protected function doDelete(array $ids) { $ok = true; foreach ($ids as $id) { $ok = $this->provider->delete($id) && $ok; } return $ok; } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { return $this->provider->saveMultiple($values, $lifetime); } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php000066400000000000000000000067161324732107100267220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Nicolas Grekas * * @internal */ trait FilesystemCommonTrait { private $directory; private $tmp; private function init($namespace, $directory) { if (!isset($directory[0])) { $directory = sys_get_temp_dir().'/symfony-cache'; } else { $directory = realpath($directory) ?: $directory; } if (isset($namespace[0])) { if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) { throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0])); } $directory .= DIRECTORY_SEPARATOR.$namespace; } if (!file_exists($directory)) { @mkdir($directory, 0777, true); } $directory .= DIRECTORY_SEPARATOR; // On Windows the whole path is limited to 258 chars if ('\\' === DIRECTORY_SEPARATOR && strlen($directory) > 234) { throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory)); } $this->directory = $directory; } /** * {@inheritdoc} */ protected function doClear($namespace) { $ok = true; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS)) as $file) { $ok = ($file->isDir() || @unlink($file) || !file_exists($file)) && $ok; } return $ok; } /** * {@inheritdoc} */ protected function doDelete(array $ids) { $ok = true; foreach ($ids as $id) { $file = $this->getFile($id); $ok = (!file_exists($file) || @unlink($file) || !file_exists($file)) && $ok; } return $ok; } private function write($file, $data, $expiresAt = null) { set_error_handler(__CLASS__.'::throwError'); try { if (null === $this->tmp) { $this->tmp = $this->directory.uniqid('', true); } file_put_contents($this->tmp, $data); if (null !== $expiresAt) { touch($this->tmp, $expiresAt); } return rename($this->tmp, $file); } finally { restore_error_handler(); } } private function getFile($id, $mkdir = false) { $hash = str_replace('/', '-', base64_encode(hash('sha256', static::class.$id, true))); $dir = $this->directory.strtoupper($hash[0].DIRECTORY_SEPARATOR.$hash[1].DIRECTORY_SEPARATOR); if ($mkdir && !file_exists($dir)) { @mkdir($dir, 0777, true); } return $dir.substr($hash, 2, 20); } /** * @internal */ public static function throwError($type, $message, $file, $line) { throw new \ErrorException($message, 0, $type, $file, $line); } public function __destruct() { if (method_exists(parent::class, '__destruct')) { parent::__destruct(); } if (null !== $this->tmp && file_exists($this->tmp)) { unlink($this->tmp); } } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/FilesystemTrait.php000066400000000000000000000052551324732107100255460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\Exception\CacheException; /** * @author Nicolas Grekas * @author Rob Frawley 2nd * * @internal */ trait FilesystemTrait { use FilesystemCommonTrait; /** * @return bool */ public function prune() { $time = time(); $pruned = true; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { if (!$h = @fopen($file, 'rb')) { continue; } if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) { fclose($h); $pruned = @unlink($file) && !file_exists($file) && $pruned; } else { fclose($h); } } return $pruned; } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $values = array(); $now = time(); foreach ($ids as $id) { $file = $this->getFile($id); if (!file_exists($file) || !$h = @fopen($file, 'rb')) { continue; } if (($expiresAt = (int) fgets($h)) && $now >= $expiresAt) { fclose($h); @unlink($file); } else { $i = rawurldecode(rtrim(fgets($h))); $value = stream_get_contents($h); fclose($h); if ($i === $id) { $values[$id] = parent::unserialize($value); } } } return $values; } /** * {@inheritdoc} */ protected function doHave($id) { $file = $this->getFile($id); return file_exists($file) && (@filemtime($file) > time() || $this->doFetch(array($id))); } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { $ok = true; $expiresAt = $lifetime ? (time() + $lifetime) : 0; foreach ($values as $id => $value) { $ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok; } if (!$ok && !is_writable($this->directory)) { throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); } return $ok; } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/MemcachedTrait.php000066400000000000000000000241341324732107100252650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Rob Frawley 2nd * @author Nicolas Grekas * * @internal */ trait MemcachedTrait { private static $defaultClientOptions = array( 'persistent_id' => null, 'username' => null, 'password' => null, 'serializer' => 'php', ); private $client; private $lazyClient; public static function isSupported() { return extension_loaded('memcached') && version_compare(phpversion('memcached'), '2.2.0', '>='); } private function init(\Memcached $client, $namespace, $defaultLifetime) { if (!static::isSupported()) { throw new CacheException('Memcached >= 2.2.0 is required'); } if ('Memcached' === get_class($client)) { $opt = $client->getOption(\Memcached::OPT_SERIALIZER); if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); } $this->maxIdLength -= strlen($client->getOption(\Memcached::OPT_PREFIX_KEY)); $this->client = $client; } else { $this->lazyClient = $client; } parent::__construct($namespace, $defaultLifetime); $this->enableVersioning(); } /** * Creates a Memcached instance. * * By default, the binary protocol, no block, and libketama compatible options are enabled. * * Examples for servers: * - 'memcached://user:pass@localhost?weight=33' * - array(array('localhost', 11211, 33)) * * @param array[]|string|string[] An array of servers, a DSN, or an array of DSNs * @param array An array of options * * @return \Memcached * * @throws \ErrorException When invalid options or servers are provided */ public static function createConnection($servers, array $options = array()) { if (is_string($servers)) { $servers = array($servers); } elseif (!is_array($servers)) { throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', gettype($servers))); } if (!static::isSupported()) { throw new CacheException('Memcached >= 2.2.0 is required'); } set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); try { $options += static::$defaultClientOptions; $client = new \Memcached($options['persistent_id']); $username = $options['username']; $password = $options['password']; // parse any DSN in $servers foreach ($servers as $i => $dsn) { if (is_array($dsn)) { continue; } if (0 !== strpos($dsn, 'memcached://')) { throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached://"', $dsn)); } $params = preg_replace_callback('#^memcached://(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) { if (!empty($m[1])) { list($username, $password) = explode(':', $m[1], 2) + array(1 => null); } return 'file://'; }, $dsn); if (false === $params = parse_url($params)) { throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); } if (!isset($params['host']) && !isset($params['path'])) { throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); } if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) { $params['weight'] = $m[1]; $params['path'] = substr($params['path'], 0, -strlen($m[0])); } $params += array( 'host' => isset($params['host']) ? $params['host'] : $params['path'], 'port' => isset($params['host']) ? 11211 : null, 'weight' => 0, ); if (isset($params['query'])) { parse_str($params['query'], $query); $params += $query; $options = $query + $options; } $servers[$i] = array($params['host'], $params['port'], $params['weight']); } // set client's options unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']); $options = array_change_key_case($options, CASE_UPPER); $client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); $client->setOption(\Memcached::OPT_NO_BLOCK, true); if (!array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) { $client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true); } foreach ($options as $name => $value) { if (is_int($name)) { continue; } if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) { $value = constant('Memcached::'.$name.'_'.strtoupper($value)); } $opt = constant('Memcached::OPT_'.$name); unset($options[$name]); $options[$opt] = $value; } $client->setOptions($options); // set client's servers, taking care of persistent connections if (!$client->isPristine()) { $oldServers = array(); foreach ($client->getServerList() as $server) { $oldServers[] = array($server['host'], $server['port']); } $newServers = array(); foreach ($servers as $server) { if (1 < count($server)) { $server = array_values($server); unset($server[2]); $server[1] = (int) $server[1]; } $newServers[] = $server; } if ($oldServers !== $newServers) { // before resetting, ensure $servers is valid $client->addServers($servers); $client->resetServerList(); } } $client->addServers($servers); if (null !== $username || null !== $password) { if (!method_exists($client, 'setSaslAuthData')) { trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.'); } $client->setSaslAuthData($username, $password); } return $client; } finally { restore_error_handler(); } } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { if ($lifetime && $lifetime > 30 * 86400) { $lifetime += time(); } return $this->checkResultCode($this->getClient()->setMulti($values, $lifetime)); } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); try { return $this->checkResultCode($this->getClient()->getMulti($ids)); } catch (\Error $e) { throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } finally { ini_set('unserialize_callback_func', $unserializeCallbackHandler); } } /** * {@inheritdoc} */ protected function doHave($id) { return false !== $this->getClient()->get($id) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode()); } /** * {@inheritdoc} */ protected function doDelete(array $ids) { $ok = true; foreach ($this->checkResultCode($this->getClient()->deleteMulti($ids)) as $result) { if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) { $ok = false; } } return $ok; } /** * {@inheritdoc} */ protected function doClear($namespace) { return false; } private function checkResultCode($result) { $code = $this->client->getResultCode(); if (\Memcached::RES_SUCCESS === $code || \Memcached::RES_NOTFOUND === $code) { return $result; } throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage()))); } /** * @return \Memcached */ private function getClient() { if ($this->client) { return $this->client; } $opt = $this->lazyClient->getOption(\Memcached::OPT_SERIALIZER); if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); } if ('' !== $prefix = (string) $this->lazyClient->getOption(\Memcached::OPT_PREFIX_KEY)) { throw new CacheException(sprintf('MemcachedAdapter: "prefix_key" option must be empty when using proxified connections, "%s" given.', $prefix)); } return $this->client = $this->lazyClient; } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/PdoTrait.php000066400000000000000000000377261324732107100241540ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Schema; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @internal */ trait PdoTrait { private $conn; private $dsn; private $driver; private $serverVersion; private $table = 'cache_items'; private $idCol = 'item_id'; private $dataCol = 'item_data'; private $lifetimeCol = 'item_lifetime'; private $timeCol = 'item_time'; private $username = ''; private $password = ''; private $connectionOptions = array(); private $namespace; private function init($connOrDsn, $namespace, $defaultLifetime, array $options) { if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) { throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0])); } if ($connOrDsn instanceof \PDO) { if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { throw new InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); } $this->conn = $connOrDsn; } elseif ($connOrDsn instanceof Connection) { $this->conn = $connOrDsn; } elseif (is_string($connOrDsn)) { $this->dsn = $connOrDsn; } else { throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, is_object($connOrDsn) ? get_class($connOrDsn) : gettype($connOrDsn))); } $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol; $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol; $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol; $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol; $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username; $this->password = isset($options['db_password']) ? $options['db_password'] : $this->password; $this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions; $this->namespace = $namespace; parent::__construct($namespace, $defaultLifetime); } /** * Creates the table to store cache items which can be called once for setup. * * Cache ID are saved in a column of maximum length 255. Cache data is * saved in a BLOB. * * @throws \PDOException When the table already exists * @throws DBALException When the table already exists * @throws \DomainException When an unsupported PDO driver is used */ public function createTable() { // connect if we are not yet $conn = $this->getConnection(); if ($conn instanceof Connection) { $types = array( 'mysql' => 'binary', 'sqlite' => 'text', 'pgsql' => 'string', 'oci' => 'string', 'sqlsrv' => 'string', ); if (!isset($types[$this->driver])) { throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); } $schema = new Schema(); $table = $schema->createTable($this->table); $table->addColumn($this->idCol, $types[$this->driver], array('length' => 255)); $table->addColumn($this->dataCol, 'blob', array('length' => 16777215)); $table->addColumn($this->lifetimeCol, 'integer', array('unsigned' => true, 'notnull' => false)); $table->addColumn($this->timeCol, 'integer', array('unsigned' => true)); $table->setPrimaryKey(array($this->idCol)); foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { $conn->exec($sql); } return; } switch ($this->driver) { case 'mysql': // We use varbinary for the ID column because it prevents unwanted conversions: // - character set conversions between server and client // - trailing space removal // - case-insensitivity // - language processing like é == e $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(255) NOT NULL PRIMARY KEY, $this->dataCol MEDIUMBLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB"; break; case 'sqlite': $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; break; case 'pgsql': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; break; case 'oci': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; break; case 'sqlsrv': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; break; default: throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); } $conn->exec($sql); } /** * {@inheritdoc} */ public function prune() { $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= :time"; if ('' !== $this->namespace) { $deleteSql .= " AND $this->idCol LIKE :namespace"; } $delete = $this->getConnection()->prepare($deleteSql); $delete->bindValue(':time', time(), \PDO::PARAM_INT); if ('' !== $this->namespace) { $delete->bindValue(':namespace', sprintf('%s%%', $this->namespace), \PDO::PARAM_STR); } return $delete->execute(); } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $now = time(); $expired = array(); $sql = str_pad('', (count($ids) << 1) - 1, '?,'); $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN ($sql)"; $stmt = $this->getConnection()->prepare($sql); $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); foreach ($ids as $id) { $stmt->bindValue(++$i, $id); } $stmt->execute(); while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { if (null === $row[1]) { $expired[] = $row[0]; } else { yield $row[0] => parent::unserialize(is_resource($row[1]) ? stream_get_contents($row[1]) : $row[1]); } } if ($expired) { $sql = str_pad('', (count($expired) << 1) - 1, '?,'); $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ? AND $this->idCol IN ($sql)"; $stmt = $this->getConnection()->prepare($sql); $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); foreach ($expired as $id) { $stmt->bindValue(++$i, $id); } $stmt->execute(); } } /** * {@inheritdoc} */ protected function doHave($id) { $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)"; $stmt = $this->getConnection()->prepare($sql); $stmt->bindValue(':id', $id); $stmt->bindValue(':time', time(), \PDO::PARAM_INT); $stmt->execute(); return (bool) $stmt->fetchColumn(); } /** * {@inheritdoc} */ protected function doClear($namespace) { $conn = $this->getConnection(); if ('' === $namespace) { if ('sqlite' === $this->driver) { $sql = "DELETE FROM $this->table"; } else { $sql = "TRUNCATE TABLE $this->table"; } } else { $sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'"; } $conn->exec($sql); return true; } /** * {@inheritdoc} */ protected function doDelete(array $ids) { $sql = str_pad('', (count($ids) << 1) - 1, '?,'); $sql = "DELETE FROM $this->table WHERE $this->idCol IN ($sql)"; $stmt = $this->getConnection()->prepare($sql); $stmt->execute(array_values($ids)); return true; } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { $serialized = array(); $failed = array(); foreach ($values as $id => $value) { try { $serialized[$id] = serialize($value); } catch (\Exception $e) { $failed[] = $id; } } if (!$serialized) { return $failed; } $conn = $this->getConnection(); $driver = $this->driver; $insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; switch (true) { case 'mysql' === $driver: $sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; break; case 'oci' === $driver: // DUAL is Oracle specific dummy table $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?"; break; case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx $sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; break; case 'sqlite' === $driver: $sql = 'INSERT OR REPLACE'.substr($insertSql, 6); break; case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='): $sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; break; default: $driver = null; $sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"; break; } $now = time(); $lifetime = $lifetime ?: null; $stmt = $conn->prepare($sql); if ('sqlsrv' === $driver || 'oci' === $driver) { $stmt->bindParam(1, $id); $stmt->bindParam(2, $id); $stmt->bindParam(3, $data, \PDO::PARAM_LOB); $stmt->bindValue(4, $lifetime, \PDO::PARAM_INT); $stmt->bindValue(5, $now, \PDO::PARAM_INT); $stmt->bindParam(6, $data, \PDO::PARAM_LOB); $stmt->bindValue(7, $lifetime, \PDO::PARAM_INT); $stmt->bindValue(8, $now, \PDO::PARAM_INT); } else { $stmt->bindParam(':id', $id); $stmt->bindParam(':data', $data, \PDO::PARAM_LOB); $stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); $stmt->bindValue(':time', $now, \PDO::PARAM_INT); } if (null === $driver) { $insertStmt = $conn->prepare($insertSql); $insertStmt->bindParam(':id', $id); $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); $insertStmt->bindValue(':time', $now, \PDO::PARAM_INT); } foreach ($serialized as $id => $data) { $stmt->execute(); if (null === $driver && !$stmt->rowCount()) { try { $insertStmt->execute(); } catch (DBALException $e) { } catch (\PDOException $e) { // A concurrent write won, let it be } } } return $failed; } /** * @return \PDO|Connection */ private function getConnection() { if (null === $this->conn) { $this->conn = new \PDO($this->dsn, $this->username, $this->password, $this->connectionOptions); $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } if (null === $this->driver) { if ($this->conn instanceof \PDO) { $this->driver = $this->conn->getAttribute(\PDO::ATTR_DRIVER_NAME); } else { switch ($this->driver = $this->conn->getDriver()->getName()) { case 'mysqli': case 'pdo_mysql': case 'drizzle_pdo_mysql': $this->driver = 'mysql'; break; case 'pdo_sqlite': $this->driver = 'sqlite'; break; case 'pdo_pgsql': $this->driver = 'pgsql'; break; case 'oci8': case 'pdo_oracle': $this->driver = 'oci'; break; case 'pdo_sqlsrv': $this->driver = 'sqlsrv'; break; } } } return $this->conn; } /** * @return string */ private function getServerVersion() { if (null === $this->serverVersion) { $conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection(); if ($conn instanceof \PDO) { $this->serverVersion = $conn->getAttribute(\PDO::ATTR_SERVER_VERSION); } elseif ($conn instanceof ServerInfoAwareConnection) { $this->serverVersion = $conn->getServerVersion(); } else { $this->serverVersion = '0'; } } return $this->serverVersion; } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php000066400000000000000000000105631324732107100251460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Titouan Galopin * @author Nicolas Grekas * * @internal */ trait PhpArrayTrait { use ProxyTrait; private $file; private $values; private $zendDetectUnicode; /** * Store an array of cached values. * * @param array $values The cached values */ public function warmUp(array $values) { if (file_exists($this->file)) { if (!is_file($this->file)) { throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: %s.', $this->file)); } if (!is_writable($this->file)) { throw new InvalidArgumentException(sprintf('Cache file is not writable: %s.', $this->file)); } } else { $directory = dirname($this->file); if (!is_dir($directory) && !@mkdir($directory, 0777, true)) { throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: %s.', $directory)); } if (!is_writable($directory)) { throw new InvalidArgumentException(sprintf('Cache directory is not writable: %s.', $directory)); } } $dump = <<<'EOF' $value) { CacheItem::validateKey(is_int($key) ? (string) $key : $key); if (null === $value || is_object($value)) { try { $value = serialize($value); } catch (\Exception $e) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, get_class($value)), 0, $e); } } elseif (is_array($value)) { try { $serialized = serialize($value); $unserialized = unserialize($serialized); } catch (\Exception $e) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable array value.', $key), 0, $e); } // Store arrays serialized if they contain any objects or references if ($unserialized !== $value || (false !== strpos($serialized, ';R:') && preg_match('/;R:[1-9]/', $serialized))) { $value = $serialized; } } elseif (is_string($value)) { // Serialize strings if they could be confused with serialized objects or arrays if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { $value = serialize($value); } } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, gettype($value))); } $dump .= var_export($key, true).' => '.var_export($value, true).",\n"; } $dump .= "\n);\n"; $dump = str_replace("' . \"\\0\" . '", "\0", $dump); $tmpFile = uniqid($this->file, true); file_put_contents($tmpFile, $dump); @chmod($tmpFile, 0666 & ~umask()); unset($serialized, $unserialized, $value, $dump); @rename($tmpFile, $this->file); $this->initialize(); } /** * {@inheritdoc} */ public function clear() { $this->values = array(); $cleared = @unlink($this->file) || !file_exists($this->file); return $this->pool->clear() && $cleared; } /** * Load the cache file. */ private function initialize() { if ($this->zendDetectUnicode) { $zmb = ini_set('zend.detect_unicode', 0); } try { $this->values = file_exists($this->file) ? (include $this->file ?: array()) : array(); } finally { if ($this->zendDetectUnicode) { ini_set('zend.detect_unicode', $zmb); } } } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php000066400000000000000000000113161324732107100251270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Piotr Stankowski * @author Nicolas Grekas * @author Rob Frawley 2nd * * @internal */ trait PhpFilesTrait { use FilesystemCommonTrait; private $includeHandler; private $zendDetectUnicode; public static function isSupported() { return function_exists('opcache_invalidate') && ini_get('opcache.enable'); } /** * @return bool */ public function prune() { $time = time(); $pruned = true; $allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli'); set_error_handler($this->includeHandler); try { foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { list($expiresAt) = include $file; if ($time >= $expiresAt) { $pruned = @unlink($file) && !file_exists($file) && $pruned; if ($allowCompile) { @opcache_invalidate($file, true); } } } } finally { restore_error_handler(); } return $pruned; } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $values = array(); $now = time(); if ($this->zendDetectUnicode) { $zmb = ini_set('zend.detect_unicode', 0); } set_error_handler($this->includeHandler); try { foreach ($ids as $id) { try { $file = $this->getFile($id); list($expiresAt, $values[$id]) = include $file; if ($now >= $expiresAt) { unset($values[$id]); } } catch (\Exception $e) { continue; } } } finally { restore_error_handler(); if ($this->zendDetectUnicode) { ini_set('zend.detect_unicode', $zmb); } } foreach ($values as $id => $value) { if ('N;' === $value) { $values[$id] = null; } elseif (is_string($value) && isset($value[2]) && ':' === $value[1]) { $values[$id] = parent::unserialize($value); } } return $values; } /** * {@inheritdoc} */ protected function doHave($id) { return (bool) $this->doFetch(array($id)); } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { $ok = true; $data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, ''); $allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli'); foreach ($values as $key => $value) { if (null === $value || is_object($value)) { $value = serialize($value); } elseif (is_array($value)) { $serialized = serialize($value); $unserialized = parent::unserialize($serialized); // Store arrays serialized if they contain any objects or references if ($unserialized !== $value || (false !== strpos($serialized, ';R:') && preg_match('/;R:[1-9]/', $serialized))) { $value = $serialized; } } elseif (is_string($value)) { // Serialize strings if they could be confused with serialized objects or arrays if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { $value = serialize($value); } } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, gettype($value))); } $data[1] = $value; $file = $this->getFile($key, true); $ok = $this->write($file, 'directory)) { throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); } return $ok; } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/ProxyTrait.php000066400000000000000000000014511324732107100245350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; /** * @author Nicolas Grekas */ trait ProxyTrait { private $pool; /** * {@inheritdoc} */ public function prune() { return $this->pool instanceof PruneableInterface && $this->pool->prune(); } /** * {@inheritdoc} */ public function reset() { if ($this->pool instanceof ResettableInterface) { $this->pool->reset(); } } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/RedisProxy.php000066400000000000000000000034601324732107100245220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; /** * @author Nicolas Grekas * * @internal */ class RedisProxy { private $redis; private $initializer; private $ready = false; public function __construct(\Redis $redis, \Closure $initializer) { $this->redis = $redis; $this->initializer = $initializer; } public function __call($method, array $args) { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); return \call_user_func_array(array($this->redis, $method), $args); } public function hscan($strKey, &$iIterator, $strPattern = null, $iCount = null) { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); return $this->redis->hscan($strKey, $iIterator, $strPattern, $iCount); } public function scan(&$iIterator, $strPattern = null, $iCount = null) { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); return $this->redis->scan($iIterator, $strPattern, $iCount); } public function sscan($strKey, &$iIterator, $strPattern = null, $iCount = null) { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); return $this->redis->sscan($strKey, $iIterator, $strPattern, $iCount); } public function zscan($strKey, &$iIterator, $strPattern = null, $iCount = null) { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); return $this->redis->zscan($strKey, $iIterator, $strPattern, $iCount); } } symfony-3.4.6/src/Symfony/Component/Cache/Traits/RedisTrait.php000066400000000000000000000322041324732107100244620ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Predis\Connection\Factory; use Predis\Connection\Aggregate\ClusterInterface; use Predis\Connection\Aggregate\PredisCluster; use Predis\Connection\Aggregate\RedisCluster; use Predis\Response\Status; use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** * @author Aurimas Niekis * @author Nicolas Grekas * * @internal */ trait RedisTrait { private static $defaultConnectionOptions = array( 'class' => null, 'persistent' => 0, 'persistent_id' => null, 'timeout' => 30, 'read_timeout' => 0, 'retry_interval' => 0, 'lazy' => false, ); private $redis; /** * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient */ public function init($redisClient, $namespace = '', $defaultLifetime = 0) { parent::__construct($namespace, $defaultLifetime); if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) { throw new InvalidArgumentException(sprintf('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0])); } if ($redisClient instanceof \RedisCluster) { $this->enableVersioning(); } elseif (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) { throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, is_object($redisClient) ? get_class($redisClient) : gettype($redisClient))); } $this->redis = $redisClient; } /** * Creates a Redis connection using a DSN configuration. * * Example DSN: * - redis://localhost * - redis://example.com:1234 * - redis://secret@example.com/13 * - redis:///var/run/redis.sock * - redis://secret@/var/run/redis.sock/13 * * @param string $dsn * @param array $options See self::$defaultConnectionOptions * * @throws InvalidArgumentException when the DSN is invalid * * @return \Redis|\Predis\Client According to the "class" option */ public static function createConnection($dsn, array $options = array()) { if (0 !== strpos($dsn, 'redis://')) { throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s does not start with "redis://"', $dsn)); } $params = preg_replace_callback('#^redis://(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) { if (isset($m[1])) { $auth = $m[1]; } return 'file://'; }, $dsn); if (false === $params = parse_url($params)) { throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s', $dsn)); } if (!isset($params['host']) && !isset($params['path'])) { throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s', $dsn)); } if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) { $params['dbindex'] = $m[1]; $params['path'] = substr($params['path'], 0, -strlen($m[0])); } if (isset($params['host'])) { $scheme = 'tcp'; } else { $scheme = 'unix'; } $params += array( 'host' => isset($params['host']) ? $params['host'] : $params['path'], 'port' => isset($params['host']) ? 6379 : null, 'dbindex' => 0, ); if (isset($params['query'])) { parse_str($params['query'], $query); $params += $query; } $params += $options + self::$defaultConnectionOptions; if (null === $params['class'] && !extension_loaded('redis') && !class_exists(\Predis\Client::class)) { throw new CacheException(sprintf('Cannot find the "redis" extension, and "predis/predis" is not installed: %s', $dsn)); } $class = null === $params['class'] ? (extension_loaded('redis') ? \Redis::class : \Predis\Client::class) : $params['class']; if (is_a($class, \Redis::class, true)) { $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect'; $redis = new $class(); $initializer = function ($redis) use ($connect, $params, $dsn, $auth) { @$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']); if (@!$redis->isConnected()) { $e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : ''; throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn)); } if ((null !== $auth && !$redis->auth($auth)) || ($params['dbindex'] && !$redis->select($params['dbindex'])) || ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout'])) ) { $e = preg_replace('/^ERR /', '', $redis->getLastError()); throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e, $dsn)); } return true; }; if ($params['lazy']) { $redis = new RedisProxy($redis, $initializer); } else { $initializer($redis); } } elseif (is_a($class, \Predis\Client::class, true)) { $params['scheme'] = $scheme; $params['database'] = $params['dbindex'] ?: null; $params['password'] = $auth; $redis = new $class((new Factory())->create($params)); } elseif (class_exists($class, false)) { throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis" or "Predis\Client"', $class)); } else { throw new InvalidArgumentException(sprintf('Class "%s" does not exist', $class)); } return $redis; } /** * {@inheritdoc} */ protected function doFetch(array $ids) { if ($ids) { $values = $this->pipeline(function () use ($ids) { foreach ($ids as $id) { yield 'get' => array($id); } }); foreach ($values as $id => $v) { if ($v) { yield $id => parent::unserialize($v); } } } } /** * {@inheritdoc} */ protected function doHave($id) { return (bool) $this->redis->exists($id); } /** * {@inheritdoc} */ protected function doClear($namespace) { // When using a native Redis cluster, clearing the cache is done by versioning in AbstractTrait::clear(). // This means old keys are not really removed until they expire and may need gargage collection. $cleared = true; $hosts = array($this->redis); $evalArgs = array(array($namespace), 0); if ($this->redis instanceof \Predis\Client) { $evalArgs = array(0, $namespace); $connection = $this->redis->getConnection(); if ($connection instanceof PredisCluster) { $hosts = array(); foreach ($connection as $c) { $hosts[] = new \Predis\Client($c); } } elseif ($connection instanceof RedisCluster) { return false; } } elseif ($this->redis instanceof \RedisArray) { $hosts = array(); foreach ($this->redis->_hosts() as $host) { $hosts[] = $this->redis->_instance($host); } } elseif ($this->redis instanceof \RedisCluster) { return false; } foreach ($hosts as $host) { if (!isset($namespace[0])) { $cleared = $host->flushDb() && $cleared; continue; } $info = $host->info('Server'); $info = isset($info['Server']) ? $info['Server'] : $info; if (!version_compare($info['redis_version'], '2.8', '>=')) { // As documented in Redis documentation (http://redis.io/commands/keys) using KEYS // can hang your server when it is executed against large databases (millions of items). // Whenever you hit this scale, you should really consider upgrading to Redis 2.8 or above. $cleared = $host->eval("local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end return 1", $evalArgs[0], $evalArgs[1]) && $cleared; continue; } $cursor = null; do { $keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000); if (isset($keys[1]) && is_array($keys[1])) { $cursor = $keys[0]; $keys = $keys[1]; } if ($keys) { $host->del($keys); } } while ($cursor = (int) $cursor); } return $cleared; } /** * {@inheritdoc} */ protected function doDelete(array $ids) { if ($ids) { $this->redis->del($ids); } return true; } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { $serialized = array(); $failed = array(); foreach ($values as $id => $value) { try { $serialized[$id] = serialize($value); } catch (\Exception $e) { $failed[] = $id; } } if (!$serialized) { return $failed; } $results = $this->pipeline(function () use ($serialized, $lifetime) { foreach ($serialized as $id => $value) { if (0 >= $lifetime) { yield 'set' => array($id, $value); } else { yield 'setEx' => array($id, $lifetime, $value); } } }); foreach ($results as $id => $result) { if (true !== $result && (!$result instanceof Status || $result !== Status::get('OK'))) { $failed[] = $id; } } return $failed; } private function pipeline(\Closure $generator) { $ids = array(); if ($this->redis instanceof \Predis\Client && !$this->redis->getConnection() instanceof ClusterInterface) { $results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) { foreach ($generator() as $command => $args) { call_user_func_array(array($redis, $command), $args); $ids[] = $args[0]; } }); } elseif ($this->redis instanceof \RedisArray) { $connections = $results = $ids = array(); foreach ($generator() as $command => $args) { if (!isset($connections[$h = $this->redis->_target($args[0])])) { $connections[$h] = array($this->redis->_instance($h), -1); $connections[$h][0]->multi(\Redis::PIPELINE); } call_user_func_array(array($connections[$h][0], $command), $args); $results[] = array($h, ++$connections[$h][1]); $ids[] = $args[0]; } foreach ($connections as $h => $c) { $connections[$h] = $c[0]->exec(); } foreach ($results as $k => list($h, $c)) { $results[$k] = $connections[$h][$c]; } } elseif ($this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface)) { // phpredis & predis don't support pipelining with RedisCluster // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining // see https://github.com/nrk/predis/issues/267#issuecomment-123781423 $results = array(); foreach ($generator() as $command => $args) { $results[] = call_user_func_array(array($this->redis, $command), $args); $ids[] = $args[0]; } } else { $this->redis->multi(\Redis::PIPELINE); foreach ($generator() as $command => $args) { call_user_func_array(array($this->redis, $command), $args); $ids[] = $args[0]; } $results = $this->redis->exec(); } foreach ($ids as $k => $id) { yield $id => $results[$k]; } } } symfony-3.4.6/src/Symfony/Component/Cache/composer.json000066400000000000000000000024051324732107100231530ustar00rootroot00000000000000{ "name": "symfony/cache", "type": "library", "description": "Symfony Cache component with PSR-6, PSR-16, and tags", "keywords": ["caching", "psr6"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Nicolas Grekas", "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "provide": { "psr/cache-implementation": "1.0", "psr/simple-cache-implementation": "1.0" }, "require": { "php": "^5.5.9|>=7.0.8", "psr/cache": "~1.0", "psr/log": "~1.0", "psr/simple-cache": "^1.0", "symfony/polyfill-apcu": "~1.1" }, "require-dev": { "cache/integration-tests": "dev-master", "doctrine/cache": "~1.6", "doctrine/dbal": "~2.4", "predis/predis": "~1.0" }, "conflict": { "symfony/var-dumper": "<3.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Cache\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Component/Cache/phpunit.xml.dist000066400000000000000000000032021324732107100236000ustar00rootroot00000000000000 ./Tests/ ./ ./Tests ./vendor Cache\IntegrationTests Doctrine\Common\Cache Symfony\Component\Cache Symfony\Component\Cache\Traits symfony-3.4.6/src/Symfony/Component/ClassLoader/000077500000000000000000000000001324732107100216215ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/.gitignore000066400000000000000000000000421324732107100236050ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Component/ClassLoader/ApcClassLoader.php000066400000000000000000000101771324732107100251600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED); /** * ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This * allows using it as a wrapper around the other loaders of the component (the * ClassLoader for instance) but also around any other autoloaders following * this convention (the Composer one for instance). * * // with a Symfony autoloader * use Symfony\Component\ClassLoader\ClassLoader; * * $loader = new ClassLoader(); * $loader->addPrefix('Symfony\Component', __DIR__.'/component'); * $loader->addPrefix('Symfony', __DIR__.'/framework'); * * // or with a Composer autoloader * use Composer\Autoload\ClassLoader; * * $loader = new ClassLoader(); * $loader->add('Symfony\Component', __DIR__.'/component'); * $loader->add('Symfony', __DIR__.'/framework'); * * $cachedLoader = new ApcClassLoader('my_prefix', $loader); * * // activate the cached autoloader * $cachedLoader->register(); * * // eventually deactivate the non-cached loader if it was registered previously * // to be sure to use the cached one. * $loader->unregister(); * * @author Fabien Potencier * @author Kris Wallsmith * * @deprecated since version 3.3, to be removed in 4.0. Use `composer install --apcu-autoloader` instead. */ class ApcClassLoader { private $prefix; /** * A class loader object that implements the findFile() method. * * @var object */ protected $decorated; /** * @param string $prefix The APC namespace prefix to use * @param object $decorated A class loader object that implements the findFile() method * * @throws \RuntimeException * @throws \InvalidArgumentException */ public function __construct($prefix, $decorated) { if (!function_exists('apcu_fetch')) { throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.'); } if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; $this->decorated = $decorated; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Unregisters this instance as an autoloader. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } /** * Loads the given class or interface. * * @param string $class The name of the class * * @return bool|null True, if loaded */ public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; return true; } } /** * Finds a file by class name while caching lookups to APC. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { $file = apcu_fetch($this->prefix.$class, $success); if (!$success) { apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null); } return $file; } /** * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/CHANGELOG.md000066400000000000000000000023061324732107100234330ustar00rootroot00000000000000CHANGELOG ========= 3.3.0 ----- * deprecated the component: use Composer instead 3.0.0 ----- * The DebugClassLoader class has been removed * The DebugUniversalClassLoader class has been removed * The UniversalClassLoader class has been removed * The ApcUniversalClassLoader class has been removed 2.4.0 ----- * deprecated the UniversalClassLoader in favor of the ClassLoader class instead * deprecated the ApcUniversalClassLoader in favor of the ApcClassLoader class instead * deprecated the DebugUniversalClassLoader in favor of the DebugClassLoader class from the Debug component * deprecated the DebugClassLoader as it has been moved to the Debug component instead 2.3.0 ----- * added a WinCacheClassLoader for WinCache 2.1.0 ----- * added a DebugClassLoader able to wrap any autoloader providing a findFile method * added a new ApcClassLoader and XcacheClassLoader using composition to wrap other loaders * added a new ClassLoader which does not distinguish between namespaced and pear-like classes (as the PEAR convention is a subset of PSR-0) and supports using Composer's namespace maps * added a class map generator * added support for loading globally-installed PEAR packages symfony-3.4.6/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php000066400000000000000000000354221324732107100265500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; if (\PHP_VERSION_ID >= 70000) { @trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED); } /** * ClassCollectionLoader. * * @author Fabien Potencier * * @deprecated since version 3.3, to be removed in 4.0. */ class ClassCollectionLoader { private static $loaded; private static $seen; private static $useTokenizer = true; /** * Loads a list of classes and caches them in one big file. * * @param array $classes An array of classes to load * @param string $cacheDir A cache directory * @param string $name The cache name prefix * @param bool $autoReload Whether to flush the cache when the cache is stale or not * @param bool $adaptive Whether to remove already declared classes or not * @param string $extension File extension of the resulting file * * @throws \InvalidArgumentException When class can't be loaded */ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php') { // each $name can only be loaded once per PHP process if (isset(self::$loaded[$name])) { return; } self::$loaded[$name] = true; if ($adaptive) { $declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); // don't include already declared classes $classes = array_diff($classes, $declared); // the cache is different depending on which classes are already declared $name = $name.'-'.substr(hash('sha256', implode('|', $classes)), 0, 5); } $classes = array_unique($classes); // cache the core classes if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir)); } $cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR); $cache = $cacheDir.'/'.$name.$extension; // auto-reload $reload = false; if ($autoReload) { $metadata = $cache.'.meta'; if (!is_file($metadata) || !is_file($cache)) { $reload = true; } else { $time = filemtime($cache); $meta = unserialize(file_get_contents($metadata)); sort($meta[1]); sort($classes); if ($meta[1] != $classes) { $reload = true; } else { foreach ($meta[0] as $resource) { if (!is_file($resource) || filemtime($resource) > $time) { $reload = true; break; } } } } } if (!$reload && file_exists($cache)) { require_once $cache; return; } if (!$adaptive) { $declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); } $files = self::inline($classes, $cache, $declared); if ($autoReload) { // save the resources self::writeCacheFile($metadata, serialize(array(array_values($files), $classes))); } } /** * Generates a file where classes and their parents are inlined. * * @param array $classes An array of classes to load * @param string $cache The file where classes are inlined * @param array $excluded An array of classes that won't be inlined * * @return array The source map of inlined classes, with classes as keys and files as values * * @throws \RuntimeException When class can't be loaded */ public static function inline($classes, $cache, array $excluded) { $declared = array(); foreach (self::getOrderedClasses($excluded) as $class) { $declared[$class->getName()] = true; } // cache the core classes $cacheDir = dirname($cache); if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir)); } $spacesRegex = '(?:\s*+(?:(?:\#|//)[^\n]*+\n|/\*(?:(?getName()])) { continue; } $declared[$class->getName()] = true; $files[$class->getName()] = $file = $class->getFileName(); $c = file_get_contents($file); if (preg_match($dontInlineRegex, $c)) { $file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file)); for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) { if ($file[$i] !== $cacheDir[$i]) { break; } } if (1 >= $i) { $file = var_export(implode('/', $file), true); } else { $file = array_slice($file, $i); $file = str_repeat('../', count($cacheDir) - $i).implode('/', $file); $file = '__DIR__.'.var_export('/'.$file, true); } $c = "\nnamespace {require $file;}"; } else { $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', $c); // fakes namespace declaration for global code if (!$class->inNamespace()) { $c = "\nnamespace\n{\n".$c."\n}\n"; } $c = self::fixNamespaceDeclarations('= 70000) { // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 unset($tokens, $rawChunk); gc_mem_caches(); } return $output; } /** * This method is only useful for testing. */ public static function enableTokenizer($bool) { self::$useTokenizer = (bool) $bool; } /** * Strips leading & trailing ws, multiple EOL, multiple ws. * * @param string $code Original PHP code * * @return string compressed code */ private static function compressCode($code) { return preg_replace( array('/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'), array('', '', "\n", ' '), $code ); } /** * Writes a cache file. * * @param string $file Filename * @param string $content Temporary file content * * @throws \RuntimeException when a cache file cannot be written */ private static function writeCacheFile($file, $content) { $dir = dirname($file); if (!is_writable($dir)) { throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir)); } $tmpFile = tempnam($dir, basename($file)); if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { @chmod($file, 0666 & ~umask()); return; } throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); } /** * Gets an ordered array of passed classes including all their dependencies. * * @return \ReflectionClass[] An array of sorted \ReflectionClass instances (dependencies added if needed) * * @throws \InvalidArgumentException When a class can't be loaded */ private static function getOrderedClasses(array $classes) { $map = array(); self::$seen = array(); foreach ($classes as $class) { try { $reflectionClass = new \ReflectionClass($class); } catch (\ReflectionException $e) { throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class)); } $map = array_merge($map, self::getClassHierarchy($reflectionClass)); } return $map; } private static function getClassHierarchy(\ReflectionClass $class) { if (isset(self::$seen[$class->getName()])) { return array(); } self::$seen[$class->getName()] = true; $classes = array($class); $parent = $class; while (($parent = $parent->getParentClass()) && $parent->isUserDefined() && !isset(self::$seen[$parent->getName()])) { self::$seen[$parent->getName()] = true; array_unshift($classes, $parent); } $traits = array(); foreach ($classes as $c) { foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) { if ($trait !== $c) { $traits[] = $trait; } } } return array_merge(self::getInterfaces($class), $traits, $classes); } private static function getInterfaces(\ReflectionClass $class) { $classes = array(); foreach ($class->getInterfaces() as $interface) { $classes = array_merge($classes, self::getInterfaces($interface)); } if ($class->isUserDefined() && $class->isInterface() && !isset(self::$seen[$class->getName()])) { self::$seen[$class->getName()] = true; $classes[] = $class; } return $classes; } private static function computeTraitDeps(\ReflectionClass $class) { $traits = $class->getTraits(); $deps = array($class->getName() => $traits); while ($trait = array_pop($traits)) { if ($trait->isUserDefined() && !isset(self::$seen[$trait->getName()])) { self::$seen[$trait->getName()] = true; $traitDeps = $trait->getTraits(); $deps[$trait->getName()] = $traitDeps; $traits = array_merge($traits, $traitDeps); } } return $deps; } /** * Dependencies resolution. * * This function does not check for circular dependencies as it should never * occur with PHP traits. * * @param array $tree The dependency tree * @param \ReflectionClass $node The node * @param \ArrayObject $resolved An array of already resolved dependencies * @param \ArrayObject $unresolved An array of dependencies to be resolved * * @return \ArrayObject The dependencies for the given node * * @throws \RuntimeException if a circular dependency is detected */ private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null) { if (null === $resolved) { $resolved = new \ArrayObject(); } if (null === $unresolved) { $unresolved = new \ArrayObject(); } $nodeName = $node->getName(); if (isset($tree[$nodeName])) { $unresolved[$nodeName] = $node; foreach ($tree[$nodeName] as $dependency) { if (!$resolved->offsetExists($dependency->getName())) { self::resolveDependencies($tree, $dependency, $resolved, $unresolved); } } $resolved[$nodeName] = $node; unset($unresolved[$nodeName]); } return $resolved; } } symfony-3.4.6/src/Symfony/Component/ClassLoader/ClassLoader.php000066400000000000000000000130531324732107100245300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED); /** * ClassLoader implements an PSR-0 class loader. * * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md * * $loader = new ClassLoader(); * * // register classes with namespaces * $loader->addPrefix('Symfony\Component', __DIR__.'/component'); * $loader->addPrefix('Symfony', __DIR__.'/framework'); * * // activate the autoloader * $loader->register(); * * // to enable searching the include path (e.g. for PEAR packages) * $loader->setUseIncludePath(true); * * In this example, if you try to use a class in the Symfony\Component * namespace or one of its children (Symfony\Component\Console for instance), * the autoloader will first look for the class under the component/ * directory, and it will then fallback to the framework/ directory if not * found before giving up. * * @author Fabien Potencier * @author Jordi Boggiano * * @deprecated since version 3.3, to be removed in 4.0. */ class ClassLoader { private $prefixes = array(); private $fallbackDirs = array(); private $useIncludePath = false; /** * Returns prefixes. * * @return array */ public function getPrefixes() { return $this->prefixes; } /** * Returns fallback directories. * * @return array */ public function getFallbackDirs() { return $this->fallbackDirs; } /** * Adds prefixes. * * @param array $prefixes Prefixes to add */ public function addPrefixes(array $prefixes) { foreach ($prefixes as $prefix => $path) { $this->addPrefix($prefix, $path); } } /** * Registers a set of classes. * * @param string $prefix The classes prefix * @param array|string $paths The location(s) of the classes */ public function addPrefix($prefix, $paths) { if (!$prefix) { foreach ((array) $paths as $path) { $this->fallbackDirs[] = $path; } return; } if (isset($this->prefixes[$prefix])) { if (is_array($paths)) { $this->prefixes[$prefix] = array_unique(array_merge( $this->prefixes[$prefix], $paths )); } elseif (!in_array($paths, $this->prefixes[$prefix])) { $this->prefixes[$prefix][] = $paths; } } else { $this->prefixes[$prefix] = array_unique((array) $paths); } } /** * Turns on searching the include for class files. * * @param bool $useIncludePath */ public function setUseIncludePath($useIncludePath) { $this->useIncludePath = (bool) $useIncludePath; } /** * Can be used to check if the autoloader uses the include path to check * for classes. * * @return bool */ public function getUseIncludePath() { return $this->useIncludePath; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Unregisters this instance as an autoloader. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } /** * Loads the given class or interface. * * @param string $class The name of the class * * @return bool|null True, if loaded */ public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; return true; } } /** * Finds the path to the file where the class is defined. * * @param string $class The name of the class * * @return string|null The path, if found */ public function findFile($class) { if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR; $className = substr($class, $pos + 1); } else { // PEAR-like class name $classPath = null; $className = $class; } $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; foreach ($this->prefixes as $prefix => $dirs) { if ($class === strstr($class, $prefix)) { foreach ($dirs as $dir) { if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) { return $dir.DIRECTORY_SEPARATOR.$classPath; } } } } foreach ($this->fallbackDirs as $dir) { if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) { return $dir.DIRECTORY_SEPARATOR.$classPath; } } if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) { return $file; } } } symfony-3.4.6/src/Symfony/Component/ClassLoader/ClassMapGenerator.php000066400000000000000000000110521324732107100257030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED); /** * ClassMapGenerator. * * @author Gyula Sallai * * @deprecated since version 3.3, to be removed in 4.0. */ class ClassMapGenerator { /** * Generate a class map file. * * @param array|string $dirs Directories or a single path to search in * @param string $file The name of the class map file */ public static function dump($dirs, $file) { $dirs = (array) $dirs; $maps = array(); foreach ($dirs as $dir) { $maps = array_merge($maps, static::createMap($dir)); } file_put_contents($file, sprintf('isFile()) { continue; } $path = $file->getRealPath() ?: $file->getPathname(); if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) { continue; } $classes = self::findClasses($path); if (\PHP_VERSION_ID >= 70000) { // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 gc_mem_caches(); } foreach ($classes as $class) { $map[$class] = $path; } } return $map; } /** * Extract the classes in the given file. * * @param string $path The file to check * * @return array The found classes */ private static function findClasses($path) { $contents = file_get_contents($path); $tokens = token_get_all($contents); $classes = array(); $namespace = ''; for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; if (!isset($token[1])) { continue; } $class = ''; switch ($token[0]) { case T_NAMESPACE: $namespace = ''; // If there is a namespace, extract it while (isset($tokens[++$i][1])) { if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) { $namespace .= $tokens[$i][1]; } } $namespace .= '\\'; break; case T_CLASS: case T_INTERFACE: case T_TRAIT: // Skip usage of ::class constant $isClassConstant = false; for ($j = $i - 1; $j > 0; --$j) { if (!isset($tokens[$j][1])) { break; } if (T_DOUBLE_COLON === $tokens[$j][0]) { $isClassConstant = true; break; } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { break; } } if ($isClassConstant) { break; } // Find the classname while (isset($tokens[++$i][1])) { $t = $tokens[$i]; if (T_STRING === $t[0]) { $class .= $t[1]; } elseif ('' !== $class && T_WHITESPACE === $t[0]) { break; } } $classes[] = ltrim($namespace.$class, '\\'); break; default: break; } } return $classes; } } symfony-3.4.6/src/Symfony/Component/ClassLoader/LICENSE000066400000000000000000000020511324732107100226240ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Component/ClassLoader/MapClassLoader.php000066400000000000000000000032761324732107100251740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED); /** * A class loader that uses a mapping file to look up paths. * * @author Fabien Potencier * * @deprecated since version 3.3, to be removed in 4.0. */ class MapClassLoader { private $map = array(); /** * @param array $map A map where keys are classes and values the absolute file path */ public function __construct(array $map) { $this->map = $map; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Loads the given class or interface. * * @param string $class The name of the class */ public function loadClass($class) { if (isset($this->map[$class])) { require $this->map[$class]; } } /** * Finds the path to the file where the class is defined. * * @param string $class The name of the class * * @return string|null The path, if found */ public function findFile($class) { if (isset($this->map[$class])) { return $this->map[$class]; } } } symfony-3.4.6/src/Symfony/Component/ClassLoader/Psr4ClassLoader.php000066400000000000000000000044121324732107100253000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED); /** * A PSR-4 compatible class loader. * * See http://www.php-fig.org/psr/psr-4/ * * @author Alexander M. Turek * * @deprecated since version 3.3, to be removed in 4.0. */ class Psr4ClassLoader { private $prefixes = array(); /** * @param string $prefix * @param string $baseDir */ public function addPrefix($prefix, $baseDir) { $prefix = trim($prefix, '\\').'\\'; $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; $this->prefixes[] = array($prefix, $baseDir); } /** * @param string $class * * @return string|null */ public function findFile($class) { $class = ltrim($class, '\\'); foreach ($this->prefixes as list($currentPrefix, $currentBaseDir)) { if (0 === strpos($class, $currentPrefix)) { $classWithoutPrefix = substr($class, strlen($currentPrefix)); $file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php'; if (file_exists($file)) { return $file; } } } } /** * @param string $class * * @return bool */ public function loadClass($class) { $file = $this->findFile($class); if (null !== $file) { require $file; return true; } return false; } /** * Registers this instance as an autoloader. * * @param bool $prepend */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Removes this instance from the registered autoloaders. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/README.md000066400000000000000000000010431324732107100230760ustar00rootroot00000000000000ClassLoader Component ===================== The ClassLoader component provides tools to autoload your classes and cache their locations for performance. Resources --------- * [Documentation](https://symfony.com/doc/current/components/class_loader/index.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/000077500000000000000000000000001324732107100227235ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php000066400000000000000000000167021324732107100271220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\ClassLoader\ClassLoader; /** * @group legacy */ class ApcClassLoaderTest extends TestCase { protected function setUp() { if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) { $this->markTestSkipped('The apc extension is not enabled.'); } else { apcu_clear_cache(); } } protected function tearDown() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { apcu_clear_cache(); } } public function testConstructor() { $loader = new ClassLoader(); $loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader = new ApcClassLoader('test.prefix.', $loader); $this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument'); } /** * @dataProvider getLoadClassTests */ public function testLoadClass($className, $testClassName, $message) { $loader = new ClassLoader(); $loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader = new ApcClassLoader('test.prefix.', $loader); $loader->loadClass($testClassName); $this->assertTrue(class_exists($className), $message); } public function getLoadClassTests() { return array( array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'), ); } /** * @dataProvider getLoadClassFromFallbackTests */ public function testLoadClassFromFallback($className, $testClassName, $message) { $loader = new ClassLoader(); $loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback')); $loader = new ApcClassLoader('test.prefix.fallback', $loader); $loader->loadClass($testClassName); $this->assertTrue(class_exists($className), $message); } public function getLoadClassFromFallbackTests() { return array( array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'), array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'), ); } /** * @dataProvider getLoadClassNamespaceCollisionTests */ public function testLoadClassNamespaceCollision($namespaces, $className, $message) { $loader = new ClassLoader(); $loader->addPrefixes($namespaces); $loader = new ApcClassLoader('test.prefix.collision.', $loader); $loader->loadClass($className); $this->assertTrue(class_exists($className), $message); } public function getLoadClassNamespaceCollisionTests() { return array( array( array( 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), 'Apc\NamespaceCollision\A\Foo', '->loadClass() loads NamespaceCollision\A\Foo from alpha.', ), array( array( 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), 'Apc\NamespaceCollision\A\Bar', '->loadClass() loads NamespaceCollision\A\Bar from alpha.', ), array( array( 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), 'Apc\NamespaceCollision\A\B\Foo', '->loadClass() loads NamespaceCollision\A\B\Foo from beta.', ), array( array( 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), 'Apc\NamespaceCollision\A\B\Bar', '->loadClass() loads NamespaceCollision\A\B\Bar from beta.', ), ); } /** * @dataProvider getLoadClassPrefixCollisionTests */ public function testLoadClassPrefixCollision($prefixes, $className, $message) { $loader = new ClassLoader(); $loader->addPrefixes($prefixes); $loader = new ApcClassLoader('test.prefix.collision.', $loader); $loader->loadClass($className); $this->assertTrue(class_exists($className), $message); } public function getLoadClassPrefixCollisionTests() { return array( array( array( 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', 'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', ), 'ApcPrefixCollision_A_Foo', '->loadClass() loads ApcPrefixCollision_A_Foo from alpha.', ), array( array( 'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', ), 'ApcPrefixCollision_A_Bar', '->loadClass() loads ApcPrefixCollision_A_Bar from alpha.', ), array( array( 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', 'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', ), 'ApcPrefixCollision_A_B_Foo', '->loadClass() loads ApcPrefixCollision_A_B_Foo from beta.', ), array( array( 'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', ), 'ApcPrefixCollision_A_B_Bar', '->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.', ), ); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php000066400000000000000000000236701324732107100305140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ClassLoader\ClassCollectionLoader; use Symfony\Component\ClassLoader\Tests\Fixtures\DeclaredClass; use Symfony\Component\ClassLoader\Tests\Fixtures\WarmedClass; require_once __DIR__.'/Fixtures/ClassesWithParents/GInterface.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/B.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/A.php'; /** * @group legacy */ class ClassCollectionLoaderTest extends TestCase { public function testTraitDependencies() { require_once __DIR__.'/Fixtures/deps/traits.php'; $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke(null, array('CTFoo')); $this->assertEquals( array('TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'), array_map(function ($class) { return $class->getName(); }, $ordered) ); $ordered = $m->invoke(null, array('CTBar')); $this->assertEquals( array('TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'), array_map(function ($class) { return $class->getName(); }, $ordered) ); } /** * @dataProvider getDifferentOrders */ public function testClassReordering(array $classes) { $expected = array( 'ClassesWithParents\\GInterface', 'ClassesWithParents\\CInterface', 'ClassesWithParents\\B', 'ClassesWithParents\\A', ); $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke(null, $classes); $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); } public function getDifferentOrders() { return array( array(array( 'ClassesWithParents\\A', 'ClassesWithParents\\CInterface', 'ClassesWithParents\\GInterface', 'ClassesWithParents\\B', )), array(array( 'ClassesWithParents\\B', 'ClassesWithParents\\A', 'ClassesWithParents\\CInterface', )), array(array( 'ClassesWithParents\\CInterface', 'ClassesWithParents\\B', 'ClassesWithParents\\A', )), array(array( 'ClassesWithParents\\A', )), ); } /** * @dataProvider getDifferentOrdersForTraits */ public function testClassWithTraitsReordering(array $classes) { require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/D.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/E.php'; $expected = array( 'ClassesWithParents\\GInterface', 'ClassesWithParents\\CInterface', 'ClassesWithParents\\ATrait', 'ClassesWithParents\\BTrait', 'ClassesWithParents\\CTrait', 'ClassesWithParents\\B', 'ClassesWithParents\\A', 'ClassesWithParents\\D', 'ClassesWithParents\\E', ); $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke(null, $classes); $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); } public function getDifferentOrdersForTraits() { return array( array(array( 'ClassesWithParents\\E', 'ClassesWithParents\\ATrait', )), array(array( 'ClassesWithParents\\E', )), ); } public function testFixClassWithTraitsOrdering() { require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/F.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/G.php'; $classes = array( 'ClassesWithParents\\F', 'ClassesWithParents\\G', ); $expected = array( 'ClassesWithParents\\CTrait', 'ClassesWithParents\\F', 'ClassesWithParents\\G', ); $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke(null, $classes); $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); } /** * @dataProvider getFixNamespaceDeclarationsData */ public function testFixNamespaceDeclarations($source, $expected) { $this->assertEquals('assertEquals('assertEquals(<<<'EOF' namespace Namespaced { class WithComments { public static $loaded = true; } $string ='string should not be modified {$string}'; $heredoc = (<<assertTrue(class_exists(WarmedClass::class, true)); @unlink($cache = sys_get_temp_dir().'/inline.php'); $classes = array(WarmedClass::class); $excluded = array(DeclaredClass::class); ClassCollectionLoader::inline($classes, $cache, $excluded); $this->assertSame(<<<'EOTXT' * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ClassLoader\ClassLoader; /** * @group legacy */ class ClassLoaderTest extends TestCase { public function testGetPrefixes() { $loader = new ClassLoader(); $loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('Foo', $prefixes); $this->assertArrayNotHasKey('Foo1', $prefixes); $this->assertArrayHasKey('Bar', $prefixes); $this->assertArrayHasKey('Bas', $prefixes); } public function testGetFallbackDirs() { $loader = new ClassLoader(); $loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $fallback_dirs = $loader->getFallbackDirs(); $this->assertCount(2, $fallback_dirs); } /** * @dataProvider getLoadClassTests */ public function testLoadClass($className, $testClassName, $message) { $loader = new ClassLoader(); $loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->loadClass($testClassName); $this->assertTrue(class_exists($className), $message); } public function getLoadClassTests() { return array( array('\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'), array('\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'), ); } /** * @dataProvider getLoadNonexistentClassTests */ public function testLoadNonexistentClass($className, $testClassName, $message) { $loader = new ClassLoader(); $loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->loadClass($testClassName); $this->assertFalse(class_exists($className), $message); } public function getLoadNonexistentClassTests() { return array( array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'), ); } public function testAddPrefixSingle() { $loader = new ClassLoader(); $loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('Foo', $prefixes); $this->assertCount(1, $prefixes['Foo']); } public function testAddPrefixesSingle() { $loader = new ClassLoader(); $loader->addPrefixes(array('Foo' => array('foo', 'foo'))); $loader->addPrefixes(array('Foo' => array('foo'))); $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('Foo', $prefixes); $this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true)); } public function testAddPrefixMulti() { $loader = new ClassLoader(); $loader->addPrefix('Foo', 'foo'); $loader->addPrefix('Foo', 'bar'); $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('Foo', $prefixes); $this->assertCount(2, $prefixes['Foo']); $this->assertContains('foo', $prefixes['Foo']); $this->assertContains('bar', $prefixes['Foo']); } public function testUseIncludePath() { $loader = new ClassLoader(); $this->assertFalse($loader->getUseIncludePath()); $this->assertNull($loader->findFile('Foo')); $includePath = get_include_path(); $loader->setUseIncludePath(true); $this->assertTrue($loader->getUseIncludePath()); set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath); $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo')); set_include_path($includePath); } /** * @dataProvider getLoadClassFromFallbackTests */ public function testLoadClassFromFallback($className, $testClassName, $message) { $loader = new ClassLoader(); $loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback')); $loader->loadClass($testClassName); $this->assertTrue(class_exists($className), $message); } public function getLoadClassFromFallbackTests() { return array( array('\\Namespaced2\\Baz', 'Namespaced2\\Baz', '->loadClass() loads Namespaced2\Baz class'), array('\\Pearlike2_Baz', 'Pearlike2_Baz', '->loadClass() loads Pearlike2_Baz class'), array('\\Namespaced2\\FooBar', 'Namespaced2\\FooBar', '->loadClass() loads Namespaced2\Baz class from fallback dir'), array('\\Pearlike2_FooBar', 'Pearlike2_FooBar', '->loadClass() loads Pearlike2_Baz class from fallback dir'), ); } /** * @dataProvider getLoadClassNamespaceCollisionTests */ public function testLoadClassNamespaceCollision($namespaces, $className, $message) { $loader = new ClassLoader(); $loader->addPrefixes($namespaces); $loader->loadClass($className); $this->assertTrue(class_exists($className), $message); } public function getLoadClassNamespaceCollisionTests() { return array( array( array( 'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', 'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', ), 'NamespaceCollision\C\Foo', '->loadClass() loads NamespaceCollision\C\Foo from alpha.', ), array( array( 'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', 'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', ), 'NamespaceCollision\C\Bar', '->loadClass() loads NamespaceCollision\C\Bar from alpha.', ), array( array( 'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', 'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', ), 'NamespaceCollision\C\B\Foo', '->loadClass() loads NamespaceCollision\C\B\Foo from beta.', ), array( array( 'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', 'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', ), 'NamespaceCollision\C\B\Bar', '->loadClass() loads NamespaceCollision\C\B\Bar from beta.', ), array( array( 'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', 'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', ), 'PrefixCollision_C_Foo', '->loadClass() loads PrefixCollision_C_Foo from alpha.', ), array( array( 'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', 'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', ), 'PrefixCollision_C_Bar', '->loadClass() loads PrefixCollision_C_Bar from alpha.', ), array( array( 'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', 'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', ), 'PrefixCollision_C_B_Foo', '->loadClass() loads PrefixCollision_C_B_Foo from beta.', ), array( array( 'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta', 'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha', ), 'PrefixCollision_C_B_Bar', '->loadClass() loads PrefixCollision_C_B_Bar from beta.', ), ); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php000066400000000000000000000144131324732107100276510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ClassLoader\ClassMapGenerator; /** * @group legacy */ class ClassMapGeneratorTest extends TestCase { /** * @var string|null */ private $workspace = null; public function prepare_workspace() { $this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand(); mkdir($this->workspace, 0777, true); $this->workspace = realpath($this->workspace); } /** * @param string $file */ private function clean($file) { if (is_dir($file) && !is_link($file)) { $dir = new \FilesystemIterator($file); foreach ($dir as $childFile) { $this->clean($childFile); } rmdir($file); } else { unlink($file); } } /** * @dataProvider getTestCreateMapTests */ public function testDump($directory) { $this->prepare_workspace(); $file = $this->workspace.'/file'; $generator = new ClassMapGenerator(); $generator->dump($directory, $file); $this->assertFileExists($file); $this->clean($this->workspace); } /** * @dataProvider getTestCreateMapTests */ public function testCreateMap($directory, $expected) { $this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory)); } public function getTestCreateMapTests() { $data = array( array(__DIR__.'/Fixtures/Namespaced', array( 'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php', 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', 'Namespaced\\WithStrictTypes' => realpath(__DIR__).'/Fixtures/Namespaced/WithStrictTypes.php', 'Namespaced\\WithHaltCompiler' => realpath(__DIR__).'/Fixtures/Namespaced/WithHaltCompiler.php', 'Namespaced\\WithDirMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithDirMagic.php', 'Namespaced\\WithFileMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithFileMagic.php', )), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php', 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php', 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php', )), array(__DIR__.'/Fixtures/Pearlike', array( 'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php', 'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php', 'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php', 'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php', )), array(__DIR__.'/Fixtures/classmap', array( 'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php', 'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php', 'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', 'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', 'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', 'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', 'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', 'ClassMap\\SomeInterface' => realpath(__DIR__).'/Fixtures/classmap/SomeInterface.php', 'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php', 'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php', )), array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php', )), array(__DIR__.'/Fixtures/php5.5', array( 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', )), ); return $data; } public function testCreateMapFinderSupport() { $finder = new \Symfony\Component\Finder\Finder(); $finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision'); $this->assertEqualsNormalized(array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php', 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php', 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php', ), ClassMapGenerator::createMap($finder)); } protected function assertEqualsNormalized($expected, $actual, $message = null) { foreach ($expected as $ns => $path) { $expected[$ns] = str_replace('\\', '/', $path); } foreach ($actual as $ns => $path) { $actual[$ns] = str_replace('\\', '/', $path); } $this->assertEquals($expected, $actual, $message); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/000077500000000000000000000000001324732107100245345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/000077500000000000000000000000001324732107100252375ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Namespaced/000077500000000000000000000000001324732107100272775ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Namespaced/Bar.php000066400000000000000000000004711324732107100305160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\Namespaced; class Bar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Namespaced/Baz.php000066400000000000000000000004711324732107100305260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\Namespaced; class Baz { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Namespaced/Foo.php000066400000000000000000000004711324732107100305350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\Namespaced; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Namespaced/FooBar.php000066400000000000000000000004741324732107100311650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\Namespaced; class FooBar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Pearlike/000077500000000000000000000000001324732107100267735ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/Pearlike/Bar.php000066400000000000000000000001041324732107100302030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\NamespaceCollision\A; class Bar { public static $loaded = true; } Foo.php000066400000000000000000000005031324732107100341320ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\NamespaceCollision\A; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/000077500000000000000000000000001324732107100261525ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/000077500000000000000000000000001324732107100266555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/000077500000000000000000000000001324732107100324125ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/000077500000000000000000000000001324732107100325725ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/000077500000000000000000000000001324732107100327535ustar00rootroot00000000000000Bar.php000066400000000000000000000001161324732107100341070ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\NamespaceCollision\A\B; class Bar { public static $loaded = true; } Foo.php000066400000000000000000000005051324732107100341430ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\NamespaceCollision\A\B; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/fallback/000077500000000000000000000000001324732107100267765ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/fallback/Apc/000077500000000000000000000000001324732107100275015ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/000077500000000000000000000000001324732107100312355ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php000066400000000000000000000001071324732107100331140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Apc\Namespaced; class FooBar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/000077500000000000000000000000001324732107100303225ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php000066400000000000000000000000741324732107100312140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Namespaced; class Bar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/Baz.php000066400000000000000000000004651324732107100300260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Namespaced; class Baz { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/Foo.php000066400000000000000000000004651324732107100300350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Namespaced; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithComments.php000066400000000000000000000010271324732107100317260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Namespaced; class WithComments { /** @Boolean */ public static $loaded = true; } $string = 'string should not be modified {$string}'; $heredoc = (<< * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Pearlike_WithComments { /** @Boolean */ public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike2/000077500000000000000000000000001324732107100263525ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike2/Bar.php000066400000000000000000000001011324732107100275570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace NamespaceCollision\A; class Bar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php000066400000000000000000000004771324732107100330150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace NamespaceCollision\A; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/alpha/NamespaceCollision/C/000077500000000000000000000000001324732107100315535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php000066400000000000000000000001301324732107100327620ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace NamespaceCollision\A\B; class Bar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php000066400000000000000000000005011324732107100330100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace NamespaceCollision\A\B; class Foo { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/beta/NamespaceCollision/C/000077500000000000000000000000001324732107100314015ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/beta/NamespaceCollision/C/B/000077500000000000000000000000001324732107100315625ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php000066400000000000000000000001321324732107100327730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ClassMap; class SomeClass extends SomeParent implements SomeInterface { } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php000066400000000000000000000004371324732107100316000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ClassMap; interface SomeInterface { } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php000066400000000000000000000004411324732107100311240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ClassMap; abstract class SomeParent { } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php000066400000000000000000000002661324732107100312100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Foo\Bar; class A { } class B { } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/deps/000077500000000000000000000000001324732107100254675ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/deps/traits.php000066400000000000000000000003161324732107100275060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Namespaced; class FooBar { public static $loaded = true; } symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/fallback/Namespaced2/000077500000000000000000000000001324732107100304155ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/ClassLoader/Tests/Fixtures/fallback/Namespaced2/FooBar.php000066400000000000000000000001221324732107100322710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ClassLoader\Psr4ClassLoader; /** * @group legacy */ class Psr4ClassLoaderTest extends TestCase { /** * @param string $className * @dataProvider getLoadClassTests */ public function testLoadClass($className) { $loader = new Psr4ClassLoader(); $loader->addPrefix( 'Acme\\DemoLib', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4' ); $loader->loadClass($className); $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className)); } /** * @return array */ public function getLoadClassTests() { return array( array('Acme\\DemoLib\\Foo'), array('Acme\\DemoLib\\Class_With_Underscores'), array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'), array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'), ); } /** * @param string $className * @dataProvider getLoadNonexistentClassTests */ public function testLoadNonexistentClass($className) { $loader = new Psr4ClassLoader(); $loader->addPrefix( 'Acme\\DemoLib', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4' ); $loader->loadClass($className); $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className)); } /** * @return array */ public function getLoadNonexistentClassTests() { return array( array('Acme\\DemoLib\\I_Do_Not_Exist'), array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'), ); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/WinCacheClassLoader.php000066400000000000000000000102501324732107100261260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED); /** * WinCacheClassLoader implements a wrapping autoloader cached in WinCache. * * It expects an object implementing a findFile method to find the file. This * allow using it as a wrapper around the other loaders of the component (the * ClassLoader for instance) but also around any other autoloaders following * this convention (the Composer one for instance). * * // with a Symfony autoloader * $loader = new ClassLoader(); * $loader->addPrefix('Symfony\Component', __DIR__.'/component'); * $loader->addPrefix('Symfony', __DIR__.'/framework'); * * // or with a Composer autoloader * use Composer\Autoload\ClassLoader; * * $loader = new ClassLoader(); * $loader->add('Symfony\Component', __DIR__.'/component'); * $loader->add('Symfony', __DIR__.'/framework'); * * $cachedLoader = new WinCacheClassLoader('my_prefix', $loader); * * // activate the cached autoloader * $cachedLoader->register(); * * // eventually deactivate the non-cached loader if it was registered previously * // to be sure to use the cached one. * $loader->unregister(); * * @author Fabien Potencier * @author Kris Wallsmith * @author Artem Ryzhkov * * @deprecated since version 3.3, to be removed in 4.0. Use `composer install --apcu-autoloader` instead. */ class WinCacheClassLoader { private $prefix; /** * A class loader object that implements the findFile() method. * * @var object */ protected $decorated; /** * @param string $prefix The WinCache namespace prefix to use * @param object $decorated A class loader object that implements the findFile() method * * @throws \RuntimeException * @throws \InvalidArgumentException */ public function __construct($prefix, $decorated) { if (!extension_loaded('wincache')) { throw new \RuntimeException('Unable to use WinCacheClassLoader as WinCache is not enabled.'); } if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; $this->decorated = $decorated; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Unregisters this instance as an autoloader. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } /** * Loads the given class or interface. * * @param string $class The name of the class * * @return bool|null True, if loaded */ public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; return true; } } /** * Finds a file by class name while caching lookups to WinCache. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { $file = wincache_ucache_get($this->prefix.$class, $success); if (!$success) { wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0); } return $file; } /** * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/XcacheClassLoader.php000066400000000000000000000101271324732107100256430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ClassLoader; @trigger_error('The '.__NAMESPACE__.'\XcacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED); /** * XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This * allows using it as a wrapper around the other loaders of the component (the * ClassLoader for instance) but also around any other autoloaders following * this convention (the Composer one for instance). * * // with a Symfony autoloader * $loader = new ClassLoader(); * $loader->addPrefix('Symfony\Component', __DIR__.'/component'); * $loader->addPrefix('Symfony', __DIR__.'/framework'); * * // or with a Composer autoloader * use Composer\Autoload\ClassLoader; * * $loader = new ClassLoader(); * $loader->add('Symfony\Component', __DIR__.'/component'); * $loader->add('Symfony', __DIR__.'/framework'); * * $cachedLoader = new XcacheClassLoader('my_prefix', $loader); * * // activate the cached autoloader * $cachedLoader->register(); * * // eventually deactivate the non-cached loader if it was registered previously * // to be sure to use the cached one. * $loader->unregister(); * * @author Fabien Potencier * @author Kris Wallsmith * @author Kim Hemsø Rasmussen * * @deprecated since version 3.3, to be removed in 4.0. Use `composer install --apcu-autoloader` instead. */ class XcacheClassLoader { private $prefix; private $decorated; /** * @param string $prefix The XCache namespace prefix to use * @param object $decorated A class loader object that implements the findFile() method * * @throws \RuntimeException * @throws \InvalidArgumentException */ public function __construct($prefix, $decorated) { if (!extension_loaded('xcache')) { throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.'); } if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; $this->decorated = $decorated; } /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Unregisters this instance as an autoloader. */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } /** * Loads the given class or interface. * * @param string $class The name of the class * * @return bool|null True, if loaded */ public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; return true; } } /** * Finds a file by class name while caching lookups to Xcache. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { $file = $this->decorated->findFile($class) ?: null; xcache_set($this->prefix.$class, $file); } return $file; } /** * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } } symfony-3.4.6/src/Symfony/Component/ClassLoader/composer.json000066400000000000000000000017261324732107100243510ustar00rootroot00000000000000{ "name": "symfony/class-loader", "type": "library", "description": "Symfony ClassLoader Component", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "minimum-stability": "dev", "require": { "php": "^5.5.9|>=7.0.8" }, "require-dev": { "symfony/finder": "~2.8|~3.0|~4.0", "symfony/polyfill-apcu": "~1.1" }, "suggest": { "symfony/polyfill-apcu": "For using ApcClassLoader on HHVM" }, "autoload": { "psr-4": { "Symfony\\Component\\ClassLoader\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Component/ClassLoader/phpunit.xml.dist000066400000000000000000000015711324732107100250000ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Component/Config/000077500000000000000000000000001324732107100206325ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/.gitignore000066400000000000000000000000421324732107100226160ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Component/Config/CHANGELOG.md000066400000000000000000000047131324732107100224500ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added `setDeprecated()` method to indicate a deprecated node * added `XmlUtils::parse()` method to parse an XML string * deprecated `ConfigCachePass` 3.3.0 ----- * added `ReflectionClassResource` class * added second `$exists` constructor argument to `ClassExistenceResource` * made `ClassExistenceResource` work with interfaces and traits * added `ConfigCachePass` (originally in FrameworkBundle) * added `castToArray()` helper to turn any config value into an array 3.0.0 ----- * removed `ReferenceDumper` class * removed the `ResourceInterface::isFresh()` method * removed `BCResourceInterfaceChecker` class * removed `ResourceInterface::getResource()` method 2.8.0 ----- The edge case of defining just one value for nodes of type Enum is now allowed: ```php $rootNode ->children() ->enumNode('variable') ->values(array('value')) ->end() ->end() ; ``` Before: `InvalidArgumentException` (variable must contain at least two distinct elements). After: the code will work as expected and it will restrict the values of the `variable` option to just `value`. * deprecated the `ResourceInterface::isFresh()` method. If you implement custom resource types and they can be validated that way, make them implement the new `SelfCheckingResourceInterface`. * deprecated the getResource() method in ResourceInterface. You can still call this method on concrete classes implementing the interface, but it does not make sense at the interface level as you need to know about the particular type of resource at hand to understand the semantics of the returned value. 2.7.0 ----- * added `ConfigCacheInterface`, `ConfigCacheFactoryInterface` and a basic `ConfigCacheFactory` implementation to delegate creation of ConfigCache instances 2.2.0 ----- * added `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()` to ease configuration when some sections are respectively disabled / enabled by default. * added a `normalizeKeys()` method for array nodes (to avoid key normalization) * added numerical type handling for config definitions * added convenience methods for optional configuration sections to `ArrayNodeDefinition` * added a utils class for XML manipulations 2.1.0 ----- * added a way to add documentation on configuration * implemented `Serializable` on resources * `LoaderResolverInterface` is now used instead of `LoaderResolver` for type hinting symfony-3.4.6/src/Symfony/Component/Config/ConfigCache.php000066400000000000000000000030651324732107100235000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Resource\SelfCheckingResourceChecker; /** * ConfigCache caches arbitrary content in files on disk. * * When in debug mode, those metadata resources that implement * \Symfony\Component\Config\Resource\SelfCheckingResourceInterface will * be used to check cache freshness. * * @author Fabien Potencier * @author Matthias Pigulla */ class ConfigCache extends ResourceCheckerConfigCache { private $debug; /** * @param string $file The absolute cache path * @param bool $debug Whether debugging is enabled or not */ public function __construct($file, $debug) { $this->debug = (bool) $debug; $checkers = array(); if (true === $this->debug) { $checkers = array(new SelfCheckingResourceChecker()); } parent::__construct($file, $checkers); } /** * Checks if the cache is still fresh. * * This implementation always returns true when debug is off and the * cache file exists. * * @return bool true if the cache is fresh, false otherwise */ public function isFresh() { if (!$this->debug && is_file($this->getPath())) { return true; } return parent::isFresh(); } } symfony-3.4.6/src/Symfony/Component/Config/ConfigCacheFactory.php000066400000000000000000000024241324732107100250260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; /** * Basic implementation of ConfigCacheFactoryInterface that * creates an instance of the default ConfigCache. * * This factory and/or cache do not support cache validation * by means of ResourceChecker instances (that is, service-based). * * @author Matthias Pigulla */ class ConfigCacheFactory implements ConfigCacheFactoryInterface { private $debug; /** * @param bool $debug The debug flag to pass to ConfigCache */ public function __construct($debug) { $this->debug = $debug; } /** * {@inheritdoc} */ public function cache($file, $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', gettype($callback))); } $cache = new ConfigCache($file, $this->debug); if (!$cache->isFresh()) { call_user_func($callback, $cache); } return $cache; } } symfony-3.4.6/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php000066400000000000000000000017161324732107100266520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; /** * Interface for a ConfigCache factory. This factory creates * an instance of ConfigCacheInterface and initializes the * cache if necessary. * * @author Matthias Pigulla */ interface ConfigCacheFactoryInterface { /** * Creates a cache instance and (re-)initializes it if necessary. * * @param string $file The absolute cache file path * @param callable $callable The callable to be executed when the cache needs to be filled (i. e. is not fresh). The cache will be passed as the only parameter to this callback * * @return ConfigCacheInterface $configCache The cache instance */ public function cache($file, $callable); } symfony-3.4.6/src/Symfony/Component/Config/ConfigCacheInterface.php000066400000000000000000000024601324732107100253170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Resource\ResourceInterface; /** * Interface for ConfigCache. * * @author Matthias Pigulla */ interface ConfigCacheInterface { /** * Gets the cache file path. * * @return string The cache file path */ public function getPath(); /** * Checks if the cache is still fresh. * * This check should take the metadata passed to the write() method into consideration. * * @return bool Whether the cache is still fresh */ public function isFresh(); /** * Writes the given content into the cache file. Metadata will be stored * independently and can be used to check cache freshness at a later time. * * @param string $content The content to write into the cache * @param ResourceInterface[]|null $metadata An array of ResourceInterface instances * * @throws \RuntimeException When the cache file cannot be written */ public function write($content, array $metadata = null); } symfony-3.4.6/src/Symfony/Component/Config/Definition/000077500000000000000000000000001324732107100227225ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Definition/ArrayNode.php000066400000000000000000000262741324732107100253320ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; use Symfony\Component\Config\Definition\Exception\UnsetKeyException; /** * Represents an Array node in the config tree. * * @author Johannes M. Schmitt */ class ArrayNode extends BaseNode implements PrototypeNodeInterface { protected $xmlRemappings = array(); protected $children = array(); protected $allowFalse = false; protected $allowNewKeys = true; protected $addIfNotSet = false; protected $performDeepMerging = true; protected $ignoreExtraKeys = false; protected $removeExtraKeys = true; protected $normalizeKeys = true; public function setNormalizeKeys($normalizeKeys) { $this->normalizeKeys = (bool) $normalizeKeys; } /** * Normalizes keys between the different configuration formats. * * Namely, you mostly have foo_bar in YAML while you have foo-bar in XML. * After running this method, all keys are normalized to foo_bar. * * If you have a mixed key like foo-bar_moo, it will not be altered. * The key will also not be altered if the target key already exists. * * @param mixed $value * * @return array The value with normalized keys */ protected function preNormalize($value) { if (!$this->normalizeKeys || !is_array($value)) { return $value; } $normalized = array(); foreach ($value as $k => $v) { if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) { $normalized[$normalizedKey] = $v; } else { $normalized[$k] = $v; } } return $normalized; } /** * Retrieves the children of this node. * * @return array The children */ public function getChildren() { return $this->children; } /** * Sets the xml remappings that should be performed. * * @param array $remappings An array of the form array(array(string, string)) */ public function setXmlRemappings(array $remappings) { $this->xmlRemappings = $remappings; } /** * Gets the xml remappings that should be performed. * * @return array $remappings an array of the form array(array(string, string)) */ public function getXmlRemappings() { return $this->xmlRemappings; } /** * Sets whether to add default values for this array if it has not been * defined in any of the configuration files. * * @param bool $boolean */ public function setAddIfNotSet($boolean) { $this->addIfNotSet = (bool) $boolean; } /** * Sets whether false is allowed as value indicating that the array should be unset. * * @param bool $allow */ public function setAllowFalse($allow) { $this->allowFalse = (bool) $allow; } /** * Sets whether new keys can be defined in subsequent configurations. * * @param bool $allow */ public function setAllowNewKeys($allow) { $this->allowNewKeys = (bool) $allow; } /** * Sets if deep merging should occur. * * @param bool $boolean */ public function setPerformDeepMerging($boolean) { $this->performDeepMerging = (bool) $boolean; } /** * Whether extra keys should just be ignore without an exception. * * @param bool $boolean To allow extra keys * @param bool $remove To remove extra keys */ public function setIgnoreExtraKeys($boolean, $remove = true) { $this->ignoreExtraKeys = (bool) $boolean; $this->removeExtraKeys = $this->ignoreExtraKeys && $remove; } /** * Sets the node Name. * * @param string $name The node's name */ public function setName($name) { $this->name = $name; } /** * Checks if the node has a default value. * * @return bool */ public function hasDefaultValue() { return $this->addIfNotSet; } /** * Retrieves the default value. * * @return array The default value * * @throws \RuntimeException if the node has no default value */ public function getDefaultValue() { if (!$this->hasDefaultValue()) { throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath())); } $defaults = array(); foreach ($this->children as $name => $child) { if ($child->hasDefaultValue()) { $defaults[$name] = $child->getDefaultValue(); } } return $defaults; } /** * Adds a child node. * * @throws \InvalidArgumentException when the child node has no name * @throws \InvalidArgumentException when the child node's name is not unique */ public function addChild(NodeInterface $node) { $name = $node->getName(); if (!strlen($name)) { throw new \InvalidArgumentException('Child nodes must be named.'); } if (isset($this->children[$name])) { throw new \InvalidArgumentException(sprintf('A child node named "%s" already exists.', $name)); } $this->children[$name] = $node; } /** * Finalizes the value of this node. * * @param mixed $value * * @return mixed The finalised value * * @throws UnsetKeyException * @throws InvalidConfigurationException if the node doesn't have enough children */ protected function finalizeValue($value) { if (false === $value) { $msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)); throw new UnsetKeyException($msg); } foreach ($this->children as $name => $child) { if (!array_key_exists($name, $value)) { if ($child->isRequired()) { $msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath()); $ex = new InvalidConfigurationException($msg); $ex->setPath($this->getPath()); throw $ex; } if ($child->hasDefaultValue()) { $value[$name] = $child->getDefaultValue(); } continue; } if ($child->isDeprecated()) { @trigger_error($child->getDeprecationMessage($name, $this->getPath()), E_USER_DEPRECATED); } try { $value[$name] = $child->finalize($value[$name]); } catch (UnsetKeyException $e) { unset($value[$name]); } } return $value; } /** * Validates the type of the value. * * @param mixed $value * * @throws InvalidTypeException */ protected function validateType($value) { if (!is_array($value) && (!$this->allowFalse || false !== $value)) { $ex = new InvalidTypeException(sprintf( 'Invalid type for path "%s". Expected array, but got %s', $this->getPath(), gettype($value) )); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } } /** * Normalizes the value. * * @param mixed $value The value to normalize * * @return mixed The normalized value * * @throws InvalidConfigurationException */ protected function normalizeValue($value) { if (false === $value) { return $value; } $value = $this->remapXml($value); $normalized = array(); foreach ($value as $name => $val) { if (isset($this->children[$name])) { $normalized[$name] = $this->children[$name]->normalize($val); unset($value[$name]); } elseif (!$this->removeExtraKeys) { $normalized[$name] = $val; } } // if extra fields are present, throw exception if (count($value) && !$this->ignoreExtraKeys) { $msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath()); $ex = new InvalidConfigurationException($msg); $ex->setPath($this->getPath()); throw $ex; } return $normalized; } /** * Remaps multiple singular values to a single plural value. * * @param array $value The source values * * @return array The remapped values */ protected function remapXml($value) { foreach ($this->xmlRemappings as list($singular, $plural)) { if (!isset($value[$singular])) { continue; } $value[$plural] = Processor::normalizeConfig($value, $singular, $plural); unset($value[$singular]); } return $value; } /** * Merges values together. * * @param mixed $leftSide The left side to merge * @param mixed $rightSide The right side to merge * * @return mixed The merged values * * @throws InvalidConfigurationException * @throws \RuntimeException */ protected function mergeValues($leftSide, $rightSide) { if (false === $rightSide) { // if this is still false after the last config has been merged the // finalization pass will take care of removing this key entirely return false; } if (false === $leftSide || !$this->performDeepMerging) { return $rightSide; } foreach ($rightSide as $k => $v) { // no conflict if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { $ex = new InvalidConfigurationException(sprintf( 'You are not allowed to define new elements for path "%s". ' .'Please define all elements for this path in one config file. ' .'If you are trying to overwrite an element, make sure you redefine it ' .'with the same name.', $this->getPath() )); $ex->setPath($this->getPath()); throw $ex; } $leftSide[$k] = $v; continue; } if (!isset($this->children[$k])) { throw new \RuntimeException('merge() expects a normalized config array.'); } $leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v); } return $leftSide; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/BaseNode.php000066400000000000000000000225631324732107100251230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; /** * The base node class. * * @author Johannes M. Schmitt */ abstract class BaseNode implements NodeInterface { protected $name; protected $parent; protected $normalizationClosures = array(); protected $finalValidationClosures = array(); protected $allowOverwrite = true; protected $required = false; protected $deprecationMessage = null; protected $equivalentValues = array(); protected $attributes = array(); /** * @param string $name The name of the node * @param NodeInterface $parent The parent of this node * * @throws \InvalidArgumentException if the name contains a period */ public function __construct($name, NodeInterface $parent = null) { if (false !== strpos($name, '.')) { throw new \InvalidArgumentException('The name must not contain ".".'); } $this->name = $name; $this->parent = $parent; } public function setAttribute($key, $value) { $this->attributes[$key] = $value; } public function getAttribute($key, $default = null) { return isset($this->attributes[$key]) ? $this->attributes[$key] : $default; } public function hasAttribute($key) { return isset($this->attributes[$key]); } public function getAttributes() { return $this->attributes; } public function setAttributes(array $attributes) { $this->attributes = $attributes; } public function removeAttribute($key) { unset($this->attributes[$key]); } /** * Sets an info message. * * @param string $info */ public function setInfo($info) { $this->setAttribute('info', $info); } /** * Returns info message. * * @return string The info text */ public function getInfo() { return $this->getAttribute('info'); } /** * Sets the example configuration for this node. * * @param string|array $example */ public function setExample($example) { $this->setAttribute('example', $example); } /** * Retrieves the example configuration for this node. * * @return string|array The example */ public function getExample() { return $this->getAttribute('example'); } /** * Adds an equivalent value. * * @param mixed $originalValue * @param mixed $equivalentValue */ public function addEquivalentValue($originalValue, $equivalentValue) { $this->equivalentValues[] = array($originalValue, $equivalentValue); } /** * Set this node as required. * * @param bool $boolean Required node */ public function setRequired($boolean) { $this->required = (bool) $boolean; } /** * Sets this node as deprecated. * * You can use %node% and %path% placeholders in your message to display, * respectively, the node name and its complete path. * * @param string|null $message Deprecated message */ public function setDeprecated($message) { $this->deprecationMessage = $message; } /** * Sets if this node can be overridden. * * @param bool $allow */ public function setAllowOverwrite($allow) { $this->allowOverwrite = (bool) $allow; } /** * Sets the closures used for normalization. * * @param \Closure[] $closures An array of Closures used for normalization */ public function setNormalizationClosures(array $closures) { $this->normalizationClosures = $closures; } /** * Sets the closures used for final validation. * * @param \Closure[] $closures An array of Closures used for final validation */ public function setFinalValidationClosures(array $closures) { $this->finalValidationClosures = $closures; } /** * Checks if this node is required. * * @return bool */ public function isRequired() { return $this->required; } /** * Checks if this node is deprecated. * * @return bool */ public function isDeprecated() { return null !== $this->deprecationMessage; } /** * Returns the deprecated message. * * @param string $node the configuration node name * @param string $path the path of the node * * @return string */ public function getDeprecationMessage($node, $path) { return strtr($this->deprecationMessage, array('%node%' => $node, '%path%' => $path)); } /** * Returns the name of this node. * * @return string The Node's name */ public function getName() { return $this->name; } /** * Retrieves the path of this node. * * @return string The Node's path */ public function getPath() { $path = $this->name; if (null !== $this->parent) { $path = $this->parent->getPath().'.'.$path; } return $path; } /** * Merges two values together. * * @param mixed $leftSide * @param mixed $rightSide * * @return mixed The merged value * * @throws ForbiddenOverwriteException */ final public function merge($leftSide, $rightSide) { if (!$this->allowOverwrite) { throw new ForbiddenOverwriteException(sprintf( 'Configuration path "%s" cannot be overwritten. You have to ' .'define all options for this path, and any of its sub-paths in ' .'one configuration section.', $this->getPath() )); } $this->validateType($leftSide); $this->validateType($rightSide); return $this->mergeValues($leftSide, $rightSide); } /** * Normalizes a value, applying all normalization closures. * * @param mixed $value Value to normalize * * @return mixed The normalized value */ final public function normalize($value) { $value = $this->preNormalize($value); // run custom normalization closures foreach ($this->normalizationClosures as $closure) { $value = $closure($value); } // replace value with their equivalent foreach ($this->equivalentValues as $data) { if ($data[0] === $value) { $value = $data[1]; } } // validate type $this->validateType($value); // normalize value return $this->normalizeValue($value); } /** * Normalizes the value before any other normalization is applied. * * @param $value * * @return $value The normalized array value */ protected function preNormalize($value) { return $value; } /** * Returns parent node for this node. * * @return NodeInterface|null */ public function getParent() { return $this->parent; } /** * Finalizes a value, applying all finalization closures. * * @param mixed $value The value to finalize * * @return mixed The finalized value * * @throws Exception * @throws InvalidConfigurationException */ final public function finalize($value) { $this->validateType($value); $value = $this->finalizeValue($value); // Perform validation on the final value if a closure has been set. // The closure is also allowed to return another value. foreach ($this->finalValidationClosures as $closure) { try { $value = $closure($value); } catch (Exception $e) { throw $e; } catch (\Exception $e) { throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": %s', $this->getPath(), $e->getMessage()), $e->getCode(), $e); } } return $value; } /** * Validates the type of a Node. * * @param mixed $value The value to validate * * @throws InvalidTypeException when the value is invalid */ abstract protected function validateType($value); /** * Normalizes the value. * * @param mixed $value The value to normalize * * @return mixed The normalized value */ abstract protected function normalizeValue($value); /** * Merges two values together. * * @param mixed $leftSide * @param mixed $rightSide * * @return mixed The merged value */ abstract protected function mergeValues($leftSide, $rightSide); /** * Finalizes a value. * * @param mixed $value The value to finalize * * @return mixed The finalized value */ abstract protected function finalizeValue($value); } symfony-3.4.6/src/Symfony/Component/Config/Definition/BooleanNode.php000066400000000000000000000022511324732107100256200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; /** * This node represents a Boolean value in the config tree. * * @author Johannes M. Schmitt */ class BooleanNode extends ScalarNode { /** * {@inheritdoc} */ protected function validateType($value) { if (!is_bool($value)) { $ex = new InvalidTypeException(sprintf( 'Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), gettype($value) )); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } } /** * {@inheritdoc} */ protected function isValueEmpty($value) { // a boolean value cannot be empty return false; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/000077500000000000000000000000001324732107100243105ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php000066400000000000000000000371321324732107100307240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; /** * This class provides a fluent interface for defining an array node. * * @author Johannes M. Schmitt */ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface { protected $performDeepMerging = true; protected $ignoreExtraKeys = false; protected $removeExtraKeys = true; protected $children = array(); protected $prototype; protected $atLeastOne = false; protected $allowNewKeys = true; protected $key; protected $removeKeyItem; protected $addDefaults = false; protected $addDefaultChildren = false; protected $nodeBuilder; protected $normalizeKeys = true; /** * {@inheritdoc} */ public function __construct($name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); $this->nullEquivalent = array(); $this->trueEquivalent = array(); } /** * Sets a custom children builder. */ public function setBuilder(NodeBuilder $builder) { $this->nodeBuilder = $builder; } /** * Returns a builder to add children nodes. * * @return NodeBuilder */ public function children() { return $this->getNodeBuilder(); } /** * Sets a prototype for child nodes. * * @param string $type The type of node * * @return NodeDefinition */ public function prototype($type) { return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this); } /** * @return VariableNodeDefinition */ public function variablePrototype() { return $this->prototype('variable'); } /** * @return ScalarNodeDefinition */ public function scalarPrototype() { return $this->prototype('scalar'); } /** * @return BooleanNodeDefinition */ public function booleanPrototype() { return $this->prototype('boolean'); } /** * @return IntegerNodeDefinition */ public function integerPrototype() { return $this->prototype('integer'); } /** * @return FloatNodeDefinition */ public function floatPrototype() { return $this->prototype('float'); } /** * @return ArrayNodeDefinition */ public function arrayPrototype() { return $this->prototype('array'); } /** * @return EnumNodeDefinition */ public function enumPrototype() { return $this->prototype('enum'); } /** * Adds the default value if the node is not set in the configuration. * * This method is applicable to concrete nodes only (not to prototype nodes). * If this function has been called and the node is not set during the finalization * phase, it's default value will be derived from its children default values. * * @return $this */ public function addDefaultsIfNotSet() { $this->addDefaults = true; return $this; } /** * Adds children with a default value when none are defined. * * This method is applicable to prototype nodes only. * * @param int|string|array|null $children The number of children|The child name|The children names to be added * * @return $this */ public function addDefaultChildrenIfNoneSet($children = null) { $this->addDefaultChildren = $children; return $this; } /** * Requires the node to have at least one element. * * This method is applicable to prototype nodes only. * * @return $this */ public function requiresAtLeastOneElement() { $this->atLeastOne = true; return $this; } /** * Disallows adding news keys in a subsequent configuration. * * If used all keys have to be defined in the same configuration file. * * @return $this */ public function disallowNewKeysInSubsequentConfigs() { $this->allowNewKeys = false; return $this; } /** * Sets a normalization rule for XML configurations. * * @param string $singular The key to remap * @param string $plural The plural of the key for irregular plurals * * @return $this */ public function fixXmlConfig($singular, $plural = null) { $this->normalization()->remap($singular, $plural); return $this; } /** * Sets the attribute which value is to be used as key. * * This is useful when you have an indexed array that should be an * associative array. You can select an item from within the array * to be the key of the particular item. For example, if "id" is the * "key", then: * * array( * array('id' => 'my_name', 'foo' => 'bar'), * ); * * becomes * * array( * 'my_name' => array('foo' => 'bar'), * ); * * If you'd like "'id' => 'my_name'" to still be present in the resulting * array, then you can set the second argument of this method to false. * * This method is applicable to prototype nodes only. * * @param string $name The name of the key * @param bool $removeKeyItem Whether or not the key item should be removed * * @return $this */ public function useAttributeAsKey($name, $removeKeyItem = true) { $this->key = $name; $this->removeKeyItem = $removeKeyItem; return $this; } /** * Sets whether the node can be unset. * * @param bool $allow * * @return $this */ public function canBeUnset($allow = true) { $this->merge()->allowUnset($allow); return $this; } /** * Adds an "enabled" boolean to enable the current section. * * By default, the section is disabled. If any configuration is specified then * the node will be automatically enabled: * * enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden * enableableArrayNode: ~ # The config is enabled & use the default values * enableableArrayNode: true # The config is enabled & use the default values * enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden * enableableArrayNode: {enabled: false, ...} # The config is disabled * enableableArrayNode: false # The config is disabled * * @return $this */ public function canBeEnabled() { $this ->addDefaultsIfNotSet() ->treatFalseLike(array('enabled' => false)) ->treatTrueLike(array('enabled' => true)) ->treatNullLike(array('enabled' => true)) ->beforeNormalization() ->ifArray() ->then(function ($v) { $v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true; return $v; }) ->end() ->children() ->booleanNode('enabled') ->defaultFalse() ; return $this; } /** * Adds an "enabled" boolean to enable the current section. * * By default, the section is enabled. * * @return $this */ public function canBeDisabled() { $this ->addDefaultsIfNotSet() ->treatFalseLike(array('enabled' => false)) ->treatTrueLike(array('enabled' => true)) ->treatNullLike(array('enabled' => true)) ->children() ->booleanNode('enabled') ->defaultTrue() ; return $this; } /** * Disables the deep merging of the node. * * @return $this */ public function performNoDeepMerging() { $this->performDeepMerging = false; return $this; } /** * Allows extra config keys to be specified under an array without * throwing an exception. * * Those config values are simply ignored and removed from the * resulting array. This should be used only in special cases where * you want to send an entire configuration array through a special * tree that processes only part of the array. * * @param bool $remove Whether to remove the extra keys * * @return $this */ public function ignoreExtraKeys($remove = true) { $this->ignoreExtraKeys = true; $this->removeExtraKeys = $remove; return $this; } /** * Sets key normalization. * * @param bool $bool Whether to enable key normalization * * @return $this */ public function normalizeKeys($bool) { $this->normalizeKeys = (bool) $bool; return $this; } /** * Appends a node definition. * * $node = new ArrayNodeDefinition() * ->children() * ->scalarNode('foo')->end() * ->scalarNode('baz')->end() * ->end() * ->append($this->getBarNodeDefinition()) * ; * * @return $this */ public function append(NodeDefinition $node) { $this->children[$node->name] = $node->setParent($this); return $this; } /** * Returns a node builder to be used to add children and prototype. * * @return NodeBuilder The node builder */ protected function getNodeBuilder() { if (null === $this->nodeBuilder) { $this->nodeBuilder = new NodeBuilder(); } return $this->nodeBuilder->setParent($this); } /** * {@inheritdoc} */ protected function createNode() { if (null === $this->prototype) { $node = new ArrayNode($this->name, $this->parent); $this->validateConcreteNode($node); $node->setAddIfNotSet($this->addDefaults); foreach ($this->children as $child) { $child->parent = $node; $node->addChild($child->getNode()); } } else { $node = new PrototypedArrayNode($this->name, $this->parent); $this->validatePrototypeNode($node); if (null !== $this->key) { $node->setKeyAttribute($this->key, $this->removeKeyItem); } if (false === $this->allowEmptyValue) { @trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), E_USER_DEPRECATED); } if (true === $this->atLeastOne) { $node->setMinNumberOfElements(1); } if ($this->default) { $node->setDefaultValue($this->defaultValue); } if (false !== $this->addDefaultChildren) { $node->setAddChildrenIfNoneSet($this->addDefaultChildren); if ($this->prototype instanceof static && null === $this->prototype->prototype) { $this->prototype->addDefaultsIfNotSet(); } } $this->prototype->parent = $node; $node->setPrototype($this->prototype->getNode()); } $node->setAllowNewKeys($this->allowNewKeys); $node->addEquivalentValue(null, $this->nullEquivalent); $node->addEquivalentValue(true, $this->trueEquivalent); $node->addEquivalentValue(false, $this->falseEquivalent); $node->setPerformDeepMerging($this->performDeepMerging); $node->setRequired($this->required); $node->setDeprecated($this->deprecationMessage); $node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys); $node->setNormalizeKeys($this->normalizeKeys); if (null !== $this->normalization) { $node->setNormalizationClosures($this->normalization->before); $node->setXmlRemappings($this->normalization->remappings); } if (null !== $this->merge) { $node->setAllowOverwrite($this->merge->allowOverwrite); $node->setAllowFalse($this->merge->allowFalse); } if (null !== $this->validation) { $node->setFinalValidationClosures($this->validation->rules); } return $node; } /** * Validate the configuration of a concrete node. * * @throws InvalidDefinitionException */ protected function validateConcreteNode(ArrayNode $node) { $path = $node->getPath(); if (null !== $this->key) { throw new InvalidDefinitionException( sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path) ); } if (false === $this->allowEmptyValue) { @trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), E_USER_DEPRECATED); } if (true === $this->atLeastOne) { throw new InvalidDefinitionException( sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path) ); } if ($this->default) { throw new InvalidDefinitionException( sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path) ); } if (false !== $this->addDefaultChildren) { throw new InvalidDefinitionException( sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path) ); } } /** * Validate the configuration of a prototype node. * * @throws InvalidDefinitionException */ protected function validatePrototypeNode(PrototypedArrayNode $node) { $path = $node->getPath(); if ($this->addDefaults) { throw new InvalidDefinitionException( sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path) ); } if (false !== $this->addDefaultChildren) { if ($this->default) { throw new InvalidDefinitionException( sprintf('A default value and default children might not be used together at path "%s"', $path) ); } if (null !== $this->key && (null === $this->addDefaultChildren || is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) { throw new InvalidDefinitionException( sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path) ); } if (null === $this->key && (is_string($this->addDefaultChildren) || is_array($this->addDefaultChildren))) { throw new InvalidDefinitionException( sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path) ); } } } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php000066400000000000000000000023651324732107100312250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\BooleanNode; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; /** * This class provides a fluent interface for defining a node. * * @author Johannes M. Schmitt */ class BooleanNodeDefinition extends ScalarNodeDefinition { /** * {@inheritdoc} */ public function __construct($name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); $this->nullEquivalent = true; } /** * Instantiate a Node. * * @return BooleanNode The node */ protected function instantiateNode() { return new BooleanNode($this->name, $this->parent); } /** * {@inheritdoc} * * @throws InvalidDefinitionException */ public function cannotBeEmpty() { throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.'); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php000066400000000000000000000023161324732107100305460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\EnumNode; /** * Enum Node Definition. * * @author Johannes M. Schmitt */ class EnumNodeDefinition extends ScalarNodeDefinition { private $values; /** * @return $this */ public function values(array $values) { $values = array_unique($values); if (empty($values)) { throw new \InvalidArgumentException('->values() must be called with at least one value.'); } $this->values = $values; return $this; } /** * Instantiate a Node. * * @return EnumNode The node * * @throws \RuntimeException */ protected function instantiateNode() { if (null === $this->values) { throw new \RuntimeException('You must call ->values() on enum nodes.'); } return new EnumNode($this->name, $this->parent, $this->values); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php000066400000000000000000000124211324732107100272460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\Exception\UnsetKeyException; /** * This class builds an if expression. * * @author Johannes M. Schmitt * @author Christophe Coevoet */ class ExprBuilder { protected $node; public $ifPart; public $thenPart; public function __construct(NodeDefinition $node) { $this->node = $node; } /** * Marks the expression as being always used. * * @return $this */ public function always(\Closure $then = null) { $this->ifPart = function ($v) { return true; }; if (null !== $then) { $this->thenPart = $then; } return $this; } /** * Sets a closure to use as tests. * * The default one tests if the value is true. * * @return $this */ public function ifTrue(\Closure $closure = null) { if (null === $closure) { $closure = function ($v) { return true === $v; }; } $this->ifPart = $closure; return $this; } /** * Tests if the value is a string. * * @return $this */ public function ifString() { $this->ifPart = function ($v) { return is_string($v); }; return $this; } /** * Tests if the value is null. * * @return $this */ public function ifNull() { $this->ifPart = function ($v) { return null === $v; }; return $this; } /** * Tests if the value is empty. * * @return ExprBuilder */ public function ifEmpty() { $this->ifPart = function ($v) { return empty($v); }; return $this; } /** * Tests if the value is an array. * * @return $this */ public function ifArray() { $this->ifPart = function ($v) { return is_array($v); }; return $this; } /** * Tests if the value is in an array. * * @return $this */ public function ifInArray(array $array) { $this->ifPart = function ($v) use ($array) { return in_array($v, $array, true); }; return $this; } /** * Tests if the value is not in an array. * * @return $this */ public function ifNotInArray(array $array) { $this->ifPart = function ($v) use ($array) { return !in_array($v, $array, true); }; return $this; } /** * Transforms variables of any type into an array. * * @return $this */ public function castToArray() { $this->ifPart = function ($v) { return !is_array($v); }; $this->thenPart = function ($v) { return array($v); }; return $this; } /** * Sets the closure to run if the test pass. * * @return $this */ public function then(\Closure $closure) { $this->thenPart = $closure; return $this; } /** * Sets a closure returning an empty array. * * @return $this */ public function thenEmptyArray() { $this->thenPart = function ($v) { return array(); }; return $this; } /** * Sets a closure marking the value as invalid at validation time. * * if you want to add the value of the node in your message just use a %s placeholder. * * @param string $message * * @return $this * * @throws \InvalidArgumentException */ public function thenInvalid($message) { $this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); }; return $this; } /** * Sets a closure unsetting this key of the array at validation time. * * @return $this * * @throws UnsetKeyException */ public function thenUnset() { $this->thenPart = function ($v) { throw new UnsetKeyException('Unsetting key'); }; return $this; } /** * Returns the related node. * * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition * * @throws \RuntimeException */ public function end() { if (null === $this->ifPart) { throw new \RuntimeException('You must specify an if part.'); } if (null === $this->thenPart) { throw new \RuntimeException('You must specify a then part.'); } return $this->node; } /** * Builds the expressions. * * @param ExprBuilder[] $expressions An array of ExprBuilder instances to build * * @return array */ public static function buildExpressions(array $expressions) { foreach ($expressions as $k => $expr) { if ($expr instanceof self) { $if = $expr->ifPart; $then = $expr->thenPart; $expressions[$k] = function ($v) use ($if, $then) { return $if($v) ? $then($v) : $v; }; } } return $expressions; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/FloatNodeDefinition.php000066400000000000000000000013711324732107100307070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\FloatNode; /** * This class provides a fluent interface for defining a float node. * * @author Jeanmonod David */ class FloatNodeDefinition extends NumericNodeDefinition { /** * Instantiates a Node. * * @return FloatNode The node */ protected function instantiateNode() { return new FloatNode($this->name, $this->parent, $this->min, $this->max); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/IntegerNodeDefinition.php000066400000000000000000000014041324732107100312340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\IntegerNode; /** * This class provides a fluent interface for defining an integer node. * * @author Jeanmonod David */ class IntegerNodeDefinition extends NumericNodeDefinition { /** * Instantiates a Node. * * @return IntegerNode The node */ protected function instantiateNode() { return new IntegerNode($this->name, $this->parent, $this->min, $this->max); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php000066400000000000000000000024641324732107100273750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * This class builds merge conditions. * * @author Johannes M. Schmitt */ class MergeBuilder { protected $node; public $allowFalse = false; public $allowOverwrite = true; public function __construct(NodeDefinition $node) { $this->node = $node; } /** * Sets whether the node can be unset. * * @param bool $allow * * @return $this */ public function allowUnset($allow = true) { $this->allowFalse = $allow; return $this; } /** * Sets whether the node can be overwritten. * * @param bool $deny Whether the overwriting is forbidden or not * * @return $this */ public function denyOverwrite($deny = true) { $this->allowOverwrite = !$deny; return $this; } /** * Returns the related node. * * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition */ public function end() { return $this->node; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php000066400000000000000000000132661324732107100272250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * This class provides a fluent interface for building a node. * * @author Johannes M. Schmitt */ class NodeBuilder implements NodeParentInterface { protected $parent; protected $nodeMapping; public function __construct() { $this->nodeMapping = array( 'variable' => __NAMESPACE__.'\\VariableNodeDefinition', 'scalar' => __NAMESPACE__.'\\ScalarNodeDefinition', 'boolean' => __NAMESPACE__.'\\BooleanNodeDefinition', 'integer' => __NAMESPACE__.'\\IntegerNodeDefinition', 'float' => __NAMESPACE__.'\\FloatNodeDefinition', 'array' => __NAMESPACE__.'\\ArrayNodeDefinition', 'enum' => __NAMESPACE__.'\\EnumNodeDefinition', ); } /** * Set the parent node. * * @return $this */ public function setParent(ParentNodeDefinitionInterface $parent = null) { $this->parent = $parent; return $this; } /** * Creates a child array node. * * @param string $name The name of the node * * @return ArrayNodeDefinition The child node */ public function arrayNode($name) { return $this->node($name, 'array'); } /** * Creates a child scalar node. * * @param string $name The name of the node * * @return ScalarNodeDefinition The child node */ public function scalarNode($name) { return $this->node($name, 'scalar'); } /** * Creates a child Boolean node. * * @param string $name The name of the node * * @return BooleanNodeDefinition The child node */ public function booleanNode($name) { return $this->node($name, 'boolean'); } /** * Creates a child integer node. * * @param string $name The name of the node * * @return IntegerNodeDefinition The child node */ public function integerNode($name) { return $this->node($name, 'integer'); } /** * Creates a child float node. * * @param string $name The name of the node * * @return FloatNodeDefinition The child node */ public function floatNode($name) { return $this->node($name, 'float'); } /** * Creates a child EnumNode. * * @param string $name * * @return EnumNodeDefinition */ public function enumNode($name) { return $this->node($name, 'enum'); } /** * Creates a child variable node. * * @param string $name The name of the node * * @return VariableNodeDefinition The builder of the child node */ public function variableNode($name) { return $this->node($name, 'variable'); } /** * Returns the parent node. * * @return ParentNodeDefinitionInterface|NodeDefinition The parent node */ public function end() { return $this->parent; } /** * Creates a child node. * * @param string $name The name of the node * @param string $type The type of the node * * @return NodeDefinition The child node * * @throws \RuntimeException When the node type is not registered * @throws \RuntimeException When the node class is not found */ public function node($name, $type) { $class = $this->getNodeClass($type); $node = new $class($name); $this->append($node); return $node; } /** * Appends a node definition. * * Usage: * * $node = new ArrayNodeDefinition('name') * ->children() * ->scalarNode('foo')->end() * ->scalarNode('baz')->end() * ->append($this->getBarNodeDefinition()) * ->end() * ; * * @return $this */ public function append(NodeDefinition $node) { if ($node instanceof ParentNodeDefinitionInterface) { $builder = clone $this; $builder->setParent(null); $node->setBuilder($builder); } if (null !== $this->parent) { $this->parent->append($node); // Make this builder the node parent to allow for a fluid interface $node->setParent($this); } return $this; } /** * Adds or overrides a node Type. * * @param string $type The name of the type * @param string $class The fully qualified name the node definition class * * @return $this */ public function setNodeClass($type, $class) { $this->nodeMapping[strtolower($type)] = $class; return $this; } /** * Returns the class name of the node definition. * * @param string $type The node type * * @return string The node definition class name * * @throws \RuntimeException When the node type is not registered * @throws \RuntimeException When the node class is not found */ protected function getNodeClass($type) { $type = strtolower($type); if (!isset($this->nodeMapping[$type])) { throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type)); } $class = $this->nodeMapping[$type]; if (!class_exists($class)) { throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class)); } return $class; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php000066400000000000000000000170431324732107100277240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; /** * This class provides a fluent interface for defining a node. * * @author Johannes M. Schmitt */ abstract class NodeDefinition implements NodeParentInterface { protected $name; protected $normalization; protected $validation; protected $defaultValue; protected $default = false; protected $required = false; protected $deprecationMessage = null; protected $merge; protected $allowEmptyValue = true; protected $nullEquivalent; protected $trueEquivalent = true; protected $falseEquivalent = false; protected $parent; protected $attributes = array(); /** * @param string $name The name of the node * @param NodeParentInterface|null $parent The parent */ public function __construct($name, NodeParentInterface $parent = null) { $this->parent = $parent; $this->name = $name; } /** * Sets the parent node. * * @return $this */ public function setParent(NodeParentInterface $parent) { $this->parent = $parent; return $this; } /** * Sets info message. * * @param string $info The info text * * @return $this */ public function info($info) { return $this->attribute('info', $info); } /** * Sets example configuration. * * @param string|array $example * * @return $this */ public function example($example) { return $this->attribute('example', $example); } /** * Sets an attribute on the node. * * @param string $key * @param mixed $value * * @return $this */ public function attribute($key, $value) { $this->attributes[$key] = $value; return $this; } /** * Returns the parent node. * * @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null The builder of the parent node */ public function end() { return $this->parent; } /** * Creates the node. * * @param bool $forceRootNode Whether to force this node as the root node * * @return NodeInterface */ public function getNode($forceRootNode = false) { if ($forceRootNode) { $this->parent = null; } if (null !== $this->normalization) { $this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before); } if (null !== $this->validation) { $this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules); } $node = $this->createNode(); $node->setAttributes($this->attributes); return $node; } /** * Sets the default value. * * @param mixed $value The default value * * @return $this */ public function defaultValue($value) { $this->default = true; $this->defaultValue = $value; return $this; } /** * Sets the node as required. * * @return $this */ public function isRequired() { $this->required = true; return $this; } /** * Sets the node as deprecated. * * You can use %node% and %path% placeholders in your message to display, * respectively, the node name and its complete path. * * @param string $message Deprecation message * * @return $this */ public function setDeprecated($message = 'The child node "%node%" at path "%path%" is deprecated.') { $this->deprecationMessage = $message; return $this; } /** * Sets the equivalent value used when the node contains null. * * @param mixed $value * * @return $this */ public function treatNullLike($value) { $this->nullEquivalent = $value; return $this; } /** * Sets the equivalent value used when the node contains true. * * @param mixed $value * * @return $this */ public function treatTrueLike($value) { $this->trueEquivalent = $value; return $this; } /** * Sets the equivalent value used when the node contains false. * * @param mixed $value * * @return $this */ public function treatFalseLike($value) { $this->falseEquivalent = $value; return $this; } /** * Sets null as the default value. * * @return $this */ public function defaultNull() { return $this->defaultValue(null); } /** * Sets true as the default value. * * @return $this */ public function defaultTrue() { return $this->defaultValue(true); } /** * Sets false as the default value. * * @return $this */ public function defaultFalse() { return $this->defaultValue(false); } /** * Sets an expression to run before the normalization. * * @return ExprBuilder */ public function beforeNormalization() { return $this->normalization()->before(); } /** * Denies the node value being empty. * * @return $this */ public function cannotBeEmpty() { $this->allowEmptyValue = false; return $this; } /** * Sets an expression to run for the validation. * * The expression receives the value of the node and must return it. It can * modify it. * An exception should be thrown when the node is not valid. * * @return ExprBuilder */ public function validate() { return $this->validation()->rule(); } /** * Sets whether the node can be overwritten. * * @param bool $deny Whether the overwriting is forbidden or not * * @return $this */ public function cannotBeOverwritten($deny = true) { $this->merge()->denyOverwrite($deny); return $this; } /** * Gets the builder for validation rules. * * @return ValidationBuilder */ protected function validation() { if (null === $this->validation) { $this->validation = new ValidationBuilder($this); } return $this->validation; } /** * Gets the builder for merging rules. * * @return MergeBuilder */ protected function merge() { if (null === $this->merge) { $this->merge = new MergeBuilder($this); } return $this->merge; } /** * Gets the builder for normalization rules. * * @return NormalizationBuilder */ protected function normalization() { if (null === $this->normalization) { $this->normalization = new NormalizationBuilder($this); } return $this->normalization; } /** * Instantiate and configure the node according to this definition. * * @return NodeInterface $node The node instance * * @throws InvalidDefinitionException When the definition is invalid */ abstract protected function createNode(); } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/NodeParentInterface.php000066400000000000000000000006771324732107100307130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * An interface that must be implemented by all node parents. * * @author Victor Berchet */ interface NodeParentInterface { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php000066400000000000000000000026211324732107100311570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * This class builds normalization conditions. * * @author Johannes M. Schmitt */ class NormalizationBuilder { protected $node; public $before = array(); public $remappings = array(); public function __construct(NodeDefinition $node) { $this->node = $node; } /** * Registers a key to remap to its plural form. * * @param string $key The key to remap * @param string $plural The plural of the key in case of irregular plural * * @return $this */ public function remap($key, $plural = null) { $this->remappings[] = array($key, null === $plural ? $key.'s' : $plural); return $this; } /** * Registers a closure to run before the normalization or an expression builder to build it if null is provided. * * @return ExprBuilder|$this */ public function before(\Closure $closure = null) { if (null !== $closure) { $this->before[] = $closure; return $this; } return $this->before[] = new ExprBuilder($this->node); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php000066400000000000000000000035771324732107100312560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; /** * Abstract class that contains common code of integer and float node definitions. * * @author David Jeanmonod */ abstract class NumericNodeDefinition extends ScalarNodeDefinition { protected $min; protected $max; /** * Ensures that the value is smaller than the given reference. * * @param mixed $max * * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ public function max($max) { if (isset($this->min) && $this->min > $max) { throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s)', $max, $this->min)); } $this->max = $max; return $this; } /** * Ensures that the value is bigger than the given reference. * * @param mixed $min * * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ public function min($min) { if (isset($this->max) && $this->max < $min) { throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s)', $min, $this->max)); } $this->min = $min; return $this; } /** * {@inheritdoc} * * @throws InvalidDefinitionException */ public function cannotBeEmpty() { throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.'); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php000066400000000000000000000011401324732107100327060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * An interface that must be implemented by nodes which can have children. * * @author Victor Berchet */ interface ParentNodeDefinitionInterface { public function children(); public function append(NodeDefinition $node); public function setBuilder(NodeBuilder $builder); } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php000066400000000000000000000013361324732107100310500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\ScalarNode; /** * This class provides a fluent interface for defining a node. * * @author Johannes M. Schmitt */ class ScalarNodeDefinition extends VariableNodeDefinition { /** * Instantiate a Node. * * @return ScalarNode The node */ protected function instantiateNode() { return new ScalarNode($this->name, $this->parent); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php000066400000000000000000000033211324732107100272260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\NodeInterface; /** * This is the entry class for building a config tree. * * @author Johannes M. Schmitt */ class TreeBuilder implements NodeParentInterface { protected $tree; protected $root; /** * @deprecated since 3.4. To be removed in 4.0 */ protected $builder; /** * Creates the root node. * * @param string $name The name of the root node * @param string $type The type of the root node * @param NodeBuilder $builder A custom node builder instance * * @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array') * * @throws \RuntimeException When the node type is not supported */ public function root($name, $type = 'array', NodeBuilder $builder = null) { $builder = $builder ?: new NodeBuilder(); return $this->root = $builder->node($name, $type)->setParent($this); } /** * Builds the tree. * * @return NodeInterface * * @throws \RuntimeException */ public function buildTree() { if (null === $this->root) { throw new \RuntimeException('The configuration tree has no root node.'); } if (null !== $this->tree) { return $this->tree; } return $this->tree = $this->root->getNode(true); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php000066400000000000000000000017121324732107100304230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; /** * This class builds validation conditions. * * @author Christophe Coevoet */ class ValidationBuilder { protected $node; public $rules = array(); public function __construct(NodeDefinition $node) { $this->node = $node; } /** * Registers a closure to run as normalization or an expression builder to build it if null is provided. * * @return ExprBuilder|$this */ public function rule(\Closure $closure = null) { if (null !== $closure) { $this->rules[] = $closure; return $this; } return $this->rules[] = new ExprBuilder($this->node); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php000066400000000000000000000032711324732107100313700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\VariableNode; /** * This class provides a fluent interface for defining a node. * * @author Johannes M. Schmitt */ class VariableNodeDefinition extends NodeDefinition { /** * Instantiate a Node. * * @return VariableNode The node */ protected function instantiateNode() { return new VariableNode($this->name, $this->parent); } /** * {@inheritdoc} */ protected function createNode() { $node = $this->instantiateNode(); if (null !== $this->normalization) { $node->setNormalizationClosures($this->normalization->before); } if (null !== $this->merge) { $node->setAllowOverwrite($this->merge->allowOverwrite); } if (true === $this->default) { $node->setDefaultValue($this->defaultValue); } $node->setAllowEmptyValue($this->allowEmptyValue); $node->addEquivalentValue(null, $this->nullEquivalent); $node->addEquivalentValue(true, $this->trueEquivalent); $node->addEquivalentValue(false, $this->falseEquivalent); $node->setRequired($this->required); $node->setDeprecated($this->deprecationMessage); if (null !== $this->validation) { $node->setFinalValidationClosures($this->validation->rules); } return $node; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/ConfigurationInterface.php000066400000000000000000000011451324732107100300640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; /** * Configuration interface. * * @author Victor Berchet */ interface ConfigurationInterface { /** * Generates the configuration tree builder. * * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder */ public function getConfigTreeBuilder(); } symfony-3.4.6/src/Symfony/Component/Config/Definition/Dumper/000077500000000000000000000000001324732107100241565ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php000066400000000000000000000242401324732107100304250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Dumper; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\EnumNode; use Symfony\Component\Config\Definition\PrototypedArrayNode; /** * Dumps a XML reference configuration for the given configuration/node instance. * * @author Wouter J */ class XmlReferenceDumper { private $reference; public function dump(ConfigurationInterface $configuration, $namespace = null) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace); } public function dumpNode(NodeInterface $node, $namespace = null) { $this->reference = ''; $this->writeNode($node, 0, true, $namespace); $ref = $this->reference; $this->reference = null; return $ref; } /** * @param NodeInterface $node * @param int $depth * @param bool $root If the node is the root node * @param string $namespace The namespace of the node */ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $namespace = null) { $rootName = ($root ? 'config' : $node->getName()); $rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null)); // xml remapping if ($node->getParent()) { $remapping = array_filter($node->getParent()->getXmlRemappings(), function ($mapping) use ($rootName) { return $rootName === $mapping[1]; }); if (count($remapping)) { list($singular) = current($remapping); $rootName = $singular; } } $rootName = str_replace('_', '-', $rootName); $rootAttributes = array(); $rootAttributeComments = array(); $rootChildren = array(); $rootComments = array(); if ($node instanceof ArrayNode) { $children = $node->getChildren(); // comments about the root node if ($rootInfo = $node->getInfo()) { $rootComments[] = $rootInfo; } if ($rootNamespace) { $rootComments[] = 'Namespace: '.$rootNamespace; } // render prototyped nodes if ($node instanceof PrototypedArrayNode) { $prototype = $node->getPrototype(); $info = 'prototype'; if (null !== $prototype->getInfo()) { $info .= ': '.$prototype->getInfo(); } array_unshift($rootComments, $info); if ($key = $node->getKeyAttribute()) { $rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key; } if ($prototype instanceof PrototypedArrayNode) { $prototype->setName($key); $children = array($key => $prototype); } elseif ($prototype instanceof ArrayNode) { $children = $prototype->getChildren(); } else { if ($prototype->hasDefaultValue()) { $prototypeValue = $prototype->getDefaultValue(); } else { switch (get_class($prototype)) { case 'Symfony\Component\Config\Definition\ScalarNode': $prototypeValue = 'scalar value'; break; case 'Symfony\Component\Config\Definition\FloatNode': case 'Symfony\Component\Config\Definition\IntegerNode': $prototypeValue = 'numeric value'; break; case 'Symfony\Component\Config\Definition\BooleanNode': $prototypeValue = 'true|false'; break; case 'Symfony\Component\Config\Definition\EnumNode': $prototypeValue = implode('|', array_map('json_encode', $prototype->getValues())); break; default: $prototypeValue = 'value'; } } } } // get attributes and elements foreach ($children as $child) { if (!$child instanceof ArrayNode) { // get attributes // metadata $name = str_replace('_', '-', $child->getName()); $value = '%%%%not_defined%%%%'; // use a string which isn't used in the normal world // comments $comments = array(); if ($info = $child->getInfo()) { $comments[] = $info; } if ($example = $child->getExample()) { $comments[] = 'Example: '.$example; } if ($child->isRequired()) { $comments[] = 'Required'; } if ($child->isDeprecated()) { $comments[] = sprintf('Deprecated (%s)', $child->getDeprecationMessage($child->getName(), $node->getPath())); } if ($child instanceof EnumNode) { $comments[] = 'One of '.implode('; ', array_map('json_encode', $child->getValues())); } if (count($comments)) { $rootAttributeComments[$name] = implode(";\n", $comments); } // default values if ($child->hasDefaultValue()) { $value = $child->getDefaultValue(); } // append attribute $rootAttributes[$name] = $value; } else { // get elements $rootChildren[] = $child; } } } // render comments // root node comment if (count($rootComments)) { foreach ($rootComments as $comment) { $this->writeLine('', $depth); } } // attribute comments if (count($rootAttributeComments)) { foreach ($rootAttributeComments as $attrName => $comment) { $commentDepth = $depth + 4 + strlen($attrName) + 2; $commentLines = explode("\n", $comment); $multiline = (count($commentLines) > 1); $comment = implode(PHP_EOL.str_repeat(' ', $commentDepth), $commentLines); if ($multiline) { $this->writeLine('', $depth); } else { $this->writeLine('', $depth); } } } // render start tag + attributes $rootIsVariablePrototype = isset($prototypeValue); $rootIsEmptyTag = (0 === count($rootChildren) && !$rootIsVariablePrototype); $rootOpenTag = '<'.$rootName; if (1 >= ($attributesCount = count($rootAttributes))) { if (1 === $attributesCount) { $rootOpenTag .= sprintf(' %s="%s"', current(array_keys($rootAttributes)), $this->writeValue(current($rootAttributes))); } $rootOpenTag .= $rootIsEmptyTag ? ' />' : '>'; if ($rootIsVariablePrototype) { $rootOpenTag .= $prototypeValue.''; } $this->writeLine($rootOpenTag, $depth); } else { $this->writeLine($rootOpenTag, $depth); $i = 1; foreach ($rootAttributes as $attrName => $attrValue) { $attr = sprintf('%s="%s"', $attrName, $this->writeValue($attrValue)); $this->writeLine($attr, $depth + 4); if ($attributesCount === $i++) { $this->writeLine($rootIsEmptyTag ? '/>' : '>', $depth); if ($rootIsVariablePrototype) { $rootOpenTag .= $prototypeValue.''; } } } } // render children tags foreach ($rootChildren as $child) { $this->writeLine(''); $this->writeNode($child, $depth + 4); } // render end tag if (!$rootIsEmptyTag && !$rootIsVariablePrototype) { $this->writeLine(''); $rootEndTag = ''; $this->writeLine($rootEndTag, $depth); } } /** * Outputs a single config reference line. * * @param string $text * @param int $indent */ private function writeLine($text, $indent = 0) { $indent = strlen($text) + $indent; $format = '%'.$indent.'s'; $this->reference .= sprintf($format, $text).PHP_EOL; } /** * Renders the string conversion of the value. * * @param mixed $value * * @return string */ private function writeValue($value) { if ('%%%%not_defined%%%%' === $value) { return ''; } if (is_string($value) || is_numeric($value)) { return $value; } if (false === $value) { return 'false'; } if (true === $value) { return 'true'; } if (null === $value) { return 'null'; } if (empty($value)) { return ''; } if (is_array($value)) { return implode(',', $value); } } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php000066400000000000000000000174431324732107100305760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Dumper; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\EnumNode; use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\ScalarNode; use Symfony\Component\Yaml\Inline; /** * Dumps a Yaml reference configuration for the given configuration/node instance. * * @author Kevin Bond */ class YamlReferenceDumper { private $reference; public function dump(ConfigurationInterface $configuration) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree()); } public function dumpAtPath(ConfigurationInterface $configuration, $path) { $rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree(); foreach (explode('.', $path) as $step) { if (!$node instanceof ArrayNode) { throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s"', $rootNode->getName(), $path)); } /** @var NodeInterface[] $children */ $children = $node instanceof PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren(); foreach ($children as $child) { if ($child->getName() === $step) { $node = $child; continue 2; } } throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s"', $rootNode->getName(), $path)); } return $this->dumpNode($node); } public function dumpNode(NodeInterface $node) { $this->reference = ''; $this->writeNode($node); $ref = $this->reference; $this->reference = null; return $ref; } /** * @param NodeInterface $node * @param NodeInterface|null $parentNode * @param int $depth * @param bool $prototypedArray */ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, $depth = 0, $prototypedArray = false) { $comments = array(); $default = ''; $defaultArray = null; $children = null; $example = $node->getExample(); // defaults if ($node instanceof ArrayNode) { $children = $node->getChildren(); if ($node instanceof PrototypedArrayNode) { $children = $this->getPrototypeChildren($node); } if (!$children) { if ($node->hasDefaultValue() && count($defaultArray = $node->getDefaultValue())) { $default = ''; } elseif (!is_array($example)) { $default = '[]'; } } } elseif ($node instanceof EnumNode) { $comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues())); $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~'; } else { $default = '~'; if ($node->hasDefaultValue()) { $default = $node->getDefaultValue(); if (is_array($default)) { if (count($defaultArray = $node->getDefaultValue())) { $default = ''; } elseif (!is_array($example)) { $default = '[]'; } } else { $default = Inline::dump($default); } } } // required? if ($node->isRequired()) { $comments[] = 'Required'; } // deprecated? if ($node->isDeprecated()) { $comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath())); } // example if ($example && !is_array($example)) { $comments[] = 'Example: '.$example; } $default = '' != (string) $default ? ' '.$default : ''; $comments = count($comments) ? '# '.implode(', ', $comments) : ''; $key = $prototypedArray ? '-' : $node->getName().':'; $text = rtrim(sprintf('%-21s%s %s', $key, $default, $comments), ' '); if ($info = $node->getInfo()) { $this->writeLine(''); // indenting multi-line info $info = str_replace("\n", sprintf("\n%".($depth * 4).'s# ', ' '), $info); $this->writeLine('# '.$info, $depth * 4); } $this->writeLine($text, $depth * 4); // output defaults if ($defaultArray) { $this->writeLine(''); $message = count($defaultArray) > 1 ? 'Defaults' : 'Default'; $this->writeLine('# '.$message.':', $depth * 4 + 4); $this->writeArray($defaultArray, $depth + 1); } if (is_array($example)) { $this->writeLine(''); $message = count($example) > 1 ? 'Examples' : 'Example'; $this->writeLine('# '.$message.':', $depth * 4 + 4); $this->writeArray($example, $depth + 1); } if ($children) { foreach ($children as $childNode) { $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute()); } } } /** * Outputs a single config reference line. * * @param string $text * @param int $indent */ private function writeLine($text, $indent = 0) { $indent = strlen($text) + $indent; $format = '%'.$indent.'s'; $this->reference .= sprintf($format, $text)."\n"; } private function writeArray(array $array, $depth) { $isIndexed = array_values($array) === $array; foreach ($array as $key => $value) { if (is_array($value)) { $val = ''; } else { $val = $value; } if ($isIndexed) { $this->writeLine('- '.$val, $depth * 4); } else { $this->writeLine(sprintf('%-20s %s', $key.':', $val), $depth * 4); } if (is_array($value)) { $this->writeArray($value, $depth + 1); } } } /** * @param PrototypedArrayNode $node * * @return array */ private function getPrototypeChildren(PrototypedArrayNode $node) { $prototype = $node->getPrototype(); $key = $node->getKeyAttribute(); // Do not expand prototype if it isn't an array node nor uses attribute as key if (!$key && !$prototype instanceof ArrayNode) { return $node->getChildren(); } if ($prototype instanceof ArrayNode) { $keyNode = new ArrayNode($key, $node); $children = $prototype->getChildren(); if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) { $children = $this->getPrototypeChildren($prototype); } // add children foreach ($children as $childNode) { $keyNode->addChild($childNode); } } else { $keyNode = new ScalarNode($key, $node); } $info = 'Prototype'; if (null !== $prototype->getInfo()) { $info .= ': '.$prototype->getInfo(); } $keyNode->setInfo($info); return array($key => $keyNode); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/EnumNode.php000066400000000000000000000027751324732107100251600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; /** * Node which only allows a finite set of values. * * @author Johannes M. Schmitt */ class EnumNode extends ScalarNode { private $values; public function __construct($name, NodeInterface $parent = null, array $values = array()) { $values = array_unique($values); if (empty($values)) { throw new \InvalidArgumentException('$values must contain at least one element.'); } parent::__construct($name, $parent); $this->values = $values; } public function getValues() { return $this->values; } protected function finalizeValue($value) { $value = parent::finalizeValue($value); if (!in_array($value, $this->values, true)) { $ex = new InvalidConfigurationException(sprintf( 'The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values)))); $ex->setPath($this->getPath()); throw $ex; } return $value; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/000077500000000000000000000000001324732107100246605ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/DuplicateKeyException.php000066400000000000000000000011051324732107100316300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * This exception is thrown whenever the key of an array is not unique. This can * only be the case if the configuration is coming from an XML file. * * @author Johannes M. Schmitt */ class DuplicateKeyException extends InvalidConfigurationException { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/Exception.php000066400000000000000000000007131324732107100273300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * Base exception for all configuration exceptions. * * @author Johannes M. Schmitt */ class Exception extends \RuntimeException { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php000066400000000000000000000011211324732107100330460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * This exception is thrown when a configuration path is overwritten from a * subsequent configuration file, but the entry node specifically forbids this. * * @author Johannes M. Schmitt */ class ForbiddenOverwriteException extends InvalidConfigurationException { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php000066400000000000000000000021221324732107100333630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * A very general exception which can be thrown whenever non of the more specific * exceptions is suitable. * * @author Johannes M. Schmitt */ class InvalidConfigurationException extends Exception { private $path; private $containsHints = false; public function setPath($path) { $this->path = $path; } public function getPath() { return $this->path; } /** * Adds extra information that is suffixed to the original exception message. * * @param string $hint */ public function addHint($hint) { if (!$this->containsHints) { $this->message .= "\nHint: ".$hint; $this->containsHints = true; } else { $this->message .= ', '.$hint; } } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/InvalidDefinitionException.php000066400000000000000000000007321324732107100326510ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * Thrown when an error is detected in a node Definition. * * @author Victor Berchet */ class InvalidDefinitionException extends Exception { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/InvalidTypeException.php000066400000000000000000000007551324732107100315070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * This exception is thrown if an invalid type is encountered. * * @author Johannes M. Schmitt */ class InvalidTypeException extends InvalidConfigurationException { } symfony-3.4.6/src/Symfony/Component/Config/Definition/Exception/UnsetKeyException.php000066400000000000000000000010341324732107100310150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition\Exception; /** * This exception is usually not encountered by the end-user, but only used * internally to signal the parent scope to unset a key. * * @author Johannes M. Schmitt */ class UnsetKeyException extends Exception { } symfony-3.4.6/src/Symfony/Component/Config/Definition/FloatNode.php000066400000000000000000000021201324732107100253010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; /** * This node represents a float value in the config tree. * * @author Jeanmonod David */ class FloatNode extends NumericNode { /** * {@inheritdoc} */ protected function validateType($value) { // Integers are also accepted, we just cast them if (is_int($value)) { $value = (float) $value; } if (!is_float($value)) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } } } symfony-3.4.6/src/Symfony/Component/Config/Definition/IntegerNode.php000066400000000000000000000017121324732107100256370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; /** * This node represents an integer value in the config tree. * * @author Jeanmonod David */ class IntegerNode extends NumericNode { /** * {@inheritdoc} */ protected function validateType($value) { if (!is_int($value)) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } } } symfony-3.4.6/src/Symfony/Component/Config/Definition/NodeInterface.php000066400000000000000000000036121324732107100261430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; /** * Common Interface among all nodes. * * In most cases, it is better to inherit from BaseNode instead of implementing * this interface yourself. * * @author Johannes M. Schmitt */ interface NodeInterface { /** * Returns the name of the node. * * @return string The name of the node */ public function getName(); /** * Returns the path of the node. * * @return string The node path */ public function getPath(); /** * Returns true when the node is required. * * @return bool If the node is required */ public function isRequired(); /** * Returns true when the node has a default value. * * @return bool If the node has a default value */ public function hasDefaultValue(); /** * Returns the default value of the node. * * @return mixed The default value * * @throws \RuntimeException if the node has no default value */ public function getDefaultValue(); /** * Normalizes the supplied value. * * @param mixed $value The value to normalize * * @return mixed The normalized value */ public function normalize($value); /** * Merges two values together. * * @param mixed $leftSide * @param mixed $rightSide * * @return mixed The merged values */ public function merge($leftSide, $rightSide); /** * Finalizes a value. * * @param mixed $value The value to finalize * * @return mixed The finalized value */ public function finalize($value); } symfony-3.4.6/src/Symfony/Component/Config/Definition/NumericNode.php000066400000000000000000000033151324732107100256450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; /** * This node represents a numeric value in the config tree. * * @author David Jeanmonod */ class NumericNode extends ScalarNode { protected $min; protected $max; public function __construct($name, NodeInterface $parent = null, $min = null, $max = null) { parent::__construct($name, $parent); $this->min = $min; $this->max = $max; } /** * {@inheritdoc} */ protected function finalizeValue($value) { $value = parent::finalizeValue($value); $errorMsg = null; if (isset($this->min) && $value < $this->min) { $errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min); } if (isset($this->max) && $value > $this->max) { $errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max); } if (isset($errorMsg)) { $ex = new InvalidConfigurationException($errorMsg); $ex->setPath($this->getPath()); throw $ex; } return $value; } /** * {@inheritdoc} */ protected function isValueEmpty($value) { // a numeric value cannot be empty return false; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/Processor.php000066400000000000000000000054471324732107100254240ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; /** * This class is the entry point for config normalization/merging/finalization. * * @author Johannes M. Schmitt */ class Processor { /** * Processes an array of configurations. * * @param NodeInterface $configTree The node tree describing the configuration * @param array $configs An array of configuration items to process * * @return array The processed configuration */ public function process(NodeInterface $configTree, array $configs) { $currentConfig = array(); foreach ($configs as $config) { $config = $configTree->normalize($config); $currentConfig = $configTree->merge($currentConfig, $config); } return $configTree->finalize($currentConfig); } /** * Processes an array of configurations. * * @param ConfigurationInterface $configuration The configuration class * @param array $configs An array of configuration items to process * * @return array The processed configuration */ public function processConfiguration(ConfigurationInterface $configuration, array $configs) { return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs); } /** * Normalizes a configuration entry. * * This method returns a normalize configuration array for a given key * to remove the differences due to the original format (YAML and XML mainly). * * Here is an example. * * The configuration in XML: * * twig.extension.foo * twig.extension.bar * * And the same configuration in YAML: * * extensions: ['twig.extension.foo', 'twig.extension.bar'] * * @param array $config A config array * @param string $key The key to normalize * @param string $plural The plural form of the key if it is irregular * * @return array */ public static function normalizeConfig($config, $key, $plural = null) { if (null === $plural) { $plural = $key.'s'; } if (isset($config[$plural])) { return $config[$plural]; } if (isset($config[$key])) { if (is_string($config[$key]) || !is_int(key($config[$key]))) { // only one return array($config[$key]); } return $config[$key]; } return array(); } } symfony-3.4.6/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php000066400000000000000000000011671324732107100300740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; /** * This interface must be implemented by nodes which can be used as prototypes. * * @author Johannes M. Schmitt */ interface PrototypeNodeInterface extends NodeInterface { /** * Sets the name of the node. * * @param string $name The name of the node */ public function setName($name); } symfony-3.4.6/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php000066400000000000000000000304621324732107100274160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Exception\DuplicateKeyException; use Symfony\Component\Config\Definition\Exception\UnsetKeyException; use Symfony\Component\Config\Definition\Exception\Exception; /** * Represents a prototyped Array node in the config tree. * * @author Johannes M. Schmitt */ class PrototypedArrayNode extends ArrayNode { protected $prototype; protected $keyAttribute; protected $removeKeyAttribute = false; protected $minNumberOfElements = 0; protected $defaultValue = array(); protected $defaultChildren; /** * @var NodeInterface[] An array of the prototypes of the simplified value children */ private $valuePrototypes = array(); /** * Sets the minimum number of elements that a prototype based node must * contain. By default this is zero, meaning no elements. * * @param int $number */ public function setMinNumberOfElements($number) { $this->minNumberOfElements = $number; } /** * Sets the attribute which value is to be used as key. * * This is useful when you have an indexed array that should be an * associative array. You can select an item from within the array * to be the key of the particular item. For example, if "id" is the * "key", then: * * array( * array('id' => 'my_name', 'foo' => 'bar'), * ); * * becomes * * array( * 'my_name' => array('foo' => 'bar'), * ); * * If you'd like "'id' => 'my_name'" to still be present in the resulting * array, then you can set the second argument of this method to false. * * @param string $attribute The name of the attribute which value is to be used as a key * @param bool $remove Whether or not to remove the key */ public function setKeyAttribute($attribute, $remove = true) { $this->keyAttribute = $attribute; $this->removeKeyAttribute = $remove; } /** * Retrieves the name of the attribute which value should be used as key. * * @return string The name of the attribute */ public function getKeyAttribute() { return $this->keyAttribute; } /** * Sets the default value of this node. * * @param string $value * * @throws \InvalidArgumentException if the default value is not an array */ public function setDefaultValue($value) { if (!is_array($value)) { throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.'); } $this->defaultValue = $value; } /** * Checks if the node has a default value. * * @return bool */ public function hasDefaultValue() { return true; } /** * Adds default children when none are set. * * @param int|string|array|null $children The number of children|The child name|The children names to be added */ public function setAddChildrenIfNoneSet($children = array('defaults')) { if (null === $children) { $this->defaultChildren = array('defaults'); } else { $this->defaultChildren = is_int($children) && $children > 0 ? range(1, $children) : (array) $children; } } /** * Retrieves the default value. * * The default value could be either explicited or derived from the prototype * default value. * * @return array The default value */ public function getDefaultValue() { if (null !== $this->defaultChildren) { $default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : array(); $defaults = array(); foreach (array_values($this->defaultChildren) as $i => $name) { $defaults[null === $this->keyAttribute ? $i : $name] = $default; } return $defaults; } return $this->defaultValue; } /** * Sets the node prototype. */ public function setPrototype(PrototypeNodeInterface $node) { $this->prototype = $node; } /** * Retrieves the prototype. * * @return PrototypeNodeInterface The prototype */ public function getPrototype() { return $this->prototype; } /** * Disable adding concrete children for prototyped nodes. * * @throws Exception */ public function addChild(NodeInterface $node) { throw new Exception('A prototyped array node can not have concrete children.'); } /** * Finalizes the value of this node. * * @param mixed $value * * @return mixed The finalized value * * @throws UnsetKeyException * @throws InvalidConfigurationException if the node doesn't have enough children */ protected function finalizeValue($value) { if (false === $value) { $msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)); throw new UnsetKeyException($msg); } foreach ($value as $k => $v) { $prototype = $this->getPrototypeForChild($k); try { $value[$k] = $prototype->finalize($v); } catch (UnsetKeyException $e) { unset($value[$k]); } } if (count($value) < $this->minNumberOfElements) { $msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements); $ex = new InvalidConfigurationException($msg); $ex->setPath($this->getPath()); throw $ex; } return $value; } /** * Normalizes the value. * * @param mixed $value The value to normalize * * @return mixed The normalized value * * @throws InvalidConfigurationException * @throws DuplicateKeyException */ protected function normalizeValue($value) { if (false === $value) { return $value; } $value = $this->remapXml($value); $isAssoc = array_keys($value) !== range(0, count($value) - 1); $normalized = array(); foreach ($value as $k => $v) { if (null !== $this->keyAttribute && is_array($v)) { if (!isset($v[$this->keyAttribute]) && is_int($k) && !$isAssoc) { $msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()); $ex = new InvalidConfigurationException($msg); $ex->setPath($this->getPath()); throw $ex; } elseif (isset($v[$this->keyAttribute])) { $k = $v[$this->keyAttribute]; // remove the key attribute when required if ($this->removeKeyAttribute) { unset($v[$this->keyAttribute]); } // if only "value" is left if (array_keys($v) === array('value')) { $v = $v['value']; if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && array_key_exists('value', $children)) { $valuePrototype = current($this->valuePrototypes) ?: clone $children['value']; $valuePrototype->parent = $this; $originalClosures = $this->prototype->normalizationClosures; if (is_array($originalClosures)) { $valuePrototypeClosures = $valuePrototype->normalizationClosures; $valuePrototype->normalizationClosures = is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures; } $this->valuePrototypes[$k] = $valuePrototype; } } } if (array_key_exists($k, $normalized)) { $msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()); $ex = new DuplicateKeyException($msg); $ex->setPath($this->getPath()); throw $ex; } } $prototype = $this->getPrototypeForChild($k); if (null !== $this->keyAttribute || $isAssoc) { $normalized[$k] = $prototype->normalize($v); } else { $normalized[] = $prototype->normalize($v); } } return $normalized; } /** * Merges values together. * * @param mixed $leftSide The left side to merge * @param mixed $rightSide The right side to merge * * @return mixed The merged values * * @throws InvalidConfigurationException * @throws \RuntimeException */ protected function mergeValues($leftSide, $rightSide) { if (false === $rightSide) { // if this is still false after the last config has been merged the // finalization pass will take care of removing this key entirely return false; } if (false === $leftSide || !$this->performDeepMerging) { return $rightSide; } foreach ($rightSide as $k => $v) { // prototype, and key is irrelevant, so simply append the element if (null === $this->keyAttribute) { $leftSide[] = $v; continue; } // no conflict if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { $ex = new InvalidConfigurationException(sprintf( 'You are not allowed to define new elements for path "%s". '. 'Please define all elements for this path in one config file.', $this->getPath() )); $ex->setPath($this->getPath()); throw $ex; } $leftSide[$k] = $v; continue; } $prototype = $this->getPrototypeForChild($k); $leftSide[$k] = $prototype->merge($leftSide[$k], $v); } return $leftSide; } /** * Returns a prototype for the child node that is associated to $key in the value array. * For general child nodes, this will be $this->prototype. * But if $this->removeKeyAttribute is true and there are only two keys in the child node: * one is same as this->keyAttribute and the other is 'value', then the prototype will be different. * * For example, assume $this->keyAttribute is 'name' and the value array is as follows: * array( * array( * 'name' => 'name001', * 'value' => 'value001' * ) * ) * * Now, the key is 0 and the child node is: * array( * 'name' => 'name001', * 'value' => 'value001' * ) * * When normalizing the value array, the 'name' element will removed from the child node * and its value becomes the new key of the child node: * array( * 'name001' => array('value' => 'value001') * ) * * Now only 'value' element is left in the child node which can be further simplified into a string: * array('name001' => 'value001') * * Now, the key becomes 'name001' and the child node becomes 'value001' and * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance. * * @param string $key The key of the child node * * @return mixed The prototype instance */ private function getPrototypeForChild($key) { $prototype = isset($this->valuePrototypes[$key]) ? $this->valuePrototypes[$key] : $this->prototype; $prototype->setName($key); return $prototype; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/ScalarNode.php000066400000000000000000000024511324732107100254500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; /** * This node represents a scalar value in the config tree. * * The following values are considered scalars: * * booleans * * strings * * null * * integers * * floats * * @author Johannes M. Schmitt */ class ScalarNode extends VariableNode { /** * {@inheritdoc} */ protected function validateType($value) { if (!is_scalar($value) && null !== $value) { $ex = new InvalidTypeException(sprintf( 'Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), gettype($value) )); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } } /** * {@inheritdoc} */ protected function isValueEmpty($value) { return null === $value || '' === $value; } } symfony-3.4.6/src/Symfony/Component/Config/Definition/VariableNode.php000066400000000000000000000056361324732107100260000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; /** * This node represents a value of variable type in the config tree. * * This node is intended for values of arbitrary type. * Any PHP type is accepted as a value. * * @author Jeremy Mikola */ class VariableNode extends BaseNode implements PrototypeNodeInterface { protected $defaultValueSet = false; protected $defaultValue; protected $allowEmptyValue = true; /** * {@inheritdoc} */ public function setDefaultValue($value) { $this->defaultValueSet = true; $this->defaultValue = $value; } /** * {@inheritdoc} */ public function hasDefaultValue() { return $this->defaultValueSet; } /** * {@inheritdoc} */ public function getDefaultValue() { $v = $this->defaultValue; return $v instanceof \Closure ? $v() : $v; } /** * Sets if this node is allowed to have an empty value. * * @param bool $boolean True if this entity will accept empty values */ public function setAllowEmptyValue($boolean) { $this->allowEmptyValue = (bool) $boolean; } /** * {@inheritdoc} */ public function setName($name) { $this->name = $name; } /** * {@inheritdoc} */ protected function validateType($value) { } /** * {@inheritdoc} */ protected function finalizeValue($value) { if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { $ex = new InvalidConfigurationException(sprintf( 'The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value) )); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } return $value; } /** * {@inheritdoc} */ protected function normalizeValue($value) { return $value; } /** * {@inheritdoc} */ protected function mergeValues($leftSide, $rightSide) { return $rightSide; } /** * Evaluates if the given value is to be treated as empty. * * By default, PHP's empty() function is used to test for emptiness. This * method may be overridden by subtypes to better match their understanding * of empty data. * * @param mixed $value * * @return bool */ protected function isValueEmpty($value) { return empty($value); } } symfony-3.4.6/src/Symfony/Component/Config/DependencyInjection/000077500000000000000000000000001324732107100245535ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/DependencyInjection/ConfigCachePass.php000066400000000000000000000035031324732107100302450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\DependencyInjection; @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use tagged iterator arguments instead.', ConfigCachePass::class), E_USER_DEPRECATED); use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority. * * @author Matthias Pigulla * @author Benjamin Klotz * * @deprecated since version 3.4, to be removed in 4.0. Use tagged iterator arguments instead. */ class ConfigCachePass implements CompilerPassInterface { use PriorityTaggedServiceTrait; private $factoryServiceId; private $resourceCheckerTag; public function __construct($factoryServiceId = 'config_cache_factory', $resourceCheckerTag = 'config_cache.resource_checker') { $this->factoryServiceId = $factoryServiceId; $this->resourceCheckerTag = $resourceCheckerTag; } public function process(ContainerBuilder $container) { $resourceCheckers = $this->findAndSortTaggedServices($this->resourceCheckerTag, $container); if (empty($resourceCheckers)) { return; } $container->getDefinition($this->factoryServiceId)->replaceArgument(0, new IteratorArgument($resourceCheckers)); } } symfony-3.4.6/src/Symfony/Component/Config/Exception/000077500000000000000000000000001324732107100225705ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php000066400000000000000000000015031324732107100336640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Exception; /** * Exception class for when a circular reference is detected when importing resources. * * @author Fabien Potencier */ class FileLoaderImportCircularReferenceException extends FileLoaderLoadException { public function __construct(array $resources, $code = null, $previous = null) { $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); \Exception::__construct($message, $code, $previous); } } symfony-3.4.6/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php000066400000000000000000000076321324732107100277760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Exception; /** * Exception class for when a resource cannot be loaded or imported. * * @author Ryan Weaver */ class FileLoaderLoadException extends \Exception { /** * @param string $resource The resource that could not be imported * @param string $sourceResource The original resource importing the new resource * @param int $code The error code * @param \Exception $previous A previous exception * @param string $type The type of resource */ public function __construct($resource, $sourceResource = null, $code = null, $previous = null, $type = null) { $message = ''; if ($previous) { // Include the previous exception, to help the user see what might be the underlying cause // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim... if ('.' === substr($previous->getMessage(), -1)) { $trimmedMessage = substr($previous->getMessage(), 0, -1); $message .= sprintf('%s', $trimmedMessage).' in '; } else { $message .= sprintf('%s', $previous->getMessage()).' in '; } $message .= $resource.' '; // show tweaked trace to complete the human readable sentence if (null === $sourceResource) { $message .= sprintf('(which is loaded in resource "%s")', $this->varToString($resource)); } else { $message .= sprintf('(which is being imported from "%s")', $this->varToString($sourceResource)); } $message .= '.'; // if there's no previous message, present it the default way } elseif (null === $sourceResource) { $message .= sprintf('Cannot load resource "%s".', $this->varToString($resource)); } else { $message .= sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource)); } // Is the resource located inside a bundle? if ('@' === $resource[0]) { $parts = explode(DIRECTORY_SEPARATOR, $resource); $bundle = substr($parts[0], 1); $message .= sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle); $message .= sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource); } elseif (null !== $type) { // maybe there is no loader for this specific type if ('annotation' === $type) { $message .= ' Make sure annotations are installed and enabled.'; } else { $message .= sprintf(' Make sure there is a loader supporting the "%s" type.', $type); } } parent::__construct($message, $code, $previous); } protected function varToString($var) { if (is_object($var)) { return sprintf('Object(%s)', get_class($var)); } if (is_array($var)) { $a = array(); foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); } return sprintf('Array(%s)', implode(', ', $a)); } if (is_resource($var)) { return sprintf('Resource(%s)', get_resource_type($var)); } if (null === $var) { return 'null'; } if (false === $var) { return 'false'; } if (true === $var) { return 'true'; } return (string) $var; } } symfony-3.4.6/src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php000066400000000000000000000014031324732107100316360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Exception; /** * File locator exception if a file does not exist. * * @author Leo Feyer */ class FileLocatorFileNotFoundException extends \InvalidArgumentException { private $paths; public function __construct($message = '', $code = 0, $previous = null, array $paths = array()) { parent::__construct($message, $code, $previous); $this->paths = $paths; } public function getPaths() { return $this->paths; } } symfony-3.4.6/src/Symfony/Component/Config/FileLocator.php000066400000000000000000000050301324732107100235440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; /** * FileLocator uses an array of pre-defined paths to find files. * * @author Fabien Potencier */ class FileLocator implements FileLocatorInterface { protected $paths; /** * @param string|array $paths A path or an array of paths where to look for resources */ public function __construct($paths = array()) { $this->paths = (array) $paths; } /** * {@inheritdoc} */ public function locate($name, $currentPath = null, $first = true) { if ('' == $name) { throw new \InvalidArgumentException('An empty file name is not valid to be located.'); } if ($this->isAbsolutePath($name)) { if (!file_exists($name)) { throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name), 0, null, array($name)); } return $name; } $paths = $this->paths; if (null !== $currentPath) { array_unshift($paths, $currentPath); } $paths = array_unique($paths); $filepaths = $notfound = array(); foreach ($paths as $path) { if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) { if (true === $first) { return $file; } $filepaths[] = $file; } else { $notfound[] = $file; } } if (!$filepaths) { throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)), 0, null, $notfound); } return $filepaths; } /** * Returns whether the file path is an absolute path. * * @param string $file A file path * * @return bool */ private function isAbsolutePath($file) { if ('/' === $file[0] || '\\' === $file[0] || (strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]) ) || null !== parse_url($file, PHP_URL_SCHEME) ) { return true; } return false; } } symfony-3.4.6/src/Symfony/Component/Config/FileLocatorInterface.php000066400000000000000000000020161324732107100253660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; /** * @author Fabien Potencier */ interface FileLocatorInterface { /** * Returns a full path for a given file name. * * @param string $name The file name to locate * @param string|null $currentPath The current path * @param bool $first Whether to return the first occurrence or an array of filenames * * @return string|array The full path to the file or an array of file paths * * @throws \InvalidArgumentException If $name is empty * @throws FileLocatorFileNotFoundException If a file is not found */ public function locate($name, $currentPath = null, $first = true); } symfony-3.4.6/src/Symfony/Component/Config/LICENSE000066400000000000000000000020511324732107100216350ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Component/Config/Loader/000077500000000000000000000000001324732107100220405ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Loader/DelegatingLoader.php000066400000000000000000000023751324732107100257520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; use Symfony\Component\Config\Exception\FileLoaderLoadException; /** * DelegatingLoader delegates loading to other loaders using a loader resolver. * * This loader acts as an array of LoaderInterface objects - each having * a chance to load a given resource (handled by the resolver) * * @author Fabien Potencier */ class DelegatingLoader extends Loader { public function __construct(LoaderResolverInterface $resolver) { $this->resolver = $resolver; } /** * {@inheritdoc} */ public function load($resource, $type = null) { if (false === $loader = $this->resolver->resolve($resource, $type)) { throw new FileLoaderLoadException($resource, null, null, null, $type); } return $loader->load($resource, $type); } /** * {@inheritdoc} */ public function supports($resource, $type = null) { return false !== $this->resolver->resolve($resource, $type); } } symfony-3.4.6/src/Symfony/Component/Config/Loader/FileLoader.php000066400000000000000000000126301324732107100245610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Config\Exception\FileLoaderLoadException; use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; use Symfony\Component\Config\Resource\FileExistenceResource; use Symfony\Component\Config\Resource\GlobResource; /** * FileLoader is the abstract class used by all built-in loaders that are file based. * * @author Fabien Potencier */ abstract class FileLoader extends Loader { protected static $loading = array(); protected $locator; private $currentDir; public function __construct(FileLocatorInterface $locator) { $this->locator = $locator; } /** * Sets the current directory. * * @param string $dir */ public function setCurrentDir($dir) { $this->currentDir = $dir; } /** * Returns the file locator used by this loader. * * @return FileLocatorInterface */ public function getLocator() { return $this->locator; } /** * Imports a resource. * * @param mixed $resource A Resource * @param string|null $type The resource type or null if unknown * @param bool $ignoreErrors Whether to ignore import errors or not * @param string|null $sourceResource The original resource importing the new resource * * @return mixed * * @throws FileLoaderLoadException * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) { if (is_string($resource) && strlen($resource) !== $i = strcspn($resource, '*?{[')) { $ret = array(); $isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/'); foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath) as $path => $info) { if (null !== $res = $this->doImport($path, $type, $ignoreErrors, $sourceResource)) { $ret[] = $res; } $isSubpath = true; } if ($isSubpath) { return isset($ret[1]) ? $ret : (isset($ret[0]) ? $ret[0] : null); } } return $this->doImport($resource, $type, $ignoreErrors, $sourceResource); } /** * @internal */ protected function glob($pattern, $recursive, &$resource = null, $ignoreErrors = false) { if (strlen($pattern) === $i = strcspn($pattern, '*?{[')) { $prefix = $pattern; $pattern = ''; } elseif (0 === $i || false === strpos(substr($pattern, 0, $i), '/')) { $prefix = '.'; $pattern = '/'.$pattern; } else { $prefix = dirname(substr($pattern, 0, 1 + $i)); $pattern = substr($pattern, strlen($prefix)); } try { $prefix = $this->locator->locate($prefix, $this->currentDir, true); } catch (FileLocatorFileNotFoundException $e) { if (!$ignoreErrors) { throw $e; } $resource = array(); foreach ($e->getPaths() as $path) { $resource[] = new FileExistenceResource($path); } return; } $resource = new GlobResource($prefix, $pattern, $recursive); foreach ($resource as $path => $info) { yield $path => $info; } } private function doImport($resource, $type = null, $ignoreErrors = false, $sourceResource = null) { try { $loader = $this->resolve($resource, $type); if ($loader instanceof self && null !== $this->currentDir) { $resource = $loader->getLocator()->locate($resource, $this->currentDir, false); } $resources = is_array($resource) ? $resource : array($resource); for ($i = 0; $i < $resourcesCount = count($resources); ++$i) { if (isset(self::$loading[$resources[$i]])) { if ($i == $resourcesCount - 1) { throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading)); } } else { $resource = $resources[$i]; break; } } self::$loading[$resource] = true; try { $ret = $loader->load($resource, $type); } finally { unset(self::$loading[$resource]); } return $ret; } catch (FileLoaderImportCircularReferenceException $e) { throw $e; } catch (\Exception $e) { if (!$ignoreErrors) { // prevent embedded imports from nesting multiple exceptions if ($e instanceof FileLoaderLoadException) { throw $e; } throw new FileLoaderLoadException($resource, $sourceResource, null, $e, $type); } } } } symfony-3.4.6/src/Symfony/Component/Config/Loader/GlobFileLoader.php000066400000000000000000000013121324732107100253600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; /** * GlobFileLoader loads files from a glob pattern. * * @author Fabien Potencier */ class GlobFileLoader extends FileLoader { /** * {@inheritdoc} */ public function load($resource, $type = null) { return $this->import($resource); } /** * {@inheritdoc} */ public function supports($resource, $type = null) { return 'glob' === $type; } } symfony-3.4.6/src/Symfony/Component/Config/Loader/Loader.php000066400000000000000000000035121324732107100237600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; use Symfony\Component\Config\Exception\FileLoaderLoadException; /** * Loader is the abstract class used by all built-in loaders. * * @author Fabien Potencier */ abstract class Loader implements LoaderInterface { protected $resolver; /** * {@inheritdoc} */ public function getResolver() { return $this->resolver; } /** * {@inheritdoc} */ public function setResolver(LoaderResolverInterface $resolver) { $this->resolver = $resolver; } /** * Imports a resource. * * @param mixed $resource A resource * @param string|null $type The resource type or null if unknown * * @return mixed */ public function import($resource, $type = null) { return $this->resolve($resource, $type)->load($resource, $type); } /** * Finds a loader able to load an imported resource. * * @param mixed $resource A resource * @param string|null $type The resource type or null if unknown * * @return $this|LoaderInterface * * @throws FileLoaderLoadException If no loader is found */ public function resolve($resource, $type = null) { if ($this->supports($resource, $type)) { return $this; } $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type); if (false === $loader) { throw new FileLoaderLoadException($resource, null, null, null, $type); } return $loader; } } symfony-3.4.6/src/Symfony/Component/Config/Loader/LoaderInterface.php000066400000000000000000000025161324732107100256040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; /** * LoaderInterface is the interface implemented by all loader classes. * * @author Fabien Potencier */ interface LoaderInterface { /** * Loads a resource. * * @param mixed $resource The resource * @param string|null $type The resource type or null if unknown * * @throws \Exception If something went wrong */ public function load($resource, $type = null); /** * Returns whether this class supports the given resource. * * @param mixed $resource A resource * @param string|null $type The resource type or null if unknown * * @return bool True if this class supports the given resource, false otherwise */ public function supports($resource, $type = null); /** * Gets the loader resolver. * * @return LoaderResolverInterface A LoaderResolverInterface instance */ public function getResolver(); /** * Sets the loader resolver. */ public function setResolver(LoaderResolverInterface $resolver); } symfony-3.4.6/src/Symfony/Component/Config/Loader/LoaderResolver.php000066400000000000000000000030711324732107100255020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; /** * LoaderResolver selects a loader for a given resource. * * A resource can be anything (e.g. a full path to a config file or a Closure). * Each loader determines whether it can load a resource and how. * * @author Fabien Potencier */ class LoaderResolver implements LoaderResolverInterface { /** * @var LoaderInterface[] An array of LoaderInterface objects */ private $loaders = array(); /** * @param LoaderInterface[] $loaders An array of loaders */ public function __construct(array $loaders = array()) { foreach ($loaders as $loader) { $this->addLoader($loader); } } /** * {@inheritdoc} */ public function resolve($resource, $type = null) { foreach ($this->loaders as $loader) { if ($loader->supports($resource, $type)) { return $loader; } } return false; } public function addLoader(LoaderInterface $loader) { $this->loaders[] = $loader; $loader->setResolver($this); } /** * Returns the registered loaders. * * @return LoaderInterface[] An array of LoaderInterface instances */ public function getLoaders() { return $this->loaders; } } symfony-3.4.6/src/Symfony/Component/Config/Loader/LoaderResolverInterface.php000066400000000000000000000014331324732107100273230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; /** * LoaderResolverInterface selects a loader for a given resource. * * @author Fabien Potencier */ interface LoaderResolverInterface { /** * Returns a loader able to load the resource. * * @param mixed $resource A resource * @param string|null $type The resource type or null if unknown * * @return LoaderInterface|false The loader or false if none is able to load the resource */ public function resolve($resource, $type = null); } symfony-3.4.6/src/Symfony/Component/Config/README.md000066400000000000000000000011761324732107100221160ustar00rootroot00000000000000Config Component ================ The Config component provides several classes to help you find, load, combine, autofill and validate configuration values of any kind, whatever their source may be (YAML, XML, INI files, or for instance a database). Resources --------- * [Documentation](https://symfony.com/doc/current/components/config/index.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) symfony-3.4.6/src/Symfony/Component/Config/Resource/000077500000000000000000000000001324732107100224215ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Resource/ClassExistenceResource.php000066400000000000000000000114721324732107100275640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * ClassExistenceResource represents a class existence. * Freshness is only evaluated against resource existence. * * The resource must be a fully-qualified class name. * * @author Fabien Potencier */ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializable { private $resource; private $exists; private static $autoloadLevel = 0; private static $autoloadedClass; private static $existsCache = array(); /** * @param string $resource The fully-qualified class name * @param bool|null $exists Boolean when the existency check has already been done */ public function __construct($resource, $exists = null) { $this->resource = $resource; if (null !== $exists) { $this->exists = (bool) $exists; } } /** * {@inheritdoc} */ public function __toString() { return $this->resource; } /** * @return string The file path to the resource */ public function getResource() { return $this->resource; } /** * {@inheritdoc} * * @throws \ReflectionException when a parent class/interface/trait is not found */ public function isFresh($timestamp) { $loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false); if (null !== $exists = &self::$existsCache[(int) (0 >= $timestamp)][$this->resource]) { $exists = $exists || $loaded; } elseif (!$exists = $loaded) { if (!self::$autoloadLevel++) { spl_autoload_register(__CLASS__.'::throwOnRequiredClass'); } $autoloadedClass = self::$autoloadedClass; self::$autoloadedClass = $this->resource; try { $exists = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false); } catch (\ReflectionException $e) { if (0 >= $timestamp) { unset(self::$existsCache[1][$this->resource]); throw $e; } } finally { self::$autoloadedClass = $autoloadedClass; if (!--self::$autoloadLevel) { spl_autoload_unregister(__CLASS__.'::throwOnRequiredClass'); } } } if (null === $this->exists) { $this->exists = $exists; } return $this->exists xor !$exists; } /** * {@inheritdoc} */ public function serialize() { if (null === $this->exists) { $this->isFresh(0); } return serialize(array($this->resource, $this->exists)); } /** * {@inheritdoc} */ public function unserialize($serialized) { list($this->resource, $this->exists) = unserialize($serialized); } /** * @throws \ReflectionException When $class is not found and is required */ private static function throwOnRequiredClass($class) { if (self::$autoloadedClass === $class) { return; } $e = new \ReflectionException("Class $class not found"); $trace = $e->getTrace(); $autoloadFrame = array( 'function' => 'spl_autoload_call', 'args' => array($class), ); $i = 1 + array_search($autoloadFrame, $trace, true); if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) { switch ($trace[$i]['function']) { case 'get_class_methods': case 'get_class_vars': case 'get_parent_class': case 'is_a': case 'is_subclass_of': case 'class_exists': case 'class_implements': case 'class_parents': case 'trait_exists': case 'defined': case 'interface_exists': case 'method_exists': case 'property_exists': case 'is_callable': return; } $props = array( 'file' => $trace[$i]['file'], 'line' => $trace[$i]['line'], 'trace' => array_slice($trace, 1 + $i), ); foreach ($props as $p => $v) { $r = new \ReflectionProperty('Exception', $p); $r->setAccessible(true); $r->setValue($e, $v); } } throw $e; } } symfony-3.4.6/src/Symfony/Component/Config/Resource/ComposerResource.php000066400000000000000000000033611324732107100264340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * ComposerResource tracks the PHP version and Composer dependencies. * * @author Nicolas Grekas */ class ComposerResource implements SelfCheckingResourceInterface, \Serializable { private $vendors; private static $runtimeVendors; public function __construct() { self::refresh(); $this->vendors = self::$runtimeVendors; } public function getVendors() { return array_keys($this->vendors); } /** * {@inheritdoc} */ public function __toString() { return __CLASS__; } /** * {@inheritdoc} */ public function isFresh($timestamp) { self::refresh(); return self::$runtimeVendors === $this->vendors; } public function serialize() { return serialize($this->vendors); } public function unserialize($serialized) { $this->vendors = unserialize($serialized); } private static function refresh() { self::$runtimeVendors = array(); foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $v = dirname(dirname($r->getFileName())); if (file_exists($v.'/composer/installed.json')) { self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json'); } } } } } symfony-3.4.6/src/Symfony/Component/Config/Resource/DirectoryResource.php000066400000000000000000000060601324732107100266100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * DirectoryResource represents a resources stored in a subdirectory tree. * * @author Fabien Potencier */ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable { private $resource; private $pattern; /** * @param string $resource The file path to the resource * @param string|null $pattern A pattern to restrict monitored files * * @throws \InvalidArgumentException */ public function __construct($resource, $pattern = null) { $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false); $this->pattern = $pattern; if (false === $this->resource || !is_dir($this->resource)) { throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $resource)); } } /** * {@inheritdoc} */ public function __toString() { return md5(serialize(array($this->resource, $this->pattern))); } /** * @return string The file path to the resource */ public function getResource() { return $this->resource; } /** * Returns the pattern to restrict monitored files. * * @return string|null */ public function getPattern() { return $this->pattern; } /** * {@inheritdoc} */ public function isFresh($timestamp) { if (!is_dir($this->resource)) { return false; } if ($timestamp < filemtime($this->resource)) { return false; } foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) { // if regex filtering is enabled only check matching files if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) { continue; } // always monitor directories for changes, except the .. entries // (otherwise deleted files wouldn't get detected) if ($file->isDir() && '/..' === substr($file, -3)) { continue; } // for broken links try { $fileMTime = $file->getMTime(); } catch (\RuntimeException $e) { continue; } // early return if a file's mtime exceeds the passed timestamp if ($timestamp < $fileMTime) { return false; } } return true; } public function serialize() { return serialize(array($this->resource, $this->pattern)); } public function unserialize($serialized) { list($this->resource, $this->pattern) = unserialize($serialized); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/FileExistenceResource.php000066400000000000000000000031531324732107100273730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * FileExistenceResource represents a resource stored on the filesystem. * Freshness is only evaluated against resource creation or deletion. * * The resource can be a file or a directory. * * @author Charles-Henri Bruyand */ class FileExistenceResource implements SelfCheckingResourceInterface, \Serializable { private $resource; private $exists; /** * @param string $resource The file path to the resource */ public function __construct($resource) { $this->resource = (string) $resource; $this->exists = file_exists($resource); } /** * {@inheritdoc} */ public function __toString() { return $this->resource; } /** * @return string The file path to the resource */ public function getResource() { return $this->resource; } /** * {@inheritdoc} */ public function isFresh($timestamp) { return file_exists($this->resource) === $this->exists; } /** * {@inheritdoc} */ public function serialize() { return serialize(array($this->resource, $this->exists)); } /** * {@inheritdoc} */ public function unserialize($serialized) { list($this->resource, $this->exists) = unserialize($serialized); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/FileResource.php000066400000000000000000000032401324732107100255200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * FileResource represents a resource stored on the filesystem. * * The resource can be a file or a directory. * * @author Fabien Potencier */ class FileResource implements SelfCheckingResourceInterface, \Serializable { /** * @var string|false */ private $resource; /** * @param string $resource The file path to the resource * * @throws \InvalidArgumentException */ public function __construct($resource) { $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false); if (false === $this->resource) { throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $resource)); } } /** * {@inheritdoc} */ public function __toString() { return $this->resource; } /** * @return string The canonicalized, absolute path to the resource */ public function getResource() { return $this->resource; } /** * {@inheritdoc} */ public function isFresh($timestamp) { return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp; } public function serialize() { return serialize($this->resource); } public function unserialize($serialized) { $this->resource = unserialize($serialized); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/GlobResource.php000066400000000000000000000111371324732107100255300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Glob; /** * GlobResource represents a set of resources stored on the filesystem. * * Only existence/removal is tracked (not mtimes.) * * @author Nicolas Grekas */ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface, \Serializable { private $prefix; private $pattern; private $recursive; private $hash; /** * @param string $prefix A directory prefix * @param string $pattern A glob pattern * @param bool $recursive Whether directories should be scanned recursively or not * * @throws \InvalidArgumentException */ public function __construct($prefix, $pattern, $recursive) { $this->prefix = realpath($prefix) ?: (file_exists($prefix) ? $prefix : false); $this->pattern = $pattern; $this->recursive = $recursive; if (false === $this->prefix) { throw new \InvalidArgumentException(sprintf('The path "%s" does not exist.', $prefix)); } } public function getPrefix() { return $this->prefix; } /** * {@inheritdoc} */ public function __toString() { return 'glob.'.$this->prefix.$this->pattern.(int) $this->recursive; } /** * {@inheritdoc} */ public function isFresh($timestamp) { $hash = $this->computeHash(); if (null === $this->hash) { $this->hash = $hash; } return $this->hash === $hash; } public function serialize() { if (null === $this->hash) { $this->hash = $this->computeHash(); } return serialize(array($this->prefix, $this->pattern, $this->recursive, $this->hash)); } public function unserialize($serialized) { list($this->prefix, $this->pattern, $this->recursive, $this->hash) = unserialize($serialized); } public function getIterator() { if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) { return; } if (false === strpos($this->pattern, '/**/') && (defined('GLOB_BRACE') || false === strpos($this->pattern, '{'))) { foreach (glob($this->prefix.$this->pattern, defined('GLOB_BRACE') ? GLOB_BRACE : 0) as $path) { if ($this->recursive && is_dir($path)) { $files = iterator_to_array(new \RecursiveIteratorIterator( new \RecursiveCallbackFilterIterator( new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), function (\SplFileInfo $file) { return '.' !== $file->getBasename()[0]; } ), \RecursiveIteratorIterator::LEAVES_ONLY )); uasort($files, function (\SplFileInfo $a, \SplFileInfo $b) { return (string) $a > (string) $b ? 1 : -1; }); foreach ($files as $path => $info) { if ($info->isFile()) { yield $path => $info; } } } elseif (is_file($path)) { yield $path => new \SplFileInfo($path); } } return; } if (!class_exists(Finder::class)) { throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern)); } $finder = new Finder(); $regex = Glob::toRegex($this->pattern); if ($this->recursive) { $regex = substr_replace($regex, '(/|$)', -2, 1); } $prefixLen = strlen($this->prefix); foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) { if (preg_match($regex, substr('\\' === \DIRECTORY_SEPARATOR ? str_replace('\\', '/', $path) : $path, $prefixLen)) && $info->isFile()) { yield $path => $info; } } } private function computeHash() { $hash = hash_init('md5'); foreach ($this->getIterator() as $path => $info) { hash_update($hash, $path."\n"); } return hash_final($hash); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/ReflectionClassResource.php000066400000000000000000000137501324732107100277300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * @author Nicolas Grekas */ class ReflectionClassResource implements SelfCheckingResourceInterface, \Serializable { private $files = array(); private $className; private $classReflector; private $excludedVendors = array(); private $hash; public function __construct(\ReflectionClass $classReflector, $excludedVendors = array()) { $this->className = $classReflector->name; $this->classReflector = $classReflector; $this->excludedVendors = $excludedVendors; } public function isFresh($timestamp) { if (null === $this->hash) { $this->hash = $this->computeHash(); $this->loadFiles($this->classReflector); } foreach ($this->files as $file => $v) { if (false === $filemtime = @filemtime($file)) { return false; } if ($filemtime > $timestamp) { return $this->hash === $this->computeHash(); } } return true; } public function __toString() { return 'reflection.'.$this->className; } public function serialize() { if (null === $this->hash) { $this->hash = $this->computeHash(); $this->loadFiles($this->classReflector); } return serialize(array($this->files, $this->className, $this->hash)); } public function unserialize($serialized) { list($this->files, $this->className, $this->hash) = unserialize($serialized); } private function loadFiles(\ReflectionClass $class) { foreach ($class->getInterfaces() as $v) { $this->loadFiles($v); } do { $file = $class->getFileName(); if (false !== $file && file_exists($file)) { foreach ($this->excludedVendors as $vendor) { if (0 === strpos($file, $vendor) && false !== strpbrk(substr($file, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) { $file = false; break; } } if ($file) { $this->files[$file] = null; } } foreach ($class->getTraits() as $v) { $this->loadFiles($v); } } while ($class = $class->getParentClass()); } private function computeHash() { if (null === $this->classReflector) { try { $this->classReflector = new \ReflectionClass($this->className); } catch (\ReflectionException $e) { // the class does not exist anymore return false; } } $hash = hash_init('md5'); foreach ($this->generateSignature($this->classReflector) as $info) { hash_update($hash, $info); } return hash_final($hash); } private function generateSignature(\ReflectionClass $class) { yield $class->getDocComment(); yield (int) $class->isFinal(); yield (int) $class->isAbstract(); if ($class->isTrait()) { yield print_r(class_uses($class->name), true); } else { yield print_r(class_parents($class->name), true); yield print_r(class_implements($class->name), true); yield print_r($class->getConstants(), true); } if (!$class->isInterface()) { $defaults = $class->getDefaultProperties(); foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) { yield $p->getDocComment().$p; yield print_r($defaults[$p->name], true); } } if (defined('HHVM_VERSION')) { foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) { // workaround HHVM bug with variadics, see https://github.com/facebook/hhvm/issues/5762 yield preg_replace('/^ @@.*/m', '', new ReflectionMethodHhvmWrapper($m->class, $m->name)); } } else { foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) { yield preg_replace('/^ @@.*/m', '', $m); $defaults = array(); foreach ($m->getParameters() as $p) { $defaults[$p->name] = $p->isDefaultValueAvailable() ? $p->getDefaultValue() : null; } yield print_r($defaults, true); } } if ($class->isSubclassOf(EventSubscriberInterface::class)) { yield EventSubscriberInterface::class; yield print_r(\call_user_func(array($class->name, 'getSubscribedEvents')), true); } if ($class->isSubclassOf(ServiceSubscriberInterface::class)) { yield ServiceSubscriberInterface::class; yield print_r(\call_user_func(array($class->name, 'getSubscribedServices')), true); } } } /** * @internal */ class ReflectionMethodHhvmWrapper extends \ReflectionMethod { public function getParameters() { $params = array(); foreach (parent::getParameters() as $i => $p) { $params[] = new ReflectionParameterHhvmWrapper(array($this->class, $this->name), $i); } return $params; } } /** * @internal */ class ReflectionParameterHhvmWrapper extends \ReflectionParameter { public function getDefaultValue() { return array($this->isVariadic(), $this->isDefaultValueAvailable() ? parent::getDefaultValue() : null); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/ResourceInterface.php000066400000000000000000000020231324732107100265370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * ResourceInterface is the interface that must be implemented by all Resource classes. * * @author Fabien Potencier */ interface ResourceInterface { /** * Returns a string representation of the Resource. * * This method is necessary to allow for resource de-duplication, for example by means * of array_unique(). The string returned need not have a particular meaning, but has * to be identical for different ResourceInterface instances referring to the same * resource; and it should be unlikely to collide with that of other, unrelated * resource instances. * * @return string A string representation unique to the underlying Resource */ public function __toString(); } symfony-3.4.6/src/Symfony/Component/Config/Resource/SelfCheckingResourceChecker.php000066400000000000000000000017421324732107100304600ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; use Symfony\Component\Config\ResourceCheckerInterface; /** * Resource checker for instances of SelfCheckingResourceInterface. * * As these resources perform the actual check themselves, we can provide * this class as a standard way of validating them. * * @author Matthias Pigulla */ class SelfCheckingResourceChecker implements ResourceCheckerInterface { public function supports(ResourceInterface $metadata) { return $metadata instanceof SelfCheckingResourceInterface; } public function isFresh(ResourceInterface $resource, $timestamp) { /* @var SelfCheckingResourceInterface $resource */ return $resource->isFresh($timestamp); } } symfony-3.4.6/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php000066400000000000000000000015021324732107100310060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * Interface for Resources that can check for freshness autonomously, * without special support from external services. * * @author Matthias Pigulla */ interface SelfCheckingResourceInterface extends ResourceInterface { /** * Returns true if the resource has not been updated since the given timestamp. * * @param int $timestamp The last time the resource was loaded * * @return bool True if the resource has not been updated, false otherwise */ public function isFresh($timestamp); } symfony-3.4.6/src/Symfony/Component/Config/ResourceCheckerConfigCache.php000066400000000000000000000126001324732107100264700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** * ResourceCheckerConfigCache uses instances of ResourceCheckerInterface * to check whether cached data is still fresh. * * @author Matthias Pigulla */ class ResourceCheckerConfigCache implements ConfigCacheInterface { /** * @var string */ private $file; /** * @var iterable|ResourceCheckerInterface[] */ private $resourceCheckers; /** * @param string $file The absolute cache path * @param iterable|ResourceCheckerInterface[] $resourceCheckers The ResourceCheckers to use for the freshness check */ public function __construct($file, $resourceCheckers = array()) { $this->file = $file; $this->resourceCheckers = $resourceCheckers; } /** * {@inheritdoc} */ public function getPath() { return $this->file; } /** * Checks if the cache is still fresh. * * This implementation will make a decision solely based on the ResourceCheckers * passed in the constructor. * * The first ResourceChecker that supports a given resource is considered authoritative. * Resources with no matching ResourceChecker will silently be ignored and considered fresh. * * @return bool true if the cache is fresh, false otherwise */ public function isFresh() { if (!is_file($this->file)) { return false; } if ($this->resourceCheckers instanceof \Traversable && !$this->resourceCheckers instanceof \Countable) { $this->resourceCheckers = iterator_to_array($this->resourceCheckers); } if (!count($this->resourceCheckers)) { return true; // shortcut - if we don't have any checkers we don't need to bother with the meta file at all } $metadata = $this->getMetaFile(); if (!is_file($metadata)) { return false; } $meta = $this->safelyUnserialize($metadata); if (false === $meta) { return false; } $time = filemtime($this->file); foreach ($meta as $resource) { /* @var ResourceInterface $resource */ foreach ($this->resourceCheckers as $checker) { if (!$checker->supports($resource)) { continue; // next checker } if ($checker->isFresh($resource, $time)) { break; // no need to further check this resource } return false; // cache is stale } // no suitable checker found, ignore this resource } return true; } /** * Writes cache. * * @param string $content The content to write in the cache * @param ResourceInterface[] $metadata An array of metadata * * @throws \RuntimeException When cache file can't be written */ public function write($content, array $metadata = null) { $mode = 0666; $umask = umask(); $filesystem = new Filesystem(); $filesystem->dumpFile($this->file, $content); try { $filesystem->chmod($this->file, $mode, $umask); } catch (IOException $e) { // discard chmod failure (some filesystem may not support it) } if (null !== $metadata) { $filesystem->dumpFile($this->getMetaFile(), serialize($metadata)); try { $filesystem->chmod($this->getMetaFile(), $mode, $umask); } catch (IOException $e) { // discard chmod failure (some filesystem may not support it) } } if (\function_exists('opcache_invalidate') && ini_get('opcache.enable')) { @opcache_invalidate($this->file, true); } } /** * Gets the meta file path. * * @return string The meta file path */ private function getMetaFile() { return $this->file.'.meta'; } private function safelyUnserialize($file) { $e = null; $meta = false; $signalingException = new \UnexpectedValueException(); $prevUnserializeHandler = ini_set('unserialize_callback_func', ''); $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$prevErrorHandler, $signalingException) { if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) { throw $signalingException; } return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false; }); try { $meta = unserialize(file_get_contents($file)); } catch (\Error $e) { } catch (\Exception $e) { } restore_error_handler(); ini_set('unserialize_callback_func', $prevUnserializeHandler); if (null !== $e && $e !== $signalingException) { throw $e; } return $meta; } } symfony-3.4.6/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php000066400000000000000000000023641324732107100300260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; /** * A ConfigCacheFactory implementation that validates the * cache with an arbitrary set of ResourceCheckers. * * @author Matthias Pigulla */ class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface { private $resourceCheckers = array(); /** * @param iterable|ResourceCheckerInterface[] $resourceCheckers */ public function __construct($resourceCheckers = array()) { $this->resourceCheckers = $resourceCheckers; } /** * {@inheritdoc} */ public function cache($file, $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', gettype($callback))); } $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers); if (!$cache->isFresh()) { call_user_func($callback, $cache); } return $cache; } } symfony-3.4.6/src/Symfony/Component/Config/ResourceCheckerInterface.php000066400000000000000000000030221324732107100262350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Resource\ResourceInterface; /** * Interface for ResourceCheckers. * * When a ResourceCheckerConfigCache instance is checked for freshness, all its associated * metadata resources are passed to ResourceCheckers. The ResourceCheckers * can then inspect the resources and decide whether the cache can be considered * fresh or not. * * @author Matthias Pigulla * @author Benjamin Klotz */ interface ResourceCheckerInterface { /** * Queries the ResourceChecker whether it can validate a given * resource or not. * * @param ResourceInterface $metadata The resource to be checked for freshness * * @return bool True if the ResourceChecker can handle this resource type, false if not */ public function supports(ResourceInterface $metadata); /** * Validates the resource. * * @param ResourceInterface $resource The resource to be validated * @param int $timestamp The timestamp at which the cache associated with this resource was created * * @return bool True if the resource has not changed since the given timestamp, false otherwise */ public function isFresh(ResourceInterface $resource, $timestamp); } symfony-3.4.6/src/Symfony/Component/Config/Tests/000077500000000000000000000000001324732107100217345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php000066400000000000000000000013671324732107100267750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\ConfigCacheFactory; class ConfigCacheFactoryTest extends TestCase { /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object". */ public function testCachWithInvalidCallback() { $cacheFactory = new ConfigCacheFactory(true); $cacheFactory->cache('file', new \stdClass()); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/ConfigCacheTest.php000066400000000000000000000046301324732107100254410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Tests\Resource\ResourceStub; class ConfigCacheTest extends TestCase { private $cacheFile = null; protected function setUp() { $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_'); } protected function tearDown() { $files = array($this->cacheFile, $this->cacheFile.'.meta'); foreach ($files as $file) { if (file_exists($file)) { unlink($file); } } } /** * @dataProvider debugModes */ public function testCacheIsNotValidIfNothingHasBeenCached($debug) { unlink($this->cacheFile); // remove tempnam() side effect $cache = new ConfigCache($this->cacheFile, $debug); $this->assertFalse($cache->isFresh()); } public function testIsAlwaysFreshInProduction() { $staleResource = new ResourceStub(); $staleResource->setFresh(false); $cache = new ConfigCache($this->cacheFile, false); $cache->write('', array($staleResource)); $this->assertTrue($cache->isFresh()); } /** * @dataProvider debugModes */ public function testIsFreshWhenNoResourceProvided($debug) { $cache = new ConfigCache($this->cacheFile, $debug); $cache->write('', array()); $this->assertTrue($cache->isFresh()); } public function testFreshResourceInDebug() { $freshResource = new ResourceStub(); $freshResource->setFresh(true); $cache = new ConfigCache($this->cacheFile, true); $cache->write('', array($freshResource)); $this->assertTrue($cache->isFresh()); } public function testStaleResourceInDebug() { $staleResource = new ResourceStub(); $staleResource->setFresh(false); $cache = new ConfigCache($this->cacheFile, true); $cache->write('', array($staleResource)); $this->assertFalse($cache->isFresh()); } public function debugModes() { return array( array(true), array(false), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/000077500000000000000000000000001324732107100240245ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php000066400000000000000000000204001324732107100272550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\ScalarNode; class ArrayNodeTest extends TestCase { /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException */ public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed() { $node = new ArrayNode('root'); $node->normalize(false); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Unrecognized option "foo" under "root" */ public function testExceptionThrownOnUnrecognizedChild() { $node = new ArrayNode('root'); $node->normalize(array('foo' => 'bar')); } public function ignoreAndRemoveMatrixProvider() { $unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"'); return array( array(true, true, array(), 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'), array(true, false, array('foo' => 'bar'), 'extra keys are not removed when ignoreExtraKeys second option is set to false'), array(false, true, $unrecognizedOptionException), array(false, false, $unrecognizedOptionException), ); } /** * @dataProvider ignoreAndRemoveMatrixProvider */ public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '') { if ($expected instanceof \Exception) { if (method_exists($this, 'expectException')) { $this->expectException(get_class($expected)); $this->expectExceptionMessage($expected->getMessage()); } else { $this->setExpectedException(get_class($expected), $expected->getMessage()); } } $node = new ArrayNode('root'); $node->setIgnoreExtraKeys($ignore, $remove); $result = $node->normalize(array('foo' => 'bar')); $this->assertSame($expected, $result, $message); } /** * @dataProvider getPreNormalizationTests */ public function testPreNormalize($denormalized, $normalized) { $node = new ArrayNode('foo'); $r = new \ReflectionMethod($node, 'preNormalize'); $r->setAccessible(true); $this->assertSame($normalized, $r->invoke($node, $denormalized)); } public function getPreNormalizationTests() { return array( array( array('foo-bar' => 'foo'), array('foo_bar' => 'foo'), ), array( array('foo-bar_moo' => 'foo'), array('foo-bar_moo' => 'foo'), ), array( array('anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'), array('anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'), ), array( array('foo-bar' => null, 'foo_bar' => 'foo'), array('foo-bar' => null, 'foo_bar' => 'foo'), ), ); } /** * @dataProvider getZeroNamedNodeExamplesData */ public function testNodeNameCanBeZero($denormalized, $normalized) { $zeroNode = new ArrayNode(0); $zeroNode->addChild(new ScalarNode('name')); $fiveNode = new ArrayNode(5); $fiveNode->addChild(new ScalarNode(0)); $fiveNode->addChild(new ScalarNode('new_key')); $rootNode = new ArrayNode('root'); $rootNode->addChild($zeroNode); $rootNode->addChild($fiveNode); $rootNode->addChild(new ScalarNode('string_key')); $r = new \ReflectionMethod($rootNode, 'normalizeValue'); $r->setAccessible(true); $this->assertSame($normalized, $r->invoke($rootNode, $denormalized)); } public function getZeroNamedNodeExamplesData() { return array( array( array( 0 => array( 'name' => 'something', ), 5 => array( 0 => 'this won\'t work too', 'new_key' => 'some other value', ), 'string_key' => 'just value', ), array( 0 => array( 'name' => 'something', ), 5 => array( 0 => 'this won\'t work too', 'new_key' => 'some other value', ), 'string_key' => 'just value', ), ), ); } /** * @dataProvider getPreNormalizedNormalizedOrderedData */ public function testChildrenOrderIsMaintainedOnNormalizeValue($prenormalized, $normalized) { $scalar1 = new ScalarNode('1'); $scalar2 = new ScalarNode('2'); $scalar3 = new ScalarNode('3'); $node = new ArrayNode('foo'); $node->addChild($scalar1); $node->addChild($scalar3); $node->addChild($scalar2); $r = new \ReflectionMethod($node, 'normalizeValue'); $r->setAccessible(true); $this->assertSame($normalized, $r->invoke($node, $prenormalized)); } public function getPreNormalizedNormalizedOrderedData() { return array( array( array('2' => 'two', '1' => 'one', '3' => 'three'), array('2' => 'two', '1' => 'one', '3' => 'three'), ), ); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Child nodes must be named. */ public function testAddChildEmptyName() { $node = new ArrayNode('root'); $childNode = new ArrayNode(''); $node->addChild($childNode); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage A child node named "foo" already exists. */ public function testAddChildNameAlreadyExists() { $node = new ArrayNode('root'); $childNode = new ArrayNode('foo'); $node->addChild($childNode); $childNodeWithSameName = new ArrayNode('foo'); $node->addChild($childNodeWithSameName); } /** * @expectedException \RuntimeException * @expectedExceptionMessage The node at path "foo" has no default value. */ public function testGetDefaultValueWithoutDefaultValue() { $node = new ArrayNode('foo'); $node->getDefaultValue(); } public function testSetDeprecated() { $childNode = new ArrayNode('foo'); $childNode->setDeprecated('"%node%" is deprecated'); $this->assertTrue($childNode->isDeprecated()); $this->assertSame('"foo" is deprecated', $childNode->getDeprecationMessage($childNode->getName(), $childNode->getPath())); $node = new ArrayNode('root'); $node->addChild($childNode); $deprecationTriggered = false; $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { if (E_USER_DEPRECATED === $level) { return $deprecationTriggered = true; } return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; }; $prevErrorHandler = set_error_handler($deprecationHandler); $node->finalize(array()); restore_error_handler(); $this->assertFalse($deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); $prevErrorHandler = set_error_handler($deprecationHandler); $node->finalize(array('foo' => array())); restore_error_handler(); $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php000066400000000000000000000032721324732107100275660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\BooleanNode; class BooleanNodeTest extends TestCase { /** * @dataProvider getValidValues */ public function testNormalize($value) { $node = new BooleanNode('test'); $this->assertSame($value, $node->normalize($value)); } /** * @dataProvider getValidValues * * @param bool $value */ public function testValidNonEmptyValues($value) { $node = new BooleanNode('test'); $node->setAllowEmptyValue(false); $this->assertSame($value, $node->finalize($value)); } public function getValidValues() { return array( array(false), array(true), ); } /** * @dataProvider getInvalidValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new BooleanNode('test'); $node->normalize($value); } public function getInvalidValues() { return array( array(null), array(''), array('foo'), array(0), array(1), array(0.0), array(0.1), array(array()), array(array('foo' => 'bar')), array(new \stdClass()), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/000077500000000000000000000000001324732107100254125ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php000066400000000000000000000266051324732107100326710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; class ArrayNodeDefinitionTest extends TestCase { public function testAppendingSomeNode() { $parent = new ArrayNodeDefinition('root'); $child = new ScalarNodeDefinition('child'); $parent ->children() ->scalarNode('foo')->end() ->scalarNode('bar')->end() ->end() ->append($child); $this->assertCount(3, $this->getField($parent, 'children')); $this->assertContains($child, $this->getField($parent, 'children')); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException * @dataProvider providePrototypeNodeSpecificCalls */ public function testPrototypeNodeSpecificOption($method, $args) { $node = new ArrayNodeDefinition('root'); call_user_func_array(array($node, $method), $args); $node->getNode(); } public function providePrototypeNodeSpecificCalls() { return array( array('defaultValue', array(array())), array('addDefaultChildrenIfNoneSet', array()), array('requiresAtLeastOneElement', array()), array('useAttributeAsKey', array('foo')), ); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException */ public function testConcreteNodeSpecificOption() { $node = new ArrayNodeDefinition('root'); $node ->addDefaultsIfNotSet() ->prototype('array') ; $node->getNode(); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException */ public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren() { $node = new ArrayNodeDefinition('root'); $node ->defaultValue(array()) ->addDefaultChildrenIfNoneSet('foo') ->prototype('array') ; $node->getNode(); } public function testPrototypedArrayNodeDefaultWhenUsingDefaultChildren() { $node = new ArrayNodeDefinition('root'); $node ->addDefaultChildrenIfNoneSet() ->prototype('array') ; $tree = $node->getNode(); $this->assertEquals(array(array()), $tree->getDefaultValue()); } /** * @dataProvider providePrototypedArrayNodeDefaults */ public function testPrototypedArrayNodeDefault($args, $shouldThrowWhenUsingAttrAsKey, $shouldThrowWhenNotUsingAttrAsKey, $defaults) { $node = new ArrayNodeDefinition('root'); $node ->addDefaultChildrenIfNoneSet($args) ->prototype('array') ; try { $tree = $node->getNode(); $this->assertFalse($shouldThrowWhenNotUsingAttrAsKey); $this->assertEquals($defaults, $tree->getDefaultValue()); } catch (InvalidDefinitionException $e) { $this->assertTrue($shouldThrowWhenNotUsingAttrAsKey); } $node = new ArrayNodeDefinition('root'); $node ->useAttributeAsKey('attr') ->addDefaultChildrenIfNoneSet($args) ->prototype('array') ; try { $tree = $node->getNode(); $this->assertFalse($shouldThrowWhenUsingAttrAsKey); $this->assertEquals($defaults, $tree->getDefaultValue()); } catch (InvalidDefinitionException $e) { $this->assertTrue($shouldThrowWhenUsingAttrAsKey); } } public function providePrototypedArrayNodeDefaults() { return array( array(null, true, false, array(array())), array(2, true, false, array(array(), array())), array('2', false, true, array('2' => array())), array('foo', false, true, array('foo' => array())), array(array('foo'), false, true, array('foo' => array())), array(array('foo', 'bar'), false, true, array('foo' => array(), 'bar' => array())), ); } public function testNestedPrototypedArrayNodes() { $nodeDefinition = new ArrayNodeDefinition('root'); $nodeDefinition ->addDefaultChildrenIfNoneSet() ->prototype('array') ->prototype('array') ; $node = $nodeDefinition->getNode(); $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node); $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node->getPrototype()); } public function testEnabledNodeDefaults() { $node = new ArrayNodeDefinition('root'); $node ->canBeEnabled() ->children() ->scalarNode('foo')->defaultValue('bar')->end() ; $this->assertEquals(array('enabled' => false, 'foo' => 'bar'), $node->getNode()->getDefaultValue()); } /** * @dataProvider getEnableableNodeFixtures */ public function testTrueEnableEnabledNode($expected, $config, $message) { $processor = new Processor(); $node = new ArrayNodeDefinition('root'); $node ->canBeEnabled() ->children() ->scalarNode('foo')->defaultValue('bar')->end() ; $this->assertEquals( $expected, $processor->process($node->getNode(), $config), $message ); } public function testCanBeDisabled() { $node = new ArrayNodeDefinition('root'); $node->canBeDisabled(); $this->assertTrue($this->getField($node, 'addDefaults')); $this->assertEquals(array('enabled' => false), $this->getField($node, 'falseEquivalent')); $this->assertEquals(array('enabled' => true), $this->getField($node, 'trueEquivalent')); $this->assertEquals(array('enabled' => true), $this->getField($node, 'nullEquivalent')); $nodeChildren = $this->getField($node, 'children'); $this->assertArrayHasKey('enabled', $nodeChildren); $enabledNode = $nodeChildren['enabled']; $this->assertTrue($this->getField($enabledNode, 'default')); $this->assertTrue($this->getField($enabledNode, 'defaultValue')); } public function testIgnoreExtraKeys() { $node = new ArrayNodeDefinition('root'); $this->assertFalse($this->getField($node, 'ignoreExtraKeys')); $result = $node->ignoreExtraKeys(); $this->assertEquals($node, $result); $this->assertTrue($this->getField($node, 'ignoreExtraKeys')); } public function testNormalizeKeys() { $node = new ArrayNodeDefinition('root'); $this->assertTrue($this->getField($node, 'normalizeKeys')); $result = $node->normalizeKeys(false); $this->assertEquals($node, $result); $this->assertFalse($this->getField($node, 'normalizeKeys')); } public function testPrototypeVariable() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('variable'), $node->variablePrototype()); } public function testPrototypeScalar() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('scalar'), $node->scalarPrototype()); } public function testPrototypeBoolean() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('boolean'), $node->booleanPrototype()); } public function testPrototypeInteger() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('integer'), $node->integerPrototype()); } public function testPrototypeFloat() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('float'), $node->floatPrototype()); } public function testPrototypeArray() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('array'), $node->arrayPrototype()); } public function testPrototypeEnum() { $node = new ArrayNodeDefinition('root'); $this->assertEquals($node->prototype('enum'), $node->enumPrototype()); } public function getEnableableNodeFixtures() { return array( array(array('enabled' => true, 'foo' => 'bar'), array(true), 'true enables an enableable node'), array(array('enabled' => true, 'foo' => 'bar'), array(null), 'null enables an enableable node'), array(array('enabled' => true, 'foo' => 'bar'), array(array('enabled' => true)), 'An enableable node can be enabled'), array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'), array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'), array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'), ); } public function testRequiresAtLeastOneElement() { $node = new ArrayNodeDefinition('root'); $node ->requiresAtLeastOneElement() ->integerPrototype(); $node->getNode()->finalize(array(1)); $this->addToAssertionCount(1); } /** * @group legacy * @expectedDeprecation Using Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::cannotBeEmpty() at path "root" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same. */ public function testCannotBeEmpty() { $node = new ArrayNodeDefinition('root'); $node ->cannotBeEmpty() ->integerPrototype(); $node->getNode()->finalize(array()); } public function testSetDeprecated() { $node = new ArrayNodeDefinition('root'); $node ->children() ->arrayNode('foo')->setDeprecated('The "%path%" node is deprecated.')->end() ->end() ; $deprecatedNode = $node->getNode()->getChildren()['foo']; $this->assertTrue($deprecatedNode->isDeprecated()); $this->assertSame('The "root.foo" node is deprecated.', $deprecatedNode->getDeprecationMessage($deprecatedNode->getName(), $deprecatedNode->getPath())); } /** * @group legacy * @expectedDeprecation ->cannotBeEmpty() is not applicable to concrete nodes at path "root". In 4.0 it will throw an exception. */ public function testCannotBeEmptyOnConcreteNode() { $node = new ArrayNodeDefinition('root'); $node->cannotBeEmpty(); $node->getNode()->finalize(array()); } protected function getField($object, $field) { $reflection = new \ReflectionProperty($object, $field); $reflection->setAccessible(true); return $reflection->getValue($object); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php000066400000000000000000000022531324732107100331630ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition; class BooleanNodeDefinitionTest extends TestCase { /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException * @expectedExceptionMessage ->cannotBeEmpty() is not applicable to BooleanNodeDefinition. */ public function testCannotBeEmptyThrowsAnException() { $def = new BooleanNodeDefinition('foo'); $def->cannotBeEmpty(); } public function testSetDeprecated() { $def = new BooleanNodeDefinition('foo'); $def->setDeprecated('The "%path%" node is deprecated.'); $node = $def->getNode(); $this->assertTrue($node->isDeprecated()); $this->assertSame('The "foo" node is deprecated.', $node->getDeprecationMessage($node->getName(), $node->getPath())); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php000066400000000000000000000041261324732107100325110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition; class EnumNodeDefinitionTest extends TestCase { public function testWithOneValue() { $def = new EnumNodeDefinition('foo'); $def->values(array('foo')); $node = $def->getNode(); $this->assertEquals(array('foo'), $node->getValues()); } public function testWithOneDistinctValue() { $def = new EnumNodeDefinition('foo'); $def->values(array('foo', 'foo')); $node = $def->getNode(); $this->assertEquals(array('foo'), $node->getValues()); } /** * @expectedException \RuntimeException * @expectedExceptionMessage You must call ->values() on enum nodes. */ public function testNoValuesPassed() { $def = new EnumNodeDefinition('foo'); $def->getNode(); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage ->values() must be called with at least one value. */ public function testWithNoValues() { $def = new EnumNodeDefinition('foo'); $def->values(array()); } public function testGetNode() { $def = new EnumNodeDefinition('foo'); $def->values(array('foo', 'bar')); $node = $def->getNode(); $this->assertEquals(array('foo', 'bar'), $node->getValues()); } public function testSetDeprecated() { $def = new EnumNodeDefinition('foo'); $def->values(array('foo', 'bar')); $def->setDeprecated('The "%path%" node is deprecated.'); $node = $def->getNode(); $this->assertTrue($node->isDeprecated()); $this->assertSame('The "foo" node is deprecated.', $def->getNode()->getDeprecationMessage($node->getName(), $node->getPath())); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php000066400000000000000000000175061324732107100312210ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class ExprBuilderTest extends TestCase { public function testAlwaysExpression() { $test = $this->getTestBuilder() ->always($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); } public function testIfTrueExpression() { $test = $this->getTestBuilder() ->ifTrue() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test, array('key' => true)); $test = $this->getTestBuilder() ->ifTrue(function ($v) { return true; }) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() ->ifTrue(function ($v) { return false; }) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); } public function testIfStringExpression() { $test = $this->getTestBuilder() ->ifString() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() ->ifString() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs(45, $test, array('key' => 45)); } public function testIfNullExpression() { $test = $this->getTestBuilder() ->ifNull() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test, array('key' => null)); $test = $this->getTestBuilder() ->ifNull() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); } public function testIfEmptyExpression() { $test = $this->getTestBuilder() ->ifEmpty() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test, array('key' => array())); $test = $this->getTestBuilder() ->ifEmpty() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); } public function testIfArrayExpression() { $test = $this->getTestBuilder() ->ifArray() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test, array('key' => array())); $test = $this->getTestBuilder() ->ifArray() ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); } public function testIfInArrayExpression() { $test = $this->getTestBuilder() ->ifInArray(array('foo', 'bar', 'value')) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() ->ifInArray(array('foo', 'bar')) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); } public function testIfNotInArrayExpression() { $test = $this->getTestBuilder() ->ifNotInArray(array('foo', 'bar')) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() ->ifNotInArray(array('foo', 'bar', 'value_from_config')) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); } public function testThenEmptyArrayExpression() { $test = $this->getTestBuilder() ->ifString() ->thenEmptyArray() ->end(); $this->assertFinalizedValueIs(array(), $test); } /** * @dataProvider castToArrayValues */ public function testcastToArrayExpression($configValue, $expectedValue) { $test = $this->getTestBuilder() ->castToArray() ->end(); $this->assertFinalizedValueIs($expectedValue, $test, array('key' => $configValue)); } public function castToArrayValues() { yield array('value', array('value')); yield array(-3.14, array(-3.14)); yield array(null, array(null)); yield array(array('value'), array('value')); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testThenInvalid() { $test = $this->getTestBuilder() ->ifString() ->thenInvalid('Invalid value') ->end(); $this->finalizeTestBuilder($test); } public function testThenUnsetExpression() { $test = $this->getTestBuilder() ->ifString() ->thenUnset() ->end(); $this->assertEquals(array(), $this->finalizeTestBuilder($test)); } /** * @expectedException \RuntimeException * @expectedExceptionMessage You must specify an if part. */ public function testEndIfPartNotSpecified() { $this->getTestBuilder()->end(); } /** * @expectedException \RuntimeException * @expectedExceptionMessage You must specify a then part. */ public function testEndThenPartNotSpecified() { $builder = $this->getTestBuilder(); $builder->ifPart = 'test'; $builder->end(); } /** * Create a test treebuilder with a variable node, and init the validation. * * @return TreeBuilder */ protected function getTestBuilder() { $builder = new TreeBuilder(); return $builder ->root('test') ->children() ->variableNode('key') ->validate() ; } /** * Close the validation process and finalize with the given config. * * @param TreeBuilder $testBuilder The tree builder to finalize * @param array $config The config you want to use for the finalization, if nothing provided * a simple array('key'=>'value') will be used * * @return array The finalized config values */ protected function finalizeTestBuilder($testBuilder, $config = null) { return $testBuilder ->end() ->end() ->end() ->buildTree() ->finalize(null === $config ? array('key' => 'value') : $config) ; } /** * Return a closure that will return the given value. * * @param mixed $val The value that the closure must return * * @return \Closure */ protected function returnClosure($val) { return function ($v) use ($val) { return $val; }; } /** * Assert that the given test builder, will return the given value. * * @param mixed $value The value to test * @param TreeBuilder $treeBuilder The tree builder to finalize * @param mixed $config The config values that new to be finalized */ protected function assertFinalizedValueIs($value, $treeBuilder, $config = null) { $this->assertEquals(array('key' => $value), $this->finalizeTestBuilder($treeBuilder, $config)); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php000066400000000000000000000052771324732107100311720ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder; use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition; class NodeBuilderTest extends TestCase { /** * @expectedException \RuntimeException */ public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNodeType() { $builder = new BaseNodeBuilder(); $builder->node('', 'foobar'); } /** * @expectedException \RuntimeException */ public function testThrowsAnExceptionWhenTheNodeClassIsNotFound() { $builder = new BaseNodeBuilder(); $builder ->setNodeClass('noclasstype', '\\foo\\bar\\noclass') ->node('', 'noclasstype'); } public function testAddingANewNodeType() { $class = __NAMESPACE__.'\\SomeNodeDefinition'; $builder = new BaseNodeBuilder(); $node = $builder ->setNodeClass('newtype', $class) ->node('', 'newtype'); $this->assertInstanceOf($class, $node); } public function testOverridingAnExistingNodeType() { $class = __NAMESPACE__.'\\SomeNodeDefinition'; $builder = new BaseNodeBuilder(); $node = $builder ->setNodeClass('variable', $class) ->node('', 'variable'); $this->assertInstanceOf($class, $node); } public function testNodeTypesAreNotCaseSensitive() { $builder = new BaseNodeBuilder(); $node1 = $builder->node('', 'VaRiAbLe'); $node2 = $builder->node('', 'variable'); $this->assertInstanceOf(get_class($node1), $node2); $builder->setNodeClass('CuStOm', __NAMESPACE__.'\\SomeNodeDefinition'); $node1 = $builder->node('', 'CUSTOM'); $node2 = $builder->node('', 'custom'); $this->assertInstanceOf(get_class($node1), $node2); } public function testNumericNodeCreation() { $builder = new BaseNodeBuilder(); $node = $builder->integerNode('foo')->min(3)->max(5); $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition', $node); $node = $builder->floatNode('bar')->min(3.0)->max(5.0); $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\FloatNodeDefinition', $node); } } class SomeNodeDefinition extends BaseVariableNodeDefinition { } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php000066400000000000000000000067401324732107100332130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition as NumericNodeDefinition; use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition; use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition; class NumericNodeDefinitionTest extends TestCase { /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage You cannot define a min(4) as you already have a max(3) */ public function testIncoherentMinAssertion() { $def = new NumericNodeDefinition('foo'); $def->max(3)->min(4); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage You cannot define a max(2) as you already have a min(3) */ public function testIncoherentMaxAssertion() { $node = new NumericNodeDefinition('foo'); $node->min(3)->max(2); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value 4 is too small for path "foo". Should be greater than or equal to 5 */ public function testIntegerMinAssertion() { $def = new IntegerNodeDefinition('foo'); $def->min(5)->getNode()->finalize(4); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value 4 is too big for path "foo". Should be less than or equal to 3 */ public function testIntegerMaxAssertion() { $def = new IntegerNodeDefinition('foo'); $def->max(3)->getNode()->finalize(4); } public function testIntegerValidMinMaxAssertion() { $def = new IntegerNodeDefinition('foo'); $node = $def->min(3)->max(7)->getNode(); $this->assertEquals(4, $node->finalize(4)); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value 400 is too small for path "foo". Should be greater than or equal to 500 */ public function testFloatMinAssertion() { $def = new FloatNodeDefinition('foo'); $def->min(5E2)->getNode()->finalize(4e2); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value 4.3 is too big for path "foo". Should be less than or equal to 0.3 */ public function testFloatMaxAssertion() { $def = new FloatNodeDefinition('foo'); $def->max(0.3)->getNode()->finalize(4.3); } public function testFloatValidMinMaxAssertion() { $def = new FloatNodeDefinition('foo'); $node = $def->min(3.0)->max(7e2)->getNode(); $this->assertEquals(4.5, $node->finalize(4.5)); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException * @expectedExceptionMessage ->cannotBeEmpty() is not applicable to NumericNodeDefinition. */ public function testCannotBeEmptyThrowsAnException() { $def = new NumericNodeDefinition('foo'); $def->cannotBeEmpty(); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php000066400000000000000000000106601324732107100311740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class TreeBuilderTest extends TestCase { public function testUsingACustomNodeBuilder() { $builder = new TreeBuilder(); $root = $builder->root('custom', 'array', new CustomNodeBuilder()); $nodeBuilder = $root->children(); $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); $nodeBuilder = $nodeBuilder->arrayNode('deeper')->children(); $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); } public function testOverrideABuiltInNodeType() { $builder = new TreeBuilder(); $root = $builder->root('override', 'array', new CustomNodeBuilder()); $definition = $root->children()->variableNode('variable'); $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition', $definition); } public function testAddANodeType() { $builder = new TreeBuilder(); $root = $builder->root('override', 'array', new CustomNodeBuilder()); $definition = $root->children()->barNode('variable'); $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition', $definition); } public function testCreateABuiltInNodeTypeWithACustomNodeBuilder() { $builder = new TreeBuilder(); $root = $builder->root('builtin', 'array', new CustomNodeBuilder()); $definition = $root->children()->booleanNode('boolean'); $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition', $definition); } public function testPrototypedArrayNodeUseTheCustomNodeBuilder() { $builder = new TreeBuilder(); $root = $builder->root('override', 'array', new CustomNodeBuilder()); $root->prototype('bar')->end(); $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\BarNode', $root->getNode(true)->getPrototype()); } public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren() { $builder = new TreeBuilder(); $builder->root('propagation') ->children() ->setNodeClass('extended', 'Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition') ->node('foo', 'extended')->end() ->arrayNode('child') ->children() ->node('foo', 'extended') ->end() ->end() ->end() ->end(); $node = $builder->buildTree(); $children = $node->getChildren(); $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $children['foo']); $childChildren = $children['child']->getChildren(); $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $childChildren['foo']); } public function testDefinitionInfoGetsTransferredToNode() { $builder = new TreeBuilder(); $builder->root('test')->info('root info') ->children() ->node('child', 'variable')->info('child info')->defaultValue('default') ->end() ->end(); $tree = $builder->buildTree(); $children = $tree->getChildren(); $this->assertEquals('root info', $tree->getInfo()); $this->assertEquals('child info', $children['child']->getInfo()); } public function testDefinitionExampleGetsTransferredToNode() { $builder = new TreeBuilder(); $builder->root('test') ->example(array('key' => 'value')) ->children() ->node('child', 'variable')->info('child info')->defaultValue('default')->example('example') ->end() ->end(); $tree = $builder->buildTree(); $children = $tree->getChildren(); $this->assertInternalType('array', $tree->getExample()); $this->assertEquals('example', $children['child']->getExample()); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Dumper/000077500000000000000000000000001324732107100252605ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php000066400000000000000000000056771324732107100324040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Dumper; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper; use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; class XmlReferenceDumperTest extends TestCase { public function testDumper() { $configuration = new ExampleConfiguration(); $dumper = new XmlReferenceDumper(); $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); } public function testNamespaceDumper() { $configuration = new ExampleConfiguration(); $dumper = new XmlReferenceDumper(); $this->assertEquals(str_replace('http://example.org/schema/dic/acme_root', 'http://symfony.com/schema/dic/symfony', $this->getConfigurationAsString()), $dumper->dump($configuration, 'http://symfony.com/schema/dic/symfony')); } private function getConfigurationAsString() { return str_replace("\n", PHP_EOL, <<<'EOL' scalar value scalar value EOL ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php000066400000000000000000000070411324732107100325310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition\Dumper; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; class YamlReferenceDumperTest extends TestCase { public function testDumper() { $configuration = new ExampleConfiguration(); $dumper = new YamlReferenceDumper(); $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); } public function provideDumpAtPath() { return array( 'Regular node' => array('scalar_true', << array('array', << array('array.child2', << array('cms_pages.page', << array('cms_pages.page.locale', <<assertSame(trim($expected), trim($dumper->dumpAtPath($configuration, $path))); } private function getConfigurationAsString() { return <<<'EOL' acme_root: boolean: true scalar_empty: ~ scalar_null: null scalar_true: true scalar_false: false scalar_default: default scalar_array_empty: [] scalar_array_defaults: # Defaults: - elem1 - elem2 scalar_required: ~ # Required scalar_deprecated: ~ # Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.) scalar_deprecated_with_message: ~ # Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") node_with_a_looong_name: ~ enum_with_default: this # One of "this"; "that" enum: ~ # One of "this"; "that" # some info array: child1: ~ child2: ~ # this is a long # multi-line info text # which should be indented child3: ~ # Example: example setting scalar_prototyped: [] parameters: # Prototype: Parameter name name: ~ connections: # Prototype - user: ~ pass: ~ cms_pages: # Prototype page: # Prototype locale: title: ~ # Required path: ~ # Required pipou: # Prototype name: [] EOL; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php000066400000000000000000000031141324732107100271060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\EnumNode; class EnumNodeTest extends TestCase { public function testFinalizeValue() { $node = new EnumNode('foo', null, array('foo', 'bar')); $this->assertSame('foo', $node->finalize('foo')); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage $values must contain at least one element. */ public function testConstructionWithNoValues() { new EnumNode('foo', null, array()); } public function testConstructionWithOneValue() { $node = new EnumNode('foo', null, array('foo')); $this->assertSame('foo', $node->finalize('foo')); } public function testConstructionWithOneDistinctValue() { $node = new EnumNode('foo', null, array('foo', 'foo')); $this->assertSame('foo', $node->finalize('foo')); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar" */ public function testFinalizeWithInvalidValue() { $node = new EnumNode('foo', null, array('foo', 'bar')); $node->finalize('foobar'); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/FinalizationTest.php000066400000000000000000000041371324732107100300310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Definition\NodeInterface; class FinalizationTest extends TestCase { public function testUnsetKeyWithDeepHierarchy() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->node('level1', 'array') ->canBeUnset() ->children() ->node('level2', 'array') ->canBeUnset() ->children() ->node('somevalue', 'scalar')->end() ->node('anothervalue', 'scalar')->end() ->end() ->end() ->node('level1_scalar', 'scalar')->end() ->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'level1' => array( 'level2' => array( 'somevalue' => 'foo', 'anothervalue' => 'bar', ), 'level1_scalar' => 'foo', ), ); $b = array( 'level1' => array( 'level2' => false, ), ); $this->assertEquals(array( 'level1' => array( 'level1_scalar' => 'foo', ), ), $this->process($tree, array($a, $b))); } protected function process(NodeInterface $tree, array $configs) { $processor = new Processor(); return $processor->process($tree, $configs); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php000066400000000000000000000035001324732107100272460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\FloatNode; class FloatNodeTest extends TestCase { /** * @dataProvider getValidValues */ public function testNormalize($value) { $node = new FloatNode('test'); $this->assertSame($value, $node->normalize($value)); } /** * @dataProvider getValidValues * * @param int $value */ public function testValidNonEmptyValues($value) { $node = new FloatNode('test'); $node->setAllowEmptyValue(false); $this->assertSame($value, $node->finalize($value)); } public function getValidValues() { return array( array(1798.0), array(-678.987), array(12.56E45), array(0.0), // Integer are accepted too, they will be cast array(17), array(-10), array(0), ); } /** * @dataProvider getInvalidValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new FloatNode('test'); $node->normalize($value); } public function getInvalidValues() { return array( array(null), array(''), array('foo'), array(true), array(false), array(array()), array(array('foo' => 'bar')), array(new \stdClass()), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php000066400000000000000000000033251324732107100276030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\IntegerNode; class IntegerNodeTest extends TestCase { /** * @dataProvider getValidValues */ public function testNormalize($value) { $node = new IntegerNode('test'); $this->assertSame($value, $node->normalize($value)); } /** * @dataProvider getValidValues * * @param int $value */ public function testValidNonEmptyValues($value) { $node = new IntegerNode('test'); $node->setAllowEmptyValue(false); $this->assertSame($value, $node->finalize($value)); } public function getValidValues() { return array( array(1798), array(-678), array(0), ); } /** * @dataProvider getInvalidValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new IntegerNode('test'); $node->normalize($value); } public function getInvalidValues() { return array( array(null), array(''), array('foo'), array(true), array(false), array(0.0), array(0.1), array(array()), array(array('foo' => 'bar')), array(new \stdClass()), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/MergeTest.php000066400000000000000000000121141324732107100264330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class MergeTest extends TestCase { /** * @expectedException \Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException */ public function testForbiddenOverwrite() { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->children() ->node('foo', 'scalar') ->cannotBeOverwritten() ->end() ->end() ->end() ->buildTree() ; $a = array( 'foo' => 'bar', ); $b = array( 'foo' => 'moo', ); $tree->merge($a, $b); } public function testUnsetKey() { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->node('unsettable', 'array') ->canBeUnset() ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->end() ->end() ->node('unsetted', 'array') ->canBeUnset() ->prototype('scalar')->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'foo' => 'bar', 'unsettable' => array( 'foo' => 'a', 'bar' => 'b', ), 'unsetted' => false, ); $b = array( 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, 'unsetted' => array('a', 'b'), ); $this->assertEquals(array( 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, 'unsetted' => array('a', 'b'), ), $tree->merge($a, $b)); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testDoesNotAllowNewKeysInSubsequentConfigs() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->node('test', 'array') ->disallowNewKeysInSubsequentConfigs() ->useAttributeAsKey('key') ->prototype('array') ->children() ->node('value', 'scalar')->end() ->end() ->end() ->end() ->end() ->end() ->buildTree(); $a = array( 'test' => array( 'a' => array('value' => 'foo'), ), ); $b = array( 'test' => array( 'b' => array('value' => 'foo'), ), ); $tree->merge($a, $b); } public function testPerformsNoDeepMerging() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->node('no_deep_merging', 'array') ->performNoDeepMerging() ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'no_deep_merging' => array( 'foo' => 'a', 'bar' => 'b', ), ); $b = array( 'no_deep_merging' => array( 'c' => 'd', ), ); $this->assertEquals(array( 'no_deep_merging' => array( 'c' => 'd', ), ), $tree->merge($a, $b)); } public function testPrototypeWithoutAKeyAttribute() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->arrayNode('append_elements') ->prototype('scalar')->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'append_elements' => array('a', 'b'), ); $b = array( 'append_elements' => array('c', 'd'), ); $this->assertEquals(array('append_elements' => array('a', 'b', 'c', 'd')), $tree->merge($a, $b)); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php000066400000000000000000000144051324732107100302270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class NormalizationTest extends TestCase { /** * @dataProvider getEncoderTests */ public function testNormalizeEncoders($denormalized) { $tb = new TreeBuilder(); $tree = $tb ->root('root_name', 'array') ->fixXmlConfig('encoder') ->children() ->node('encoders', 'array') ->useAttributeAsKey('class') ->prototype('array') ->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end() ->children() ->node('algorithm', 'scalar')->end() ->end() ->end() ->end() ->end() ->end() ->buildTree() ; $normalized = array( 'encoders' => array( 'foo' => array('algorithm' => 'plaintext'), ), ); $this->assertNormalized($tree, $denormalized, $normalized); } public function getEncoderTests() { $configs = array(); // XML $configs[] = array( 'encoder' => array( array('class' => 'foo', 'algorithm' => 'plaintext'), ), ); // XML when only one element of this type $configs[] = array( 'encoder' => array('class' => 'foo', 'algorithm' => 'plaintext'), ); // YAML/PHP $configs[] = array( 'encoders' => array( array('class' => 'foo', 'algorithm' => 'plaintext'), ), ); // YAML/PHP $configs[] = array( 'encoders' => array( 'foo' => 'plaintext', ), ); // YAML/PHP $configs[] = array( 'encoders' => array( 'foo' => array('algorithm' => 'plaintext'), ), ); return array_map(function ($v) { return array($v); }, $configs); } /** * @dataProvider getAnonymousKeysTests */ public function testAnonymousKeysArray($denormalized) { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->children() ->node('logout', 'array') ->fixXmlConfig('handler') ->children() ->node('handlers', 'array') ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ->buildTree() ; $normalized = array('logout' => array('handlers' => array('a', 'b', 'c'))); $this->assertNormalized($tree, $denormalized, $normalized); } public function getAnonymousKeysTests() { $configs = array(); $configs[] = array( 'logout' => array( 'handlers' => array('a', 'b', 'c'), ), ); $configs[] = array( 'logout' => array( 'handler' => array('a', 'b', 'c'), ), ); return array_map(function ($v) { return array($v); }, $configs); } /** * @dataProvider getNumericKeysTests */ public function testNumericKeysAsAttributes($denormalized) { $normalized = array( 'thing' => array(42 => array('foo', 'bar'), 1337 => array('baz', 'qux')), ); $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, $normalized); } public function getNumericKeysTests() { $configs = array(); $configs[] = array( 'thing' => array( 42 => array('foo', 'bar'), 1337 => array('baz', 'qux'), ), ); $configs[] = array( 'thing' => array( array('foo', 'bar', 'id' => 42), array('baz', 'qux', 'id' => 1337), ), ); return array_map(function ($v) { return array($v); }, $configs); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The attribute "id" must be set for path "root.thing". */ public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet() { $denormalized = array( 'thing' => array( array('foo', 'bar'), array('baz', 'qux'), ), ); $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, array()); } public function testAssociativeArrayPreserveKeys() { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->prototype('array') ->children() ->node('foo', 'scalar')->end() ->end() ->end() ->end() ->buildTree() ; $data = array('first' => array('foo' => 'bar')); $this->assertNormalized($tree, $data, $data); } public static function assertNormalized(NodeInterface $tree, $denormalized, $normalized) { self::assertSame($normalized, $tree->normalize($denormalized)); } private function getNumericKeysTestTree() { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->children() ->node('thing', 'array') ->useAttributeAsKey('id') ->prototype('array') ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->buildTree() ; return $tree; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php000066400000000000000000000267751324732107100313740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\ScalarNode; use Symfony\Component\Config\Definition\VariableNode; class PrototypedArrayNodeTest extends TestCase { public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes() { $node = new PrototypedArrayNode('root'); $prototype = new ArrayNode(null, $node); $node->setPrototype($prototype); $this->assertEmpty($node->getDefaultValue()); } public function testGetDefaultValueReturnsDefaultValueForPrototypes() { $node = new PrototypedArrayNode('root'); $prototype = new ArrayNode(null, $node); $node->setPrototype($prototype); $node->setDefaultValue(array('test')); $this->assertEquals(array('test'), $node->getDefaultValue()); } // a remapped key (e.g. "mapping" -> "mappings") should be unset after being used public function testRemappedKeysAreUnset() { $node = new ArrayNode('root'); $mappingsNode = new PrototypedArrayNode('mappings'); $node->addChild($mappingsNode); // each item under mappings is just a scalar $prototype = new ScalarNode(null, $mappingsNode); $mappingsNode->setPrototype($prototype); $remappings = array(); $remappings[] = array('mapping', 'mappings'); $node->setXmlRemappings($remappings); $normalized = $node->normalize(array('mapping' => array('foo', 'bar'))); $this->assertEquals(array('mappings' => array('foo', 'bar')), $normalized); } /** * Tests that when a key attribute is mapped, that key is removed from the array. * * * * * The above should finally be mapped to an array that looks like this * (because "id" is the key attribute). * * array( * 'things' => array( * 'option1' => 'foo', * 'option2' => 'bar', * ) * ) */ public function testMappedAttributeKeyIsRemoved() { $node = new PrototypedArrayNode('root'); $node->setKeyAttribute('id', true); // each item under the root is an array, with one scalar item $prototype = new ArrayNode(null, $node); $prototype->addChild(new ScalarNode('foo')); $node->setPrototype($prototype); $children = array(); $children[] = array('id' => 'item_name', 'foo' => 'bar'); $normalized = $node->normalize($children); $expected = array(); $expected['item_name'] = array('foo' => 'bar'); $this->assertEquals($expected, $normalized); } /** * Tests the opposite of the testMappedAttributeKeyIsRemoved because * the removal can be toggled with an option. */ public function testMappedAttributeKeyNotRemoved() { $node = new PrototypedArrayNode('root'); $node->setKeyAttribute('id', false); // each item under the root is an array, with two scalar items $prototype = new ArrayNode(null, $node); $prototype->addChild(new ScalarNode('foo')); $prototype->addChild(new ScalarNode('id')); // the key attribute will remain $node->setPrototype($prototype); $children = array(); $children[] = array('id' => 'item_name', 'foo' => 'bar'); $normalized = $node->normalize($children); $expected = array(); $expected['item_name'] = array('id' => 'item_name', 'foo' => 'bar'); $this->assertEquals($expected, $normalized); } public function testAddDefaultChildren() { $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet(); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array('defaults' => array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet('defaultkey'); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet(array('defaultkey')); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet(array('dk1', 'dk2')); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array('dk1' => array('foo' => 'bar'), 'dk2' => array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(array(5, 6)); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array(0 => array('foo' => 'bar'), 1 => array('foo' => 'bar')), $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(2); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array(array('foo' => 'bar'), array('foo' => 'bar')), $node->getDefaultValue()); } public function testDefaultChildrenWinsOverDefaultValue() { $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(); $node->setDefaultValue(array('bar' => 'foo')); $this->assertTrue($node->hasDefaultValue()); $this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue()); } protected function getPrototypeNodeWithDefaultChildren() { $node = new PrototypedArrayNode('root'); $prototype = new ArrayNode(null, $node); $child = new ScalarNode('foo'); $child->setDefaultValue('bar'); $prototype->addChild($child); $prototype->setAddIfNotSet(true); $node->setPrototype($prototype); return $node; } /** * Tests that when a key attribute is mapped, that key is removed from the array. * And if only 'value' element is left in the array, it will replace its wrapper array. * * * * * The above should finally be mapped to an array that looks like this * (because "id" is the key attribute). * * array( * 'things' => array( * 'option1' => 'value1' * ) * ) * * It's also possible to mix 'value-only' and 'non-value-only' elements in the array. * * * * * The above should finally be mapped to an array as follows * * array( * 'things' => array( * 'option1' => 'value1', * 'option2' => array( * 'value' => 'value2', * 'foo' => 'foo2' * ) * ) * ) * * The 'value' element can also be ArrayNode: * * * * * * The above should be finally be mapped to an array as follows * * array( * 'things' => array( * 'option1' => array( * 'foo' => 'foo1', * 'bar' => 'bar1' * ) * ) * ) * * If using VariableNode for value node, it's also possible to mix different types of value nodes: * * * * * * The above should be finally mapped to an array as follows * * array( * 'things' => array( * 'option1' => array( * 'foo' => 'foo1', * 'bar' => 'bar1' * ), * 'option2' => 'value2' * ) * ) * * * @dataProvider getDataForKeyRemovedLeftValueOnly */ public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, $expected) { $node = new PrototypedArrayNode('root'); $node->setKeyAttribute('id', true); // each item under the root is an array, with one scalar item $prototype = new ArrayNode(null, $node); $prototype->addChild(new ScalarNode('id')); $prototype->addChild(new ScalarNode('foo')); $prototype->addChild($value); $node->setPrototype($prototype); $normalized = $node->normalize($children); $this->assertEquals($expected, $normalized); } public function getDataForKeyRemovedLeftValueOnly() { $scalarValue = new ScalarNode('value'); $arrayValue = new ArrayNode('value'); $arrayValue->addChild(new ScalarNode('foo')); $arrayValue->addChild(new ScalarNode('bar')); $variableValue = new VariableNode('value'); return array( array( $scalarValue, array( array('id' => 'option1', 'value' => 'value1'), ), array('option1' => 'value1'), ), array( $scalarValue, array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'), ), array( 'option1' => 'value1', 'option2' => array('value' => 'value2', 'foo' => 'foo2'), ), ), array( $arrayValue, array( array( 'id' => 'option1', 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), ), ), array( 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), ), ), array($variableValue, array( array( 'id' => 'option1', 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), ), array('id' => 'option2', 'value' => 'value2'), ), array( 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), 'option2' => 'value2', ), ), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php000066400000000000000000000121521324732107100274110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\ScalarNode; class ScalarNodeTest extends TestCase { /** * @dataProvider getValidValues */ public function testNormalize($value) { $node = new ScalarNode('test'); $this->assertSame($value, $node->normalize($value)); } public function getValidValues() { return array( array(false), array(true), array(null), array(''), array('foo'), array(0), array(1), array(0.0), array(0.1), ); } public function testSetDeprecated() { $childNode = new ScalarNode('foo'); $childNode->setDeprecated('"%node%" is deprecated'); $this->assertTrue($childNode->isDeprecated()); $this->assertSame('"foo" is deprecated', $childNode->getDeprecationMessage($childNode->getName(), $childNode->getPath())); $node = new ArrayNode('root'); $node->addChild($childNode); $deprecationTriggered = 0; $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { if (E_USER_DEPRECATED === $level) { return ++$deprecationTriggered; } return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; }; $prevErrorHandler = set_error_handler($deprecationHandler); $node->finalize(array()); restore_error_handler(); $this->assertSame(0, $deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); $prevErrorHandler = set_error_handler($deprecationHandler); $node->finalize(array('foo' => '')); restore_error_handler(); $this->assertSame(1, $deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } /** * @dataProvider getInvalidValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new ScalarNode('test'); $node->normalize($value); } public function getInvalidValues() { return array( array(array()), array(array('foo' => 'bar')), array(new \stdClass()), ); } public function testNormalizeThrowsExceptionWithoutHint() { $node = new ScalarNode('test'); if (method_exists($this, 'expectException')) { $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); $this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.'); } else { $this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', 'Invalid type for path "test". Expected scalar, but got array.'); } $node->normalize(array()); } public function testNormalizeThrowsExceptionWithErrorMessage() { $node = new ScalarNode('test'); $node->setInfo('"the test value"'); if (method_exists($this, 'expectException')) { $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); $this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); } else { $this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', "Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); } $node->normalize(array()); } /** * @dataProvider getValidNonEmptyValues * * @param mixed $value */ public function testValidNonEmptyValues($value) { $node = new ScalarNode('test'); $node->setAllowEmptyValue(false); $this->assertSame($value, $node->finalize($value)); } public function getValidNonEmptyValues() { return array( array(false), array(true), array('foo'), array(0), array(1), array(0.0), array(0.1), ); } /** * @dataProvider getEmptyValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * * @param mixed $value */ public function testNotAllowedEmptyValuesThrowException($value) { $node = new ScalarNode('test'); $node->setAllowEmptyValue(false); $node->finalize($value); } public function getEmptyValues() { return array( array(null), array(''), ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/DependencyInjection/000077500000000000000000000000001324732107100256555ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/DependencyInjection/ConfigCachePassTest.php000066400000000000000000000037551324732107100322200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Config\DependencyInjection\ConfigCachePass; /** * @group legacy */ class ConfigCachePassTest extends TestCase { public function testThatCheckersAreProcessedInPriorityOrder() { $container = new ContainerBuilder(); $definition = $container->register('config_cache_factory')->addArgument(null); $container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100)); $container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200)); $container->register('checker_3')->addTag('config_cache.resource_checker'); $pass = new ConfigCachePass(); $pass->process($container); $expected = new IteratorArgument(array( new Reference('checker_1'), new Reference('checker_2'), new Reference('checker_3'), )); $this->assertEquals($expected, $definition->getArgument(0)); } public function testThatCheckersCanBeMissing() { $container = new ContainerBuilder(); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $pass = new ConfigCachePass(); $pass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Exception/000077500000000000000000000000001324732107100236725ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Exception/FileLoaderLoadExceptionTest.php000066400000000000000000000072361324732107100317400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Exception; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Exception\FileLoaderLoadException; class FileLoaderLoadExceptionTest extends TestCase { public function testMessageCannotLoadResource() { $exception = new FileLoaderLoadException('resource', null); $this->assertEquals('Cannot load resource "resource".', $exception->getMessage()); } public function testMessageCannotLoadResourceWithType() { $exception = new FileLoaderLoadException('resource', null, null, null, 'foobar'); $this->assertEquals('Cannot load resource "resource". Make sure there is a loader supporting the "foobar" type.', $exception->getMessage()); } public function testMessageCannotLoadResourceWithAnnotationType() { $exception = new FileLoaderLoadException('resource', null, null, null, 'annotation'); $this->assertEquals('Cannot load resource "resource". Make sure annotations are installed and enabled.', $exception->getMessage()); } public function testMessageCannotImportResourceFromSource() { $exception = new FileLoaderLoadException('resource', 'sourceResource'); $this->assertEquals('Cannot import resource "resource" from "sourceResource".', $exception->getMessage()); } public function testMessageCannotImportBundleResource() { $exception = new FileLoaderLoadException('@resource', 'sourceResource'); $this->assertEquals( 'Cannot import resource "@resource" from "sourceResource". '. 'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '. 'If the bundle is registered, make sure the bundle path "@resource" is not empty.', $exception->getMessage() ); } public function testMessageHasPreviousErrorWithDotAndUnableToLoad() { $exception = new FileLoaderLoadException( 'resource', null, null, new \Exception('There was a previous error with an ending dot.') ); $this->assertEquals( 'There was a previous error with an ending dot in resource (which is loaded in resource "resource").', $exception->getMessage() ); } public function testMessageHasPreviousErrorWithoutDotAndUnableToLoad() { $exception = new FileLoaderLoadException( 'resource', null, null, new \Exception('There was a previous error with no ending dot') ); $this->assertEquals( 'There was a previous error with no ending dot in resource (which is loaded in resource "resource").', $exception->getMessage() ); } public function testMessageHasPreviousErrorAndUnableToLoadBundle() { $exception = new FileLoaderLoadException( '@resource', null, null, new \Exception('There was a previous error with an ending dot.') ); $this->assertEquals( 'There was a previous error with an ending dot in @resource '. '(which is loaded in resource "@resource"). '. 'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '. 'If the bundle is registered, make sure the bundle path "@resource" is not empty.', $exception->getMessage() ); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/FileLocatorTest.php000066400000000000000000000100331324732107100255050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; class FileLocatorTest extends TestCase { /** * @dataProvider getIsAbsolutePathTests */ public function testIsAbsolutePath($path) { $loader = new FileLocator(array()); $r = new \ReflectionObject($loader); $m = $r->getMethod('isAbsolutePath'); $m->setAccessible(true); $this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for an absolute path'); } public function getIsAbsolutePathTests() { return array( array('/foo.xml'), array('c:\\\\foo.xml'), array('c:/foo.xml'), array('\\server\\foo.xml'), array('https://server/foo.xml'), array('phar://server/foo.xml'), ); } public function testLocate() { $loader = new FileLocator(__DIR__.'/Fixtures'); $this->assertEquals( __DIR__.DIRECTORY_SEPARATOR.'FileLocatorTest.php', $loader->locate('FileLocatorTest.php', __DIR__), '->locate() returns the absolute filename if the file exists in the given path' ); $this->assertEquals( __DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', $loader->locate('foo.xml', __DIR__), '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' ); $this->assertEquals( __DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', $loader->locate(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__), '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' ); $loader = new FileLocator(array(__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again')); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__, false), '->locate() returns an array of absolute filenames' ); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); $loader = new FileLocator(__DIR__.'/Fixtures/Again'); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); } /** * @expectedException \Symfony\Component\Config\Exception\FileLocatorFileNotFoundException * @expectedExceptionMessage The file "foobar.xml" does not exist */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExists() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate('foobar.xml', __DIR__); } /** * @expectedException \Symfony\Component\Config\Exception\FileLocatorFileNotFoundException */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage An empty file name is not valid to be located. */ public function testLocateEmpty() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate(null, __DIR__); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/000077500000000000000000000000001324732107100235455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Again/000077500000000000000000000000001324732107100245645ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Again/foo.xml000066400000000000000000000000001324732107100260570ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php000066400000000000000000000001451324732107100261160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Fixtures; use Symfony\Component\Config\Definition\ArrayNode; class BarNode extends ArrayNode { } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Builder/000077500000000000000000000000001324732107100251335ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php000066400000000000000000000010541324732107100311670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Fixtures\Builder; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Tests\Fixtures\BarNode; class BarNodeDefinition extends NodeDefinition { protected function createNode() { return new BarNode($this->name); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php000066400000000000000000000015611324732107100300430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Fixtures\Builder; use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder; class NodeBuilder extends BaseNodeBuilder { public function barNode($name) { return $this->node($name, 'bar'); } protected function getNodeClass($type) { switch ($type) { case 'variable': return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition'; case 'bar': return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition'; default: return parent::getNodeClass($type); } } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Builder/VariableNodeDefinition.php000066400000000000000000000007251324732107100322140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Fixtures\Builder; use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition; class VariableNodeDefinition extends BaseVariableNodeDefinition { } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Configuration/000077500000000000000000000000001324732107100263545ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php000066400000000000000000000102161324732107100332100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Fixtures\Configuration; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; class ExampleConfiguration implements ConfigurationInterface { public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('acme_root'); $rootNode ->fixXmlConfig('parameter') ->fixXmlConfig('connection') ->fixXmlConfig('cms_page') ->children() ->booleanNode('boolean')->defaultTrue()->end() ->scalarNode('scalar_empty')->end() ->scalarNode('scalar_null')->defaultNull()->end() ->scalarNode('scalar_true')->defaultTrue()->end() ->scalarNode('scalar_false')->defaultFalse()->end() ->scalarNode('scalar_default')->defaultValue('default')->end() ->scalarNode('scalar_array_empty')->defaultValue(array())->end() ->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end() ->scalarNode('scalar_required')->isRequired()->end() ->scalarNode('scalar_deprecated')->setDeprecated()->end() ->scalarNode('scalar_deprecated_with_message')->setDeprecated('Deprecation custom message for "%node%" at "%path%"')->end() ->scalarNode('node_with_a_looong_name')->end() ->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end() ->enumNode('enum')->values(array('this', 'that'))->end() ->arrayNode('array') ->info('some info') ->canBeUnset() ->children() ->scalarNode('child1')->end() ->scalarNode('child2')->end() ->scalarNode('child3') ->info( "this is a long\n". "multi-line info text\n". 'which should be indented' ) ->example('example setting') ->end() ->end() ->end() ->arrayNode('scalar_prototyped') ->prototype('scalar')->end() ->end() ->arrayNode('parameters') ->useAttributeAsKey('name') ->prototype('scalar')->info('Parameter name')->end() ->end() ->arrayNode('connections') ->prototype('array') ->children() ->scalarNode('user')->end() ->scalarNode('pass')->end() ->end() ->end() ->end() ->arrayNode('cms_pages') ->useAttributeAsKey('page') ->prototype('array') ->useAttributeAsKey('locale') ->prototype('array') ->children() ->scalarNode('title')->isRequired()->end() ->scalarNode('path')->isRequired()->end() ->end() ->end() ->end() ->end() ->arrayNode('pipou') ->useAttributeAsKey('name') ->prototype('array') ->prototype('array') ->children() ->scalarNode('didou') ->end() ->end() ->end() ->end() ->end() ->end() ; return $treeBuilder; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Resource/000077500000000000000000000000001324732107100253345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Resource/.hiddenFile000066400000000000000000000000001324732107100273560ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Resource/ConditionalClass.php000066400000000000000000000002271324732107100312770ustar00rootroot00000000000000 ]> symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Util/invalid.xml000066400000000000000000000000561324732107100266330ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Util/invalid_schema.xml000066400000000000000000000001231324732107100301460ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Util/schema.xsd000066400000000000000000000004101324732107100264350ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/Util/valid.xml000066400000000000000000000001301324732107100262750ustar00rootroot00000000000000 symfony-3.4.6/src/Symfony/Component/Config/Tests/Fixtures/foo.xml000066400000000000000000000000001324732107100250400ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Loader/000077500000000000000000000000001324732107100231425ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php000066400000000000000000000055401324732107100277110ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\Loader\DelegatingLoader; class DelegatingLoaderTest extends TestCase { public function testConstructor() { $loader = new DelegatingLoader($resolver = new LoaderResolver()); $this->assertTrue(true, '__construct() takes a loader resolver as its first argument'); } public function testGetSetResolver() { $resolver = new LoaderResolver(); $loader = new DelegatingLoader($resolver); $this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader'); $loader->setResolver($resolver = new LoaderResolver()); $this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader'); } public function testSupports() { $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); } public function testLoad() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader->expects($this->once())->method('load'); $resolver = new LoaderResolver(array($loader)); $loader = new DelegatingLoader($resolver); $loader->load('foo'); } /** * @expectedException \Symfony\Component\Config\Exception\FileLoaderLoadException */ public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(false)); $resolver = new LoaderResolver(array($loader)); $loader = new DelegatingLoader($resolver); $loader->load('foo'); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php000066400000000000000000000111271324732107100265230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\FileLoader; use Symfony\Component\Config\Loader\LoaderResolver; class FileLoaderTest extends TestCase { public function testImportWithFileLocatorDelegation() { $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( array('path/to/file1'), // Default array('path/to/file1', 'path/to/file2'), // First is imported array('path/to/file1', 'path/to/file2'), // Second is imported array('path/to/file1'), // Exception array('path/to/file1', 'path/to/file2') // Exception )); $fileLoader = new TestFileLoader($locatorMock); $fileLoader->setSupports(false); $fileLoader->setCurrentDir('.'); $additionalLoader = new TestFileLoader($locatorMockForAdditionalLoader); $additionalLoader->setCurrentDir('.'); $fileLoader->setResolver($loaderResolver = new LoaderResolver(array($fileLoader, $additionalLoader))); // Default case $this->assertSame('path/to/file1', $fileLoader->import('my_resource')); // Check first file is imported if not already loading $this->assertSame('path/to/file1', $fileLoader->import('my_resource')); // Check second file is imported if first is already loading $fileLoader->addLoading('path/to/file1'); $this->assertSame('path/to/file2', $fileLoader->import('my_resource')); // Check exception throws if first (and only available) file is already loading try { $fileLoader->import('my_resource'); $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } // Check exception throws if all files are already loading try { $fileLoader->addLoading('path/to/file2'); $fileLoader->import('my_resource'); $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } } public function testImportWithGlobLikeResource() { $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new TestFileLoader($locatorMock); $this->assertSame('[foo]', $loader->import('[foo]')); } public function testImportWithNoGlobMatch() { $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new TestFileLoader($locatorMock); $this->assertNull($loader->import('./*.abc')); } public function testImportWithSimpleGlob() { $loader = new TestFileLoader(new FileLocator(__DIR__)); $this->assertSame(__FILE__, strtr($loader->import('FileLoaderTest.*'), '/', DIRECTORY_SEPARATOR)); } } class TestFileLoader extends FileLoader { private $supports = true; public function load($resource, $type = null) { return $resource; } public function supports($resource, $type = null) { return $this->supports; } public function addLoading($resource) { self::$loading[$resource] = true; } public function removeLoading($resource) { unset(self::$loading[$resource]); } public function clearLoading() { self::$loading = array(); } public function setSupports($supports) { $this->supports = $supports; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php000066400000000000000000000034141324732107100274450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Loader\LoaderResolver; class LoaderResolverTest extends TestCase { public function testConstructor() { $resolver = new LoaderResolver(array( $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(), )); $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); } public function testResolve() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolver = new LoaderResolver(array($loader)); $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $resolver = new LoaderResolver(array($loader)); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); } public function testLoaders() { $resolver = new LoaderResolver(); $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock()); $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader'); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php000066400000000000000000000073351324732107100257310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Loader\Loader; class LoaderTest extends TestCase { public function testGetSetResolver() { $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $loader = new ProjectLoader1(); $loader->setResolver($resolver); $this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader'); } public function testResolve() { $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo.xml') ->will($this->returnValue($resolvedLoader)); $loader = new ProjectLoader1(); $loader->setResolver($resolver); $this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader'); $this->assertSame($resolvedLoader, $loader->resolve('foo.xml'), '->resolve() finds a loader'); } /** * @expectedException \Symfony\Component\Config\Exception\FileLoaderLoadException */ public function testResolveWhenResolverCannotFindLoader() { $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('FOOBAR') ->will($this->returnValue(false)); $loader = new ProjectLoader1(); $loader->setResolver($resolver); $loader->resolve('FOOBAR'); } public function testImport() { $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo') ->will($this->returnValue('yes')); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo') ->will($this->returnValue($resolvedLoader)); $loader = new ProjectLoader1(); $loader->setResolver($resolver); $this->assertEquals('yes', $loader->import('foo')); } public function testImportWithType() { $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo', 'bar') ->will($this->returnValue('yes')); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo', 'bar') ->will($this->returnValue($resolvedLoader)); $loader = new ProjectLoader1(); $loader->setResolver($resolver); $this->assertEquals('yes', $loader->import('foo', 'bar')); } } class ProjectLoader1 extends Loader { public function load($resource, $type = null) { } public function supports($resource, $type = null) { return is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION); } public function getType() { } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/000077500000000000000000000000001324732107100235235ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php000066400000000000000000000053101324732107100315200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\ClassExistenceResource; use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass; use Symfony\Component\Config\Tests\Fixtures\BadParent; class ClassExistenceResourceTest extends TestCase { public function testToString() { $res = new ClassExistenceResource('BarClass'); $this->assertSame('BarClass', (string) $res); } public function testGetResource() { $res = new ClassExistenceResource('BarClass'); $this->assertSame('BarClass', $res->getResource()); } public function testIsFreshWhenClassDoesNotExist() { $res = new ClassExistenceResource('Symfony\Component\Config\Tests\Fixtures\BarClass'); $this->assertTrue($res->isFresh(time())); eval(<<assertFalse($res->isFresh(time())); } public function testIsFreshWhenClassExists() { $res = new ClassExistenceResource('Symfony\Component\Config\Tests\Resource\ClassExistenceResourceTest'); $this->assertTrue($res->isFresh(time())); } public function testExistsKo() { spl_autoload_register($autoloader = function ($class) use (&$loadedClass) { $loadedClass = $class; }); try { $res = new ClassExistenceResource('MissingFooClass'); $this->assertTrue($res->isFresh(0)); $this->assertSame('MissingFooClass', $loadedClass); $loadedClass = 123; $res = new ClassExistenceResource('MissingFooClass', false); $this->assertSame(123, $loadedClass); } finally { spl_autoload_unregister($autoloader); } } public function testBadParentWithTimestamp() { $res = new ClassExistenceResource(BadParent::class, false); $this->assertTrue($res->isFresh(time())); } /** * @expectedException \ReflectionException * @expectedExceptionMessage Class Symfony\Component\Config\Tests\Fixtures\MissingParent not found */ public function testBadParentWithNoTimestamp() { $res = new ClassExistenceResource(BadParent::class, false); $res->isFresh(0); } public function testConditionalClass() { $res = new ClassExistenceResource(ConditionalClass::class, false); $this->assertFalse($res->isFresh(0)); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/ComposerResourceTest.php000066400000000000000000000021661324732107100304000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use Composer\Autoload\ClassLoader; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\ComposerResource; class ComposerResourceTest extends TestCase { public function testGetVendor() { $res = new ComposerResource(); $r = new \ReflectionClass(ClassLoader::class); $found = false; foreach ($res->getVendors() as $vendor) { if ($vendor && 0 === strpos($r->getFileName(), $vendor)) { $found = true; break; } } $this->assertTrue($found); } public function testSerializeUnserialize() { $res = new ComposerResource(); $ser = unserialize(serialize($res)); $this->assertTrue($res->isFresh(0)); $this->assertTrue($ser->isFresh(0)); $this->assertEquals($res, $ser); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php000066400000000000000000000147321324732107100305570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\DirectoryResource; class DirectoryResourceTest extends TestCase { protected $directory; protected function setUp() { $this->directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'symfonyDirectoryIterator'; if (!file_exists($this->directory)) { mkdir($this->directory); } touch($this->directory.'/tmp.xml'); } protected function tearDown() { if (!is_dir($this->directory)) { return; } $this->removeDirectory($this->directory); } protected function removeDirectory($directory) { $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $path) { if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) { continue; } if ($path->isDir()) { rmdir($path->__toString()); } else { unlink($path->__toString()); } } rmdir($directory); } public function testGetResource() { $resource = new DirectoryResource($this->directory); $this->assertSame(realpath($this->directory), $resource->getResource(), '->getResource() returns the path to the resource'); } public function testGetPattern() { $resource = new DirectoryResource($this->directory, 'bar'); $this->assertEquals('bar', $resource->getPattern()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessageRegExp /The directory ".*" does not exist./ */ public function testResourceDoesNotExist() { $resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999)); } public function testIsFresh() { $resource = new DirectoryResource($this->directory); $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed'); $this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated'); } public function testIsFreshForDeletedResources() { $resource = new DirectoryResource($this->directory); $this->removeDirectory($this->directory); $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist'); } public function testIsFreshUpdateFile() { $resource = new DirectoryResource($this->directory); touch($this->directory.'/tmp.xml', time() + 20); $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified'); } public function testIsFreshNewFile() { $resource = new DirectoryResource($this->directory); touch($this->directory.'/new.xml', time() + 20); $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added'); } public function testIsFreshNewFileWithDifferentPattern() { $resource = new DirectoryResource($this->directory, '/.xml$/'); touch($this->directory.'/new.yaml', time() + 20); $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file with a non-matching pattern is added'); } public function testIsFreshDeleteFile() { $resource = new DirectoryResource($this->directory); $time = time(); sleep(1); unlink($this->directory.'/tmp.xml'); $this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed'); } public function testIsFreshDeleteDirectory() { $resource = new DirectoryResource($this->directory); $this->removeDirectory($this->directory); $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed'); } public function testIsFreshCreateFileInSubdirectory() { $subdirectory = $this->directory.'/subdirectory'; mkdir($subdirectory); $resource = new DirectoryResource($this->directory); $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists'); touch($subdirectory.'/newfile.xml', time() + 20); $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added'); } public function testIsFreshModifySubdirectory() { $resource = new DirectoryResource($this->directory); $subdirectory = $this->directory.'/subdirectory'; mkdir($subdirectory); touch($subdirectory, time() + 20); $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)'); } public function testFilterRegexListNoMatch() { $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); touch($this->directory.'/new.bar', time() + 20); $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created'); } public function testFilterRegexListMatch() { $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); touch($this->directory.'/new.xml', time() + 20); $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created '); } public function testSerializeUnserialize() { $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); $unserialized = unserialize(serialize($resource)); $this->assertSame(realpath($this->directory), $resource->getResource()); $this->assertSame('/\.(foo|xml)$/', $resource->getPattern()); } public function testResourcesWithDifferentPatternsAreDifferent() { $resourceA = new DirectoryResource($this->directory, '/.xml$/'); $resourceB = new DirectoryResource($this->directory, '/.yaml$/'); $this->assertCount(2, array_unique(array($resourceA, $resourceB))); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/FileExistenceResourceTest.php000066400000000000000000000042161324732107100313360ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileExistenceResource; class FileExistenceResourceTest extends TestCase { protected $resource; protected $file; protected $time; protected function setUp() { $this->file = realpath(sys_get_temp_dir()).'/tmp.xml'; $this->time = time(); $this->resource = new FileExistenceResource($this->file); } protected function tearDown() { if (file_exists($this->file)) { unlink($this->file); } } public function testToString() { $this->assertSame($this->file, (string) $this->resource); } public function testGetResource() { $this->assertSame($this->file, $this->resource->getResource(), '->getResource() returns the path to the resource'); } public function testIsFreshWithExistingResource() { touch($this->file, $this->time); $serialized = serialize(new FileExistenceResource($this->file)); $resource = unserialize($serialized); $this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still present'); unlink($this->file); $resource = unserialize($serialized); $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been deleted'); } public function testIsFreshWithAbsentResource() { $serialized = serialize(new FileExistenceResource($this->file)); $resource = unserialize($serialized); $this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still absent'); touch($this->file, $this->time); $resource = unserialize($serialized); $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been created'); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php000066400000000000000000000050341324732107100274650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; class FileResourceTest extends TestCase { protected $resource; protected $file; protected $time; protected function setUp() { $this->file = sys_get_temp_dir().'/tmp.xml'; $this->time = time(); touch($this->file, $this->time); $this->resource = new FileResource($this->file); } protected function tearDown() { if (!file_exists($this->file)) { return; } unlink($this->file); } public function testGetResource() { $this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource'); } public function testGetResourceWithScheme() { $resource = new FileResource('file://'.$this->file); $this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource'); } public function testToString() { $this->assertSame(realpath($this->file), (string) $this->resource); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessageRegExp /The file ".*" does not exist./ */ public function testResourceDoesNotExist() { $resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999)); } public function testIsFresh() { $this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second'); $this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed'); $this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated'); } public function testIsFreshForDeletedResources() { unlink($this->file); $this->assertFalse($this->resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); } public function testSerializeUnserialize() { $unserialized = unserialize(serialize($this->resource)); $this->assertSame(realpath($this->file), $this->resource->getResource()); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php000066400000000000000000000065721324732107100275010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\GlobResource; class GlobResourceTest extends TestCase { protected function tearDown() { $dir = dirname(__DIR__).'/Fixtures'; @rmdir($dir.'/TmpGlob'); @unlink($dir.'/TmpGlob'); @unlink($dir.'/Resource/TmpGlob'); touch($dir.'/Resource/.hiddenFile'); } public function testIterator() { $dir = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'; $resource = new GlobResource($dir, '/Resource', true); $paths = iterator_to_array($resource); $file = $dir.'/Resource'.DIRECTORY_SEPARATOR.'ConditionalClass.php'; $this->assertEquals(array($file => new \SplFileInfo($file)), $paths); $this->assertInstanceOf('SplFileInfo', current($paths)); $this->assertSame($dir, $resource->getPrefix()); $resource = new GlobResource($dir, '/**/Resource', true); $paths = iterator_to_array($resource); $file = $dir.DIRECTORY_SEPARATOR.'Resource'.DIRECTORY_SEPARATOR.'ConditionalClass.php'; $this->assertEquals(array($file => $file), $paths); $this->assertInstanceOf('SplFileInfo', current($paths)); $this->assertSame($dir, $resource->getPrefix()); } public function testIsFreshNonRecursiveDetectsNewFile() { $dir = dirname(__DIR__).'/Fixtures'; $resource = new GlobResource($dir, '/*', false); $this->assertTrue($resource->isFresh(0)); mkdir($dir.'/TmpGlob'); $this->assertTrue($resource->isFresh(0)); rmdir($dir.'/TmpGlob'); $this->assertTrue($resource->isFresh(0)); touch($dir.'/TmpGlob'); $this->assertFalse($resource->isFresh(0)); unlink($dir.'/TmpGlob'); $this->assertTrue($resource->isFresh(0)); } public function testIsFreshNonRecursiveDetectsRemovedFile() { $dir = dirname(__DIR__).'/Fixtures'; $resource = new GlobResource($dir, '/*', false); touch($dir.'/TmpGlob'); touch($dir.'/.TmpGlob'); $this->assertTrue($resource->isFresh(0)); unlink($dir.'/.TmpGlob'); $this->assertTrue($resource->isFresh(0)); unlink($dir.'/TmpGlob'); $this->assertFalse($resource->isFresh(0)); } public function testIsFreshRecursiveDetectsRemovedFile() { $dir = dirname(__DIR__).'/Fixtures'; $resource = new GlobResource($dir, '/*', true); touch($dir.'/Resource/TmpGlob'); $this->assertTrue($resource->isFresh(0)); unlink($dir.'/Resource/TmpGlob'); $this->assertFalse($resource->isFresh(0)); touch($dir.'/Resource/TmpGlob'); $this->assertTrue($resource->isFresh(0)); unlink($dir.'/Resource/.hiddenFile'); $this->assertTrue($resource->isFresh(0)); } public function testIsFreshRecursiveDetectsNewFile() { $dir = dirname(__DIR__).'/Fixtures'; $resource = new GlobResource($dir, '/*', true); $this->assertTrue($resource->isFresh(0)); touch($dir.'/Resource/TmpGlob'); $this->assertFalse($resource->isFresh(0)); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php000066400000000000000000000147161324732107100316750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\ReflectionClassResource; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class ReflectionClassResourceTest extends TestCase { public function testToString() { $res = new ReflectionClassResource(new \ReflectionClass('ErrorException')); $this->assertSame('reflection.ErrorException', (string) $res); } public function testSerializeUnserialize() { $res = new ReflectionClassResource(new \ReflectionClass(DummyInterface::class)); $ser = unserialize(serialize($res)); $this->assertTrue($res->isFresh(0)); $this->assertTrue($ser->isFresh(0)); $this->assertSame((string) $res, (string) $ser); } public function testIsFresh() { $res = new ReflectionClassResource(new \ReflectionClass(__CLASS__)); $mtime = filemtime(__FILE__); $this->assertTrue($res->isFresh($mtime), '->isFresh() returns true if the resource has not changed in same second'); $this->assertTrue($res->isFresh($mtime + 10), '->isFresh() returns true if the resource has not changed'); $this->assertTrue($res->isFresh($mtime - 86400), '->isFresh() returns true if the resource has not changed'); } public function testIsFreshForDeletedResources() { $now = time(); $tmp = sys_get_temp_dir().'/tmp.php'; file_put_contents($tmp, 'assertTrue($res->isFresh($now)); unlink($tmp); $this->assertFalse($res->isFresh($now), '->isFresh() returns false if the resource does not exist'); } /** * @dataProvider provideHashedSignature */ public function testHashedSignature($changeExpected, $changedLine, $changedCode) { $code = <<<'EOPHP' /* 0*/ /* 1*/ class %s extends ErrorException /* 2*/ { /* 3*/ const FOO = 123; /* 4*/ /* 5*/ public $pub = array(); /* 6*/ /* 7*/ protected $prot; /* 8*/ /* 9*/ private $priv; /*10*/ /*11*/ public function pub($arg = null) {} /*12*/ /*13*/ protected function prot($a = array()) {} /*14*/ /*15*/ private function priv() {} /*16*/ } EOPHP; static $expectedSignature, $generateSignature; if (null === $expectedSignature) { eval(sprintf($code, $class = 'Foo'.str_replace('.', '_', uniqid('', true)))); $r = new \ReflectionClass(ReflectionClassResource::class); $generateSignature = $r->getMethod('generateSignature'); $generateSignature->setAccessible(true); $generateSignature = $generateSignature->getClosure($r->newInstanceWithoutConstructor()); $expectedSignature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class)))); } $code = explode("\n", $code); $code[$changedLine] = $changedCode; eval(sprintf(implode("\n", $code), $class = 'Foo'.str_replace('.', '_', uniqid('', true)))); $signature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class)))); if ($changeExpected) { $this->assertNotSame($expectedSignature, $signature); } else { $this->assertSame($expectedSignature, $signature); } } public function provideHashedSignature() { yield array(0, 0, "// line change\n\n"); yield array(1, 0, '/** class docblock */'); yield array(1, 1, 'abstract class %s'); yield array(1, 1, 'final class %s'); yield array(1, 1, 'class %s extends Exception'); yield array(1, 1, 'class %s implements '.DummyInterface::class); yield array(1, 3, 'const FOO = 456;'); yield array(1, 3, 'const BAR = 123;'); yield array(1, 4, '/** pub docblock */'); yield array(1, 5, 'protected $pub = array();'); yield array(1, 5, 'public $pub = array(123);'); yield array(1, 6, '/** prot docblock */'); yield array(1, 7, 'private $prot;'); yield array(0, 8, '/** priv docblock */'); yield array(0, 9, 'private $priv = 123;'); yield array(1, 10, '/** pub docblock */'); if (\PHP_VERSION_ID >= 50600) { yield array(1, 11, 'public function pub(...$arg) {}'); } if (\PHP_VERSION_ID >= 70000) { yield array(1, 11, 'public function pub($arg = null): Foo {}'); } yield array(0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"); yield array(1, 12, '/** prot docblock */'); yield array(1, 13, 'protected function prot($a = array(123)) {}'); yield array(0, 14, '/** priv docblock */'); yield array(0, 15, ''); } public function testEventSubscriber() { $res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class)); $this->assertTrue($res->isFresh(0)); TestEventSubscriber::$subscribedEvents = array(123); $this->assertFalse($res->isFresh(0)); $res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class)); $this->assertTrue($res->isFresh(0)); } public function testServiceSubscriber() { $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); $this->assertTrue($res->isFresh(0)); TestServiceSubscriber::$subscribedServices = array(123); $this->assertFalse($res->isFresh(0)); $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); $this->assertTrue($res->isFresh(0)); } } interface DummyInterface { } class TestEventSubscriber implements EventSubscriberInterface { public static $subscribedEvents = array(); public static function getSubscribedEvents() { return self::$subscribedEvents; } } class TestServiceSubscriber implements ServiceSubscriberInterface { public static $subscribedServices = array(); public static function getSubscribedServices() { return self::$subscribedServices; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php000066400000000000000000000012571324732107100266660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; class ResourceStub implements SelfCheckingResourceInterface { private $fresh = true; public function setFresh($isFresh) { $this->fresh = $isFresh; } public function __toString() { return 'stub'; } public function isFresh($timestamp) { return $this->fresh; } } symfony-3.4.6/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php000066400000000000000000000116561324732107100304440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Tests\Resource\ResourceStub; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\ResourceCheckerConfigCache; class ResourceCheckerConfigCacheTest extends TestCase { private $cacheFile = null; protected function setUp() { $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_'); } protected function tearDown() { $files = array($this->cacheFile, "{$this->cacheFile}.meta"); foreach ($files as $file) { if (file_exists($file)) { unlink($file); } } } public function testGetPath() { $cache = new ResourceCheckerConfigCache($this->cacheFile); $this->assertSame($this->cacheFile, $cache->getPath()); } public function testCacheIsNotFreshIfEmpty() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock() ->expects($this->never())->method('supports'); /* If there is nothing in the cache, it needs to be filled (and thus it's not fresh). It does not matter if you provide checkers or not. */ unlink($this->cacheFile); // remove tempnam() side effect $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $this->assertFalse($cache->isFresh()); } public function testCacheIsFreshIfNoCheckerProvided() { /* For example in prod mode, you may choose not to run any checkers at all. In that case, the cache should always be considered fresh. */ $cache = new ResourceCheckerConfigCache($this->cacheFile); $this->assertTrue($cache->isFresh()); } public function testCacheIsFreshIfEmptyCheckerIteratorProvided() { $cache = new ResourceCheckerConfigCache($this->cacheFile, new \ArrayIterator(array())); $this->assertTrue($cache->isFresh()); } public function testResourcesWithoutcheckersAreIgnoredAndConsideredFresh() { /* As in the previous test, but this time we have a resource. */ $cache = new ResourceCheckerConfigCache($this->cacheFile); $cache->write('', array(new ResourceStub())); $this->assertTrue($cache->isFresh()); // no (matching) ResourceChecker passed } public function testIsFreshWithchecker() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') ->willReturn(true); $checker->expects($this->once()) ->method('isFresh') ->willReturn(true); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('', array(new ResourceStub())); $this->assertTrue($cache->isFresh()); } public function testIsNotFreshWithchecker() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') ->willReturn(true); $checker->expects($this->once()) ->method('isFresh') ->willReturn(false); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('', array(new ResourceStub())); $this->assertFalse($cache->isFresh()); } public function testCacheIsNotFreshWhenUnserializeFails() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('foo', array(new FileResource(__FILE__))); $metaFile = "{$this->cacheFile}.meta"; file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile))); $this->assertFalse($cache->isFresh()); } public function testCacheKeepsContent() { $cache = new ResourceCheckerConfigCache($this->cacheFile); $cache->write('FOOBAR'); $this->assertSame('FOOBAR', file_get_contents($cache->getPath())); } public function testCacheIsNotFreshIfNotExistsMetaFile() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('foo', array(new FileResource(__FILE__))); $metaFile = "{$this->cacheFile}.meta"; unlink($metaFile); $this->assertFalse($cache->isFresh()); } } symfony-3.4.6/src/Symfony/Component/Config/Tests/Util/000077500000000000000000000000001324732107100226515ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php000066400000000000000000000202701324732107100260040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Util; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Util\XmlUtils; class XmlUtilsTest extends TestCase { public function testLoadFile() { $fixtures = __DIR__.'/../Fixtures/Util/'; try { XmlUtils::loadFile($fixtures.'invalid.xml'); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertContains('ERROR 77', $e->getMessage()); } try { XmlUtils::loadFile($fixtures.'document_type.xml'); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertContains('Document types are not allowed', $e->getMessage()); } try { XmlUtils::loadFile($fixtures.'invalid_schema.xml', $fixtures.'schema.xsd'); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertContains('ERROR 1845', $e->getMessage()); } try { XmlUtils::loadFile($fixtures.'invalid_schema.xml', 'invalid_callback_or_file'); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertContains('XSD file or callable', $e->getMessage()); } $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); $mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true)); try { XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate')); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertRegExp('/The XML file "[\w:\/\\\.-]+" is not valid\./', $e->getMessage()); } $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate'))); $this->assertSame(array(), libxml_get_errors()); } /** * @expectedException \Symfony\Component\Config\Util\Exception\InvalidXmlException * @expectedExceptionMessage The XML is not valid */ public function testParseWithInvalidValidatorCallable() { $fixtures = __DIR__.'/../Fixtures/Util/'; $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); $mock->expects($this->once())->method('validate')->willReturn(false); XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), array($mock, 'validate')); } public function testLoadFileWithInternalErrorsEnabled() { $internalErrors = libxml_use_internal_errors(true); $this->assertSame(array(), libxml_get_errors()); $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); $this->assertSame(array(), libxml_get_errors()); libxml_clear_errors(); libxml_use_internal_errors($internalErrors); } /** * @dataProvider getDataForConvertDomToArray */ public function testConvertDomToArray($expected, $xml, $root = false, $checkPrefix = true) { $dom = new \DOMDocument(); $dom->loadXML($root ? $xml : ''.$xml.''); $this->assertSame($expected, XmlUtils::convertDomElementToArray($dom->documentElement, $checkPrefix)); } public function getDataForConvertDomToArray() { return array( array(null, ''), array('bar', 'bar'), array(array('bar' => 'foobar'), '', true), array(array('foo' => null), ''), array(array('foo' => 'bar'), 'bar'), array(array('foo' => array('foo' => 'bar')), ''), array(array('foo' => array('foo' => 0)), '0'), array(array('foo' => array('foo' => 'bar')), 'bar'), array(array('foo' => array('foo' => 'bar', 'value' => 'text')), 'text'), array(array('foo' => array('attr' => 'bar', 'foo' => 'text')), 'text'), array(array('foo' => array('bar', 'text')), 'bartext'), array(array('foo' => array(array('foo' => 'bar'), array('foo' => 'text'))), ''), array(array('foo' => array('foo' => array('bar', 'text'))), 'text'), array(array('foo' => 'bar'), 'bar'), array(array('foo' => 'text'), 'text'), array(array('foo' => array('bar' => 'bar', 'value' => 'text')), 'text', false, false), array(array('attr' => 1, 'b' => 'hello'), 'hello2', true), ); } /** * @dataProvider getDataForPhpize */ public function testPhpize($expected, $value) { $this->assertSame($expected, XmlUtils::phpize($value)); } public function getDataForPhpize() { return array( array('', ''), array(null, 'null'), array(true, 'true'), array(false, 'false'), array(null, 'Null'), array(true, 'True'), array(false, 'False'), array(0, '0'), array(1, '1'), array(-1, '-1'), array(0777, '0777'), array(255, '0xFF'), array(100.0, '1e2'), array(-120.0, '-1.2E2'), array(-10100.1, '-10100.1'), array('-10,100.1', '-10,100.1'), array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'), array('1,2,3,4', '1,2,3,4'), array('11,22,33,44', '11,22,33,44'), array('11,222,333,4', '11,222,333,4'), array('1,222,333,444', '1,222,333,444'), array('11,222,333,444', '11,222,333,444'), array('111,222,333,444', '111,222,333,444'), array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'), array('foo', 'foo'), array(6, '0b0110'), ); } public function testLoadEmptyXmlFile() { $file = __DIR__.'/../Fixtures/foo.xml'; if (method_exists($this, 'expectException')) { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file)); } else { $this->setExpectedException('InvalidArgumentException', sprintf('File %s does not contain valid XML, it is empty.', $file)); } XmlUtils::loadFile($file); } // test for issue https://github.com/symfony/symfony/issues/9731 public function testLoadWrongEmptyXMLWithErrorHandler() { $originalDisableEntities = libxml_disable_entity_loader(false); $errorReporting = error_reporting(-1); set_error_handler(function ($errno, $errstr) { throw new \Exception($errstr, $errno); }); $file = __DIR__.'/../Fixtures/foo.xml'; try { try { XmlUtils::loadFile($file); $this->fail('An exception should have been raised'); } catch (\InvalidArgumentException $e) { $this->assertEquals(sprintf('File %s does not contain valid XML, it is empty.', $file), $e->getMessage()); } } finally { restore_error_handler(); error_reporting($errorReporting); } $disableEntities = libxml_disable_entity_loader(true); libxml_disable_entity_loader($disableEntities); libxml_disable_entity_loader($originalDisableEntities); $this->assertFalse($disableEntities); // should not throw an exception XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/valid.xml', __DIR__.'/../Fixtures/Util/schema.xsd'); } } interface Validator { public function validate(); } symfony-3.4.6/src/Symfony/Component/Config/Util/000077500000000000000000000000001324732107100215475ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Util/Exception/000077500000000000000000000000001324732107100235055ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Config/Util/Exception/InvalidXmlException.php000066400000000000000000000010451324732107100301440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Util\Exception; /** * Exception class for when XML parsing with an XSD schema file path or a callable validator produces errors unrelated * to the actual XML parsing. * * @author Ole Rößner */ class InvalidXmlException extends XmlParsingException { } symfony-3.4.6/src/Symfony/Component/Config/Util/Exception/XmlParsingException.php000066400000000000000000000007221324732107100301620ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Util\Exception; /** * Exception class for when XML cannot be parsed properly. * * @author Ole Rößner */ class XmlParsingException extends \InvalidArgumentException { } symfony-3.4.6/src/Symfony/Component/Config/Util/XmlUtils.php000066400000000000000000000222731324732107100240470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Util; use Symfony\Component\Config\Util\Exception\InvalidXmlException; use Symfony\Component\Config\Util\Exception\XmlParsingException; /** * XMLUtils is a bunch of utility methods to XML operations. * * This class contains static methods only and is not meant to be instantiated. * * @author Fabien Potencier * @author Martin Hasoň * @author Ole Rößner */ class XmlUtils { /** * This class should not be instantiated. */ private function __construct() { } /** * Parses an XML string. * * @param string $content An XML string * @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation * * @return \DOMDocument * * @throws XmlParsingException When parsing of XML file returns error * @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself * @throws \RuntimeException When DOM extension is missing */ public static function parse($content, $schemaOrCallable = null) { if (!extension_loaded('dom')) { throw new \RuntimeException('Extension DOM is required.'); } $internalErrors = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); libxml_clear_errors(); $dom = new \DOMDocument(); $dom->validateOnParse = true; if (!$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { libxml_disable_entity_loader($disableEntities); throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors))); } $dom->normalizeDocument(); libxml_use_internal_errors($internalErrors); libxml_disable_entity_loader($disableEntities); foreach ($dom->childNodes as $child) { if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new XmlParsingException('Document types are not allowed.'); } } if (null !== $schemaOrCallable) { $internalErrors = libxml_use_internal_errors(true); libxml_clear_errors(); $e = null; if (is_callable($schemaOrCallable)) { try { $valid = call_user_func($schemaOrCallable, $dom, $internalErrors); } catch (\Exception $e) { $valid = false; } } elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) { $schemaSource = file_get_contents((string) $schemaOrCallable); $valid = @$dom->schemaValidateSource($schemaSource); } else { libxml_use_internal_errors($internalErrors); throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.'); } if (!$valid) { $messages = static::getXmlErrors($internalErrors); if (empty($messages)) { throw new InvalidXmlException('The XML is not valid.', 0, $e); } throw new XmlParsingException(implode("\n", $messages), 0, $e); } } libxml_clear_errors(); libxml_use_internal_errors($internalErrors); return $dom; } /** * Loads an XML file. * * @param string $file An XML file path * @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation * * @return \DOMDocument * * @throws \InvalidArgumentException When loading of XML file returns error * @throws XmlParsingException When XML parsing returns any errors * @throws \RuntimeException When DOM extension is missing */ public static function loadFile($file, $schemaOrCallable = null) { $content = @file_get_contents($file); if ('' === trim($content)) { throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file)); } try { return static::parse($content, $schemaOrCallable); } catch (InvalidXmlException $e) { throw new XmlParsingException(sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious()); } } /** * Converts a \DOMElement object to a PHP array. * * The following rules applies during the conversion: * * * Each tag is converted to a key value or an array * if there is more than one "value" * * * The content of a tag is set under a "value" key (bar) * if the tag also has some nested tags * * * The attributes are converted to keys () * * * The nested-tags are converted to keys (bar) * * @param \DOMElement $element A \DOMElement instance * @param bool $checkPrefix Check prefix in an element or an attribute name * * @return array A PHP array */ public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true) { $prefix = (string) $element->prefix; $empty = true; $config = array(); foreach ($element->attributes as $name => $node) { if ($checkPrefix && !in_array((string) $node->prefix, array('', $prefix), true)) { continue; } $config[$name] = static::phpize($node->value); $empty = false; } $nodeValue = false; foreach ($element->childNodes as $node) { if ($node instanceof \DOMText) { if ('' !== trim($node->nodeValue)) { $nodeValue = trim($node->nodeValue); $empty = false; } } elseif ($checkPrefix && $prefix != (string) $node->prefix) { continue; } elseif (!$node instanceof \DOMComment) { $value = static::convertDomElementToArray($node, $checkPrefix); $key = $node->localName; if (isset($config[$key])) { if (!is_array($config[$key]) || !is_int(key($config[$key]))) { $config[$key] = array($config[$key]); } $config[$key][] = $value; } else { $config[$key] = $value; } $empty = false; } } if (false !== $nodeValue) { $value = static::phpize($nodeValue); if (count($config)) { $config['value'] = $value; } else { $config = $value; } } return !$empty ? $config : null; } /** * Converts an xml value to a PHP type. * * @param mixed $value * * @return mixed */ public static function phpize($value) { $value = (string) $value; $lowercaseValue = strtolower($value); switch (true) { case 'null' === $lowercaseValue: return; case ctype_digit($value): $raw = $value; $cast = (int) $value; return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)): $raw = $value; $cast = (int) $value; return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); case 'true' === $lowercaseValue: return true; case 'false' === $lowercaseValue: return false; case isset($value[1]) && '0b' == $value[0].$value[1]: return bindec($value); case is_numeric($value): return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value; case preg_match('/^0x[0-9a-f]++$/i', $value): return hexdec($value); case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value): return (float) $value; default: return $value; } } protected static function getXmlErrors($internalErrors) { $errors = array(); foreach (libxml_get_errors() as $error) { $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', $error->code, trim($error->message), $error->file ?: 'n/a', $error->line, $error->column ); } libxml_clear_errors(); libxml_use_internal_errors($internalErrors); return $errors; } } symfony-3.4.6/src/Symfony/Component/Config/composer.json000066400000000000000000000022641324732107100233600ustar00rootroot00000000000000{ "name": "symfony/config", "type": "library", "description": "Symfony Config Component", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": "^5.5.9|>=7.0.8", "symfony/filesystem": "~2.8|~3.0|~4.0" }, "require-dev": { "symfony/finder": "~3.3|~4.0", "symfony/yaml": "~3.0|~4.0", "symfony/dependency-injection": "~3.3|~4.0", "symfony/event-dispatcher": "~3.3|~4.0" }, "conflict": { "symfony/finder": "<3.3", "symfony/dependency-injection": "<3.3" }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" }, "autoload": { "psr-4": { "Symfony\\Component\\Config\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "3.4-dev" } } } symfony-3.4.6/src/Symfony/Component/Config/phpunit.xml.dist000066400000000000000000000015641324732107100240130ustar00rootroot00000000000000 ./Tests/ ./ ./Resources ./Tests ./vendor symfony-3.4.6/src/Symfony/Component/Console/000077500000000000000000000000001324732107100210275ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/.gitignore000066400000000000000000000000421324732107100230130ustar00rootroot00000000000000vendor/ composer.lock phpunit.xml symfony-3.4.6/src/Symfony/Component/Console/Application.php000066400000000000000000001232521324732107100240100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console; use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\DebugFormatterHelper; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Helper\ProcessHelper; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\StreamableInputInterface; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputAwareInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\ListCommand; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * An Application is the container for a collection of commands. * * It is the main entry point of a Console application. * * This class is optimized for a standard CLI environment. * * Usage: * * $app = new Application('myapp', '1.0 (stable)'); * $app->add(new SimpleCommand()); * $app->run(); * * @author Fabien Potencier */ class Application { private $commands = array(); private $wantHelps = false; private $runningCommand; private $name; private $version; private $commandLoader; private $catchExceptions = true; private $autoExit = true; private $definition; private $helperSet; private $dispatcher; private $terminal; private $defaultCommand; private $singleCommand; private $initialized; /** * @param string $name The name of the application * @param string $version The version of the application */ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { $this->name = $name; $this->version = $version; $this->terminal = new Terminal(); $this->defaultCommand = 'list'; } public function setDispatcher(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } public function setCommandLoader(CommandLoaderInterface $commandLoader) { $this->commandLoader = $commandLoader; } /** * Runs the current application. * * @return int 0 if everything went fine, or an error code * * @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}. */ public function run(InputInterface $input = null, OutputInterface $output = null) { putenv('LINES='.$this->terminal->getHeight()); putenv('COLUMNS='.$this->terminal->getWidth()); if (null === $input) { $input = new ArgvInput(); } if (null === $output) { $output = new ConsoleOutput(); } $renderException = function ($e) use ($output) { if (!$e instanceof \Exception) { $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } if ($output instanceof ConsoleOutputInterface) { $this->renderException($e, $output->getErrorOutput()); } else { $this->renderException($e, $output); } }; if ($phpHandler = set_exception_handler($renderException)) { restore_exception_handler(); if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) { $debugHandler = true; } elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) { $phpHandler[0]->setExceptionHandler($debugHandler); } } if (null !== $this->dispatcher && $this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) { @trigger_error(sprintf('The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.'), E_USER_DEPRECATED); } $this->configureIO($input, $output); try { $exitCode = $this->doRun($input, $output); } catch (\Exception $e) { if (!$this->catchExceptions) { throw $e; } $renderException($e); $exitCode = $e->getCode(); if (is_numeric($exitCode)) { $exitCode = (int) $exitCode; if (0 === $exitCode) { $exitCode = 1; } } else { $exitCode = 1; } } finally { // if the exception handler changed, keep it // otherwise, unregister $renderException if (!$phpHandler) { if (set_exception_handler($renderException) === $renderException) { restore_exception_handler(); } restore_exception_handler(); } elseif (!$debugHandler) { $finalHandler = $phpHandler[0]->setExceptionHandler(null); if ($finalHandler !== $renderException) { $phpHandler[0]->setExceptionHandler($finalHandler); } } } if ($this->autoExit) { if ($exitCode > 255) { $exitCode = 255; } exit($exitCode); } return $exitCode; } /** * Runs the current application. * * @return int 0 if everything went fine, or an error code */ public function doRun(InputInterface $input, OutputInterface $output) { if (true === $input->hasParameterOption(array('--version', '-V'), true)) { $output->writeln($this->getLongVersion()); return 0; } $name = $this->getCommandName($input); if (true === $input->hasParameterOption(array('--help', '-h'), true)) { if (!$name) { $name = 'help'; $input = new ArrayInput(array('command_name' => $this->defaultCommand)); } else { $this->wantHelps = true; } } if (!$name) { $name = $this->defaultCommand; $definition = $this->getDefinition(); $definition->setArguments(array_merge( $definition->getArguments(), array( 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name), ) )); } try { $e = $this->runningCommand = null; // the command name MUST be the first element of the input $command = $this->find($name); } catch (\Exception $e) { } catch (\Throwable $e) { } if (null !== $e) { if (null !== $this->dispatcher) { $event = new ConsoleErrorEvent($input, $output, $e); $this->dispatcher->dispatch(ConsoleEvents::ERROR, $event); $e = $event->getError(); if (0 === $event->getExitCode()) { return 0; } } throw $e; } $this->runningCommand = $command; $exitCode = $this->doRunCommand($command, $input, $output); $this->runningCommand = null; return $exitCode; } public function setHelperSet(HelperSet $helperSet) { $this->helperSet = $helperSet; } /** * Get the helper set associated with the command. * * @return HelperSet The HelperSet instance associated with this command */ public function getHelperSet() { if (!$this->helperSet) { $this->helperSet = $this->getDefaultHelperSet(); } return $this->helperSet; } public function setDefinition(InputDefinition $definition) { $this->definition = $definition; } /** * Gets the InputDefinition related to this Application. * * @return InputDefinition The InputDefinition instance */ public function getDefinition() { if (!$this->definition) { $this->definition = $this->getDefaultInputDefinition(); } if ($this->singleCommand) { $inputDefinition = $this->definition; $inputDefinition->setArguments(); return $inputDefinition; } return $this->definition; } /** * Gets the help message. * * @return string A help message */ public function getHelp() { return $this->getLongVersion(); } /** * Gets whether to catch exceptions or not during commands execution. * * @return bool Whether to catch exceptions or not during commands execution */ public function areExceptionsCaught() { return $this->catchExceptions; } /** * Sets whether to catch exceptions or not during commands execution. * * @param bool $boolean Whether to catch exceptions or not during commands execution */ public function setCatchExceptions($boolean) { $this->catchExceptions = (bool) $boolean; } /** * Gets whether to automatically exit after a command execution or not. * * @return bool Whether to automatically exit after a command execution or not */ public function isAutoExitEnabled() { return $this->autoExit; } /** * Sets whether to automatically exit after a command execution or not. * * @param bool $boolean Whether to automatically exit after a command execution or not */ public function setAutoExit($boolean) { $this->autoExit = (bool) $boolean; } /** * Gets the name of the application. * * @return string The application name */ public function getName() { return $this->name; } /** * Sets the application name. * * @param string $name The application name */ public function setName($name) { $this->name = $name; } /** * Gets the application version. * * @return string The application version */ public function getVersion() { return $this->version; } /** * Sets the application version. * * @param string $version The application version */ public function setVersion($version) { $this->version = $version; } /** * Returns the long version of the application. * * @return string The long application version */ public function getLongVersion() { if ('UNKNOWN' !== $this->getName()) { if ('UNKNOWN' !== $this->getVersion()) { return sprintf('%s %s', $this->getName(), $this->getVersion()); } return $this->getName(); } return 'Console Tool'; } /** * Registers a new command. * * @param string $name The command name * * @return Command The newly created command */ public function register($name) { return $this->add(new Command($name)); } /** * Adds an array of command objects. * * If a Command is not enabled it will not be added. * * @param Command[] $commands An array of commands */ public function addCommands(array $commands) { foreach ($commands as $command) { $this->add($command); } } /** * Adds a command object. * * If a command with the same name already exists, it will be overridden. * If the command is not enabled it will not be added. * * @return Command|null The registered command if enabled or null */ public function add(Command $command) { $this->init(); $command->setApplication($this); if (!$command->isEnabled()) { $command->setApplication(null); return; } if (null === $command->getDefinition()) { throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command))); } if (!$command->getName()) { throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_class($command))); } $this->commands[$command->getName()] = $command; foreach ($command->getAliases() as $alias) { $this->commands[$alias] = $command; } return $command; } /** * Returns a registered command by name or alias. * * @param string $name The command name or alias * * @return Command A Command object * * @throws CommandNotFoundException When given command name does not exist */ public function get($name) { $this->init(); if (!$this->has($name)) { throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name)); } $command = $this->commands[$name]; if ($this->wantHelps) { $this->wantHelps = false; $helpCommand = $this->get('help'); $helpCommand->setCommand($command); return $helpCommand; } return $command; } /** * Returns true if the command exists, false otherwise. * * @param string $name The command name or alias * * @return bool true if the command exists, false otherwise */ public function has($name) { $this->init(); return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name))); } /** * Returns an array of all unique namespaces used by currently registered commands. * * It does not return the global namespace which always exists. * * @return string[] An array of namespaces */ public function getNamespaces() { $namespaces = array(); foreach ($this->all() as $command) { $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName())); foreach ($command->getAliases() as $alias) { $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias)); } } return array_values(array_unique(array_filter($namespaces))); } /** * Finds a registered namespace by a name or an abbreviation. * * @param string $namespace A namespace or abbreviation to search for * * @return string A registered namespace * * @throws CommandNotFoundException When namespace is incorrect or ambiguous */ public function findNamespace($namespace) { $allNamespaces = $this->getNamespaces(); $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace); $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); if (empty($namespaces)) { $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) { if (1 == count($alternatives)) { $message .= "\n\nDid you mean this?\n "; } else { $message .= "\n\nDid you mean one of these?\n "; } $message .= implode("\n ", $alternatives); } throw new CommandNotFoundException($message, $alternatives); } $exact = in_array($namespace, $namespaces, true); if (count($namespaces) > 1 && !$exact) { throw new CommandNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces)); } return $exact ? $namespace : reset($namespaces); } /** * Finds a command by name or alias. * * Contrary to get, this command tries to find the best * match if you give it an abbreviation of a name or alias. * * @param string $name A command name or a command alias * * @return Command A Command instance * * @throws CommandNotFoundException When command name is incorrect or ambiguous */ public function find($name) { $this->init(); $aliases = array(); $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands); $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name); $commands = preg_grep('{^'.$expr.'}', $allCommands); if (empty($commands)) { $commands = preg_grep('{^'.$expr.'}i', $allCommands); } // if no commands matched or we just matched namespaces if (empty($commands) || count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) { if (false !== $pos = strrpos($name, ':')) { // check if a namespace exists and contains commands $this->findNamespace(substr($name, 0, $pos)); } $message = sprintf('Command "%s" is not defined.', $name); if ($alternatives = $this->findAlternatives($name, $allCommands)) { if (1 == count($alternatives)) { $message .= "\n\nDid you mean this?\n "; } else { $message .= "\n\nDid you mean one of these?\n "; } $message .= implode("\n ", $alternatives); } throw new CommandNotFoundException($message, $alternatives); } // filter out aliases for commands which are already on the list if (count($commands) > 1) { $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands; $commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) { $commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias; $aliases[$nameOrAlias] = $commandName; return $commandName === $nameOrAlias || !in_array($commandName, $commands); })); } $exact = in_array($name, $commands, true) || isset($aliases[$name]); if (count($commands) > 1 && !$exact) { $usableWidth = $this->terminal->getWidth() - 10; $abbrevs = array_values($commands); $maxLen = 0; foreach ($abbrevs as $abbrev) { $maxLen = max(Helper::strlen($abbrev), $maxLen); } $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) { if (!$commandList[$cmd] instanceof Command) { return $cmd; } $abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription(); return Helper::strlen($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev; }, array_values($commands)); $suggestions = $this->getAbbreviationSuggestions($abbrevs); throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $name, $suggestions), array_values($commands)); } return $this->get($exact ? $name : reset($commands)); } /** * Gets the commands (registered in the given namespace if provided). * * The array keys are the full names and the values the command instances. * * @param string $namespace A namespace name * * @return Command[] An array of Command instances */ public function all($namespace = null) { $this->init(); if (null === $namespace) { if (!$this->commandLoader) { return $this->commands; } $commands = $this->commands; foreach ($this->commandLoader->getNames() as $name) { if (!isset($commands[$name]) && $this->has($name)) { $commands[$name] = $this->get($name); } } return $commands; } $commands = array(); foreach ($this->commands as $name => $command) { if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) { $commands[$name] = $command; } } if ($this->commandLoader) { foreach ($this->commandLoader->getNames() as $name) { if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) { $commands[$name] = $this->get($name); } } } return $commands; } /** * Returns an array of possible abbreviations given a set of names. * * @param array $names An array of names * * @return array An array of abbreviations */ public static function getAbbreviations($names) { $abbrevs = array(); foreach ($names as $name) { for ($len = strlen($name); $len > 0; --$len) { $abbrev = substr($name, 0, $len); $abbrevs[$abbrev][] = $name; } } return $abbrevs; } /** * Renders a caught exception. */ public function renderException(\Exception $e, OutputInterface $output) { $output->writeln('', OutputInterface::VERBOSITY_QUIET); $this->doRenderException($e, $output); if (null !== $this->runningCommand) { $output->writeln(sprintf('%s', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET); $output->writeln('', OutputInterface::VERBOSITY_QUIET); } } protected function doRenderException(\Exception $e, OutputInterface $output) { do { $message = trim($e->getMessage()); if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $title = sprintf(' [%s%s] ', get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : ''); $len = Helper::strlen($title); } else { $len = 0; } $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX; // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327 if (defined('HHVM_VERSION') && $width > 1 << 31) { $width = 1 << 31; } $lines = array(); foreach ('' !== $message ? preg_split('/\r?\n/', $message) : array() as $line) { foreach ($this->splitStringByWidth($line, $width - 4) as $line) { // pre-format lines to get the right string length $lineLength = Helper::strlen($line) + 4; $lines[] = array($line, $lineLength); $len = max($lineLength, $len); } } $messages = array(); if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $messages[] = sprintf('%s', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a'))); } $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len)); if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - Helper::strlen($title)))); } foreach ($lines as $line) { $messages[] = sprintf(' %s %s', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1])); } $messages[] = $emptyLine; $messages[] = ''; $output->writeln($messages, OutputInterface::VERBOSITY_QUIET); if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln('Exception trace:', OutputInterface::VERBOSITY_QUIET); // exception related properties $trace = $e->getTrace(); for ($i = 0, $count = count($trace); $i < $count; ++$i) { $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; $function = $trace[$i]['function']; $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; $output->writeln(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET); } $output->writeln('', OutputInterface::VERBOSITY_QUIET); } } while ($e = $e->getPrevious()); } /** * Tries to figure out the terminal width in which this application runs. * * @return int|null * * @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead. */ protected function getTerminalWidth() { @trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); return $this->terminal->getWidth(); } /** * Tries to figure out the terminal height in which this application runs. * * @return int|null * * @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead. */ protected function getTerminalHeight() { @trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); return $this->terminal->getHeight(); } /** * Tries to figure out the terminal dimensions based on the current environment. * * @return array Array containing width and height * * @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead. */ public function getTerminalDimensions() { @trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); return array($this->terminal->getWidth(), $this->terminal->getHeight()); } /** * Sets terminal dimensions. * * Can be useful to force terminal dimensions for functional tests. * * @param int $width The width * @param int $height The height * * @return $this * * @deprecated since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead. */ public function setTerminalDimensions($width, $height) { @trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED); putenv('COLUMNS='.$width); putenv('LINES='.$height); return $this; } /** * Configures the input and output instances based on the user arguments and options. */ protected function configureIO(InputInterface $input, OutputInterface $output) { if (true === $input->hasParameterOption(array('--ansi'), true)) { $output->setDecorated(true); } elseif (true === $input->hasParameterOption(array('--no-ansi'), true)) { $output->setDecorated(false); } if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) { $input->setInteractive(false); } elseif (function_exists('posix_isatty')) { $inputStream = null; if ($input instanceof StreamableInputInterface) { $inputStream = $input->getStream(); } // This check ensures that calling QuestionHelper::setInputStream() works // To be removed in 4.0 (in the same time as QuestionHelper::setInputStream) if (!$inputStream && $this->getHelperSet()->has('question')) { $inputStream = $this->getHelperSet()->get('question')->getInputStream(false); } if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { $input->setInteractive(false); } } switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break; case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break; case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break; case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break; default: $shellVerbosity = 0; break; } if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) { $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); $shellVerbosity = -1; } else { if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) { $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $shellVerbosity = 3; } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) { $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); $shellVerbosity = 2; } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $shellVerbosity = 1; } } if (-1 === $shellVerbosity) { $input->setInteractive(false); } putenv('SHELL_VERBOSITY='.$shellVerbosity); $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; } /** * Runs the current command. * * If an event dispatcher has been attached to the application, * events are also dispatched during the life-cycle of the command. * * @return int 0 if everything went fine, or an error code */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { foreach ($command->getHelperSet() as $helper) { if ($helper instanceof InputAwareInterface) { $helper->setInput($input); } } if (null === $this->dispatcher) { return $command->run($input, $output); } // bind before the console.command event, so the listeners have access to input options/arguments try { $command->mergeApplicationDefinition(); $input->bind($command->getDefinition()); } catch (ExceptionInterface $e) { // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition } $event = new ConsoleCommandEvent($command, $input, $output); $e = null; try { $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event); if ($event->commandShouldRun()) { $exitCode = $command->run($input, $output); } else { $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED; } } catch (\Exception $e) { } catch (\Throwable $e) { } if (null !== $e) { if ($this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) { $x = $e instanceof \Exception ? $e : new FatalThrowableError($e); $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode()); $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event); if ($x !== $event->getException()) { $e = $event->getException(); } } $event = new ConsoleErrorEvent($input, $output, $e, $command); $this->dispatcher->dispatch(ConsoleEvents::ERROR, $event); $e = $event->getError(); if (0 === $exitCode = $event->getExitCode()) { $e = null; } } $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode); $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); if (null !== $e) { throw $e; } return $event->getExitCode(); } /** * Gets the name of the command based on input. * * @return string The command name */ protected function getCommandName(InputInterface $input) { return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument(); } /** * Gets the default input definition. * * @return InputDefinition An InputDefinition instance */ protected function getDefaultInputDefinition() { return new InputDefinition(array( new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'), new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'), new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), )); } /** * Gets the default commands that should always be available. * * @return Command[] An array of default Command instances */ protected function getDefaultCommands() { return array(new HelpCommand(), new ListCommand()); } /** * Gets the default helper set with the helpers that should always be available. * * @return HelperSet A HelperSet instance */ protected function getDefaultHelperSet() { return new HelperSet(array( new FormatterHelper(), new DebugFormatterHelper(), new ProcessHelper(), new QuestionHelper(), )); } /** * Returns abbreviated suggestions in string format. * * @param array $abbrevs Abbreviated suggestions to convert * * @return string A formatted string of abbreviated suggestions */ private function getAbbreviationSuggestions($abbrevs) { return ' '.implode("\n ", $abbrevs); } /** * Returns the namespace part of the command name. * * This method is not part of public API and should not be used directly. * * @param string $name The full name of the command * @param string $limit The maximum number of parts of the namespace * * @return string The namespace of the command */ public function extractNamespace($name, $limit = null) { $parts = explode(':', $name); array_pop($parts); return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit)); } /** * Finds alternative of $name among $collection, * if nothing is found in $collection, try in $abbrevs. * * @param string $name The string * @param iterable $collection The collection * * @return string[] A sorted array of similar string */ private function findAlternatives($name, $collection) { $threshold = 1e3; $alternatives = array(); $collectionParts = array(); foreach ($collection as $item) { $collectionParts[$item] = explode(':', $item); } foreach (explode(':', $name) as $i => $subname) { foreach ($collectionParts as $collectionName => $parts) { $exists = isset($alternatives[$collectionName]); if (!isset($parts[$i]) && $exists) { $alternatives[$collectionName] += $threshold; continue; } elseif (!isset($parts[$i])) { continue; } $lev = levenshtein($subname, $parts[$i]); if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) { $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; } elseif ($exists) { $alternatives[$collectionName] += $threshold; } } } foreach ($collection as $item) { $lev = levenshtein($name, $item); if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; }); ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); return array_keys($alternatives); } /** * Sets the default Command name. * * @param string $commandName The Command name * @param bool $isSingleCommand Set to true if there is only one command in this application * * @return self */ public function setDefaultCommand($commandName, $isSingleCommand = false) { $this->defaultCommand = $commandName; if ($isSingleCommand) { // Ensure the command exist $this->find($commandName); $this->singleCommand = true; } return $this; } private function splitStringByWidth($string, $width) { // str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly. // additionally, array_slice() is not enough as some character has doubled width. // we need a function to split string not by character count but by string width if (false === $encoding = mb_detect_encoding($string, null, true)) { return str_split($string, $width); } $utf8String = mb_convert_encoding($string, 'utf8', $encoding); $lines = array(); $line = ''; foreach (preg_split('//u', $utf8String) as $char) { // test if $char could be appended to current line if (mb_strwidth($line.$char, 'utf8') <= $width) { $line .= $char; continue; } // if not, push current line to array and make new line $lines[] = str_pad($line, $width); $line = $char; } $lines[] = count($lines) ? str_pad($line, $width) : $line; mb_convert_variables($encoding, 'utf8', $lines); return $lines; } /** * Returns all namespaces of the command name. * * @param string $name The full name of the command * * @return string[] The namespaces of the command */ private function extractAllNamespaces($name) { // -1 as third argument is needed to skip the command short name when exploding $parts = explode(':', $name, -1); $namespaces = array(); foreach ($parts as $part) { if (count($namespaces)) { $namespaces[] = end($namespaces).':'.$part; } else { $namespaces[] = $part; } } return $namespaces; } private function init() { if ($this->initialized) { return; } $this->initialized = true; foreach ($this->getDefaultCommands() as $command) { $this->add($command); } } } symfony-3.4.6/src/Symfony/Component/Console/CHANGELOG.md000066400000000000000000000072421324732107100226450ustar00rootroot00000000000000CHANGELOG ========= 3.4.0 ----- * added `SHELL_VERBOSITY` env var to control verbosity * added `CommandLoaderInterface`, `FactoryCommandLoader` and PSR-11 `ContainerCommandLoader` for commands lazy-loading * added a case-insensitive command name matching fallback * added static `Command::$defaultName/getDefaultName()`, allowing for commands to be registered at compile time in the application command loader. Setting the `$defaultName` property avoids the need for filling the `command` attribute on the `console.command` tag when using `AddConsoleCommandPass`. 3.3.0 ----- * added `ExceptionListener` * added `AddConsoleCommandPass` (originally in FrameworkBundle) * [BC BREAK] `Input::getOption()` no longer returns the default value for options with value optional explicitly passed empty * added console.error event to catch exceptions thrown by other listeners * deprecated console.exception event in favor of console.error * added ability to handle `CommandNotFoundException` through the `console.error` event * deprecated default validation in `SymfonyQuestionHelper::ask` 3.2.0 ------ * added `setInputs()` method to CommandTester for ease testing of commands expecting inputs * added `setStream()` and `getStream()` methods to Input (implement StreamableInputInterface) * added StreamableInputInterface * added LockableTrait 3.1.0 ----- * added truncate method to FormatterHelper * added setColumnWidth(s) method to Table 2.8.3 ----- * remove readline support from the question helper as it caused issues 2.8.0 ----- * use readline for user input in the question helper when available to allow the use of arrow keys 2.6.0 ----- * added a Process helper * added a DebugFormatter helper 2.5.0 ----- * deprecated the dialog helper (use the question helper instead) * deprecated TableHelper in favor of Table * deprecated ProgressHelper in favor of ProgressBar * added ConsoleLogger * added a question helper * added a way to set the process name of a command * added a way to set a default command instead of `ListCommand` 2.4.0 ----- * added a way to force terminal dimensions * added a convenient method to detect verbosity level * [BC BREAK] made descriptors use output instead of returning a string 2.3.0 ----- * added multiselect support to the select dialog helper * added Table Helper for tabular data rendering * added support for events in `Application` * added a way to normalize EOLs in `ApplicationTester::getDisplay()` and `CommandTester::getDisplay()` * added a way to set the progress bar progress via the `setCurrent` method * added support for multiple InputOption shortcuts, written as `'-a|-b|-c'` * added two additional verbosity levels, VERBOSITY_VERY_VERBOSE and VERBOSITY_DEBUG 2.2.0 ----- * added support for colorization on Windows via ConEmu * add a method to Dialog Helper to ask for a question and hide the response * added support for interactive selections in console (DialogHelper::select()) * added support for autocompletion as you type in Dialog Helper 2.1.0 ----- * added ConsoleOutputInterface * added the possibility to disable a command (Command::isEnabled()) * added suggestions when a command does not exist * added a --raw option to the list command * added support for STDERR in the console output class (errors are now sent to STDERR) * made the defaults (helper set, commands, input definition) in Application more easily customizable * added support for the shell even if readline is not available * added support for process isolation in Symfony shell via `--process-isolation` switch * added support for `--`, which disables options parsing after that point (tokens will be parsed as arguments) symfony-3.4.6/src/Symfony/Component/Console/Command/000077500000000000000000000000001324732107100224055ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Command/Command.php000066400000000000000000000446761324732107100245150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * Base class for all commands. * * @author Fabien Potencier */ class Command { /** * @var string|null The default command name */ protected static $defaultName; private $application; private $name; private $processTitle; private $aliases = array(); private $definition; private $hidden = false; private $help; private $description; private $ignoreValidationErrors = false; private $applicationDefinitionMerged = false; private $applicationDefinitionMergedWithArgs = false; private $code; private $synopsis = array(); private $usages = array(); private $helperSet; /** * @return string|null The default command name or null when no default name is set */ public static function getDefaultName() { $class = get_called_class(); $r = new \ReflectionProperty($class, 'defaultName'); return $class === $r->class ? static::$defaultName : null; } /** * @param string|null $name The name of the command; passing null means it must be set in configure() * * @throws LogicException When the command name is empty */ public function __construct($name = null) { $this->definition = new InputDefinition(); if (null !== $name || null !== $name = static::getDefaultName()) { $this->setName($name); } $this->configure(); } /** * Ignores validation errors. * * This is mainly useful for the help command. */ public function ignoreValidationErrors() { $this->ignoreValidationErrors = true; } public function setApplication(Application $application = null) { $this->application = $application; if ($application) { $this->setHelperSet($application->getHelperSet()); } else { $this->helperSet = null; } } public function setHelperSet(HelperSet $helperSet) { $this->helperSet = $helperSet; } /** * Gets the helper set. * * @return HelperSet A HelperSet instance */ public function getHelperSet() { return $this->helperSet; } /** * Gets the application instance for this command. * * @return Application An Application instance */ public function getApplication() { return $this->application; } /** * Checks whether the command is enabled or not in the current environment. * * Override this to check for x or y and return false if the command can not * run properly under the current conditions. * * @return bool */ public function isEnabled() { return true; } /** * Configures the current command. */ protected function configure() { } /** * Executes the current command. * * This method is not abstract because you can use this class * as a concrete class. In this case, instead of defining the * execute() method, you set the code to execute by passing * a Closure to the setCode() method. * * @return null|int null or 0 if everything went fine, or an error code * * @throws LogicException When this abstract method is not implemented * * @see setCode() */ protected function execute(InputInterface $input, OutputInterface $output) { throw new LogicException('You must override the execute() method in the concrete command class.'); } /** * Interacts with the user. * * This method is executed before the InputDefinition is validated. * This means that this is the only place where the command can * interactively ask for values of missing required arguments. */ protected function interact(InputInterface $input, OutputInterface $output) { } /** * Initializes the command just after the input has been validated. * * This is mainly useful when a lot of commands extends one main command * where some things need to be initialized based on the input arguments and options. */ protected function initialize(InputInterface $input, OutputInterface $output) { } /** * Runs the command. * * The code to execute is either defined directly with the * setCode() method or by overriding the execute() method * in a sub-class. * * @return int The command exit code * * @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}. * * @see setCode() * @see execute() */ public function run(InputInterface $input, OutputInterface $output) { // force the creation of the synopsis before the merge with the app definition $this->getSynopsis(true); $this->getSynopsis(false); // add the application arguments and options $this->mergeApplicationDefinition(); // bind the input against the command specific arguments/options try { $input->bind($this->definition); } catch (ExceptionInterface $e) { if (!$this->ignoreValidationErrors) { throw $e; } } $this->initialize($input, $output); if (null !== $this->processTitle) { if (function_exists('cli_set_process_title')) { if (false === @cli_set_process_title($this->processTitle)) { if ('Darwin' === PHP_OS) { $output->writeln('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); } else { $error = error_get_last(); trigger_error($error['message'], E_USER_WARNING); } } } elseif (function_exists('setproctitle')) { setproctitle($this->processTitle); } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { $output->writeln('Install the proctitle PECL to be able to change the process title.'); } } if ($input->isInteractive()) { $this->interact($input, $output); } // The command name argument is often omitted when a command is executed directly with its run() method. // It would fail the validation if we didn't make sure the command argument is present, // since it's required by the application. if ($input->hasArgument('command') && null === $input->getArgument('command')) { $input->setArgument('command', $this->getName()); } $input->validate(); if ($this->code) { $statusCode = call_user_func($this->code, $input, $output); } else { $statusCode = $this->execute($input, $output); } return is_numeric($statusCode) ? (int) $statusCode : 0; } /** * Sets the code to execute when running this command. * * If this method is used, it overrides the code defined * in the execute() method. * * @param callable $code A callable(InputInterface $input, OutputInterface $output) * * @return $this * * @throws InvalidArgumentException * * @see execute() */ public function setCode(callable $code) { if ($code instanceof \Closure) { $r = new \ReflectionFunction($code); if (null === $r->getClosureThis()) { if (\PHP_VERSION_ID < 70000) { // Bug in PHP5: https://bugs.php.net/bug.php?id=64761 // This means that we cannot bind static closures and therefore we must // ignore any errors here. There is no way to test if the closure is // bindable. $code = @\Closure::bind($code, $this); } else { $code = \Closure::bind($code, $this); } } } $this->code = $code; return $this; } /** * Merges the application definition with the command definition. * * This method is not part of public API and should not be used directly. * * @param bool $mergeArgs Whether to merge or not the Application definition arguments to Command definition arguments */ public function mergeApplicationDefinition($mergeArgs = true) { if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) { return; } $this->definition->addOptions($this->application->getDefinition()->getOptions()); if ($mergeArgs) { $currentArguments = $this->definition->getArguments(); $this->definition->setArguments($this->application->getDefinition()->getArguments()); $this->definition->addArguments($currentArguments); } $this->applicationDefinitionMerged = true; if ($mergeArgs) { $this->applicationDefinitionMergedWithArgs = true; } } /** * Sets an array of argument and option instances. * * @param array|InputDefinition $definition An array of argument and option instances or a definition instance * * @return $this */ public function setDefinition($definition) { if ($definition instanceof InputDefinition) { $this->definition = $definition; } else { $this->definition->setDefinition($definition); } $this->applicationDefinitionMerged = false; return $this; } /** * Gets the InputDefinition attached to this Command. * * @return InputDefinition An InputDefinition instance */ public function getDefinition() { return $this->definition; } /** * Gets the InputDefinition to be used to create representations of this Command. * * Can be overridden to provide the original command representation when it would otherwise * be changed by merging with the application InputDefinition. * * This method is not part of public API and should not be used directly. * * @return InputDefinition An InputDefinition instance */ public function getNativeDefinition() { return $this->getDefinition(); } /** * Adds an argument. * * @param string $name The argument name * @param int $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL * @param string $description A description text * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * * @return $this */ public function addArgument($name, $mode = null, $description = '', $default = null) { $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); return $this; } /** * Adds an option. * * @param string $name The option name * @param string $shortcut The shortcut (can be null) * @param int $mode The option mode: One of the InputOption::VALUE_* constants * @param string $description A description text * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * * @return $this */ public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) { $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); return $this; } /** * Sets the name of the command. * * This method can set both the namespace and the name if * you separate them by a colon (:) * * $command->setName('foo:bar'); * * @param string $name The command name * * @return $this * * @throws InvalidArgumentException When the name is invalid */ public function setName($name) { $this->validateName($name); $this->name = $name; return $this; } /** * Sets the process title of the command. * * This feature should be used only when creating a long process command, * like a daemon. * * PHP 5.5+ or the proctitle PECL library is required * * @param string $title The process title * * @return $this */ public function setProcessTitle($title) { $this->processTitle = $title; return $this; } /** * Returns the command name. * * @return string The command name */ public function getName() { return $this->name; } /** * @param bool $hidden Whether or not the command should be hidden from the list of commands * * @return Command The current instance */ public function setHidden($hidden) { $this->hidden = (bool) $hidden; return $this; } /** * @return bool whether the command should be publicly shown or not */ public function isHidden() { return $this->hidden; } /** * Sets the description for the command. * * @param string $description The description for the command * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Returns the description for the command. * * @return string The description for the command */ public function getDescription() { return $this->description; } /** * Sets the help for the command. * * @param string $help The help for the command * * @return $this */ public function setHelp($help) { $this->help = $help; return $this; } /** * Returns the help for the command. * * @return string The help for the command */ public function getHelp() { return $this->help; } /** * Returns the processed help for the command replacing the %command.name% and * %command.full_name% patterns with the real values dynamically. * * @return string The processed help for the command */ public function getProcessedHelp() { $name = $this->name; $placeholders = array( '%command.name%', '%command.full_name%', ); $replacements = array( $name, $_SERVER['PHP_SELF'].' '.$name, ); return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription()); } /** * Sets the aliases for the command. * * @param string[] $aliases An array of aliases for the command * * @return $this * * @throws InvalidArgumentException When an alias is invalid */ public function setAliases($aliases) { if (!is_array($aliases) && !$aliases instanceof \Traversable) { throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable'); } foreach ($aliases as $alias) { $this->validateName($alias); } $this->aliases = $aliases; return $this; } /** * Returns the aliases for the command. * * @return array An array of aliases for the command */ public function getAliases() { return $this->aliases; } /** * Returns the synopsis for the command. * * @param bool $short Whether to show the short version of the synopsis (with options folded) or not * * @return string The synopsis */ public function getSynopsis($short = false) { $key = $short ? 'short' : 'long'; if (!isset($this->synopsis[$key])) { $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short))); } return $this->synopsis[$key]; } /** * Add a command usage example. * * @param string $usage The usage, it'll be prefixed with the command name * * @return $this */ public function addUsage($usage) { if (0 !== strpos($usage, $this->name)) { $usage = sprintf('%s %s', $this->name, $usage); } $this->usages[] = $usage; return $this; } /** * Returns alternative usages of the command. * * @return array */ public function getUsages() { return $this->usages; } /** * Gets a helper instance by name. * * @param string $name The helper name * * @return mixed The helper value * * @throws LogicException if no HelperSet is defined * @throws InvalidArgumentException if the helper is not defined */ public function getHelper($name) { if (null === $this->helperSet) { throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name)); } return $this->helperSet->get($name); } /** * Validates a command name. * * It must be non-empty and parts can optionally be separated by ":". * * @param string $name * * @throws InvalidArgumentException When the name is invalid */ private function validateName($name) { if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); } } } symfony-3.4.6/src/Symfony/Component/Console/Command/HelpCommand.php000066400000000000000000000045111324732107100253060ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * HelpCommand displays the help for a given command. * * @author Fabien Potencier */ class HelpCommand extends Command { private $command; /** * {@inheritdoc} */ protected function configure() { $this->ignoreValidationErrors(); $this ->setName('help') ->setDefinition(array( new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), )) ->setDescription('Displays help for a command') ->setHelp(<<<'EOF' The %command.name% command displays help for a given command: php %command.full_name% list You can also output the help in other formats by using the --format option: php %command.full_name% --format=xml list To display the list of available commands, please use the list command. EOF ) ; } public function setCommand(Command $command) { $this->command = $command; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (null === $this->command) { $this->command = $this->getApplication()->find($input->getArgument('command_name')); } $helper = new DescriptorHelper(); $helper->describe($output, $this->command, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), )); $this->command = null; } } symfony-3.4.6/src/Symfony/Component/Console/Command/ListCommand.php000066400000000000000000000050111324732107100253250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputDefinition; /** * ListCommand displays the list of all available commands for the application. * * @author Fabien Potencier */ class ListCommand extends Command { /** * {@inheritdoc} */ protected function configure() { $this ->setName('list') ->setDefinition($this->createDefinition()) ->setDescription('Lists commands') ->setHelp(<<<'EOF' The %command.name% command lists all commands: php %command.full_name% You can also display the commands for a specific namespace: php %command.full_name% test You can also output the information in other formats by using the --format option: php %command.full_name% --format=xml It's also possible to get raw list of commands (useful for embedding command runner): php %command.full_name% --raw EOF ) ; } /** * {@inheritdoc} */ public function getNativeDefinition() { return $this->createDefinition(); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $helper = new DescriptorHelper(); $helper->describe($output, $this->getApplication(), array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'namespace' => $input->getArgument('namespace'), )); } /** * {@inheritdoc} */ private function createDefinition() { return new InputDefinition(array( new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), )); } } symfony-3.4.6/src/Symfony/Component/Console/Command/LockableTrait.php000066400000000000000000000033441324732107100256420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Lock\Factory; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Store\FlockStore; use Symfony\Component\Lock\Store\SemaphoreStore; /** * Basic lock feature for commands. * * @author Geoffrey Brier */ trait LockableTrait { /** @var Lock */ private $lock; /** * Locks a command. * * @return bool */ private function lock($name = null, $blocking = false) { if (!class_exists(SemaphoreStore::class)) { throw new RuntimeException('To enable the locking feature you must install the symfony/lock component.'); } if (null !== $this->lock) { throw new LogicException('A lock is already in place.'); } if (SemaphoreStore::isSupported($blocking)) { $store = new SemaphoreStore(); } else { $store = new FlockStore(); } $this->lock = (new Factory($store))->createLock($name ?: $this->getName()); if (!$this->lock->acquire($blocking)) { $this->lock = null; return false; } return true; } /** * Releases the command lock if there is one. */ private function release() { if ($this->lock) { $this->lock->release(); $this->lock = null; } } } symfony-3.4.6/src/Symfony/Component/Console/CommandLoader/000077500000000000000000000000001324732107100235345ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php000066400000000000000000000012711324732107100305740ustar00rootroot00000000000000 */ interface CommandLoaderInterface { /** * Loads a command. * * @param string $name * * @return Command * * @throws CommandNotFoundException */ public function get($name); /** * Checks if a command exists. * * @param string $name * * @return bool */ public function has($name); /** * @return string[] All registered command names */ public function getNames(); } symfony-3.4.6/src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php000066400000000000000000000025271324732107100306230ustar00rootroot00000000000000 */ class ContainerCommandLoader implements CommandLoaderInterface { private $container; private $commandMap; /** * @param ContainerInterface $container A container from which to load command services * @param array $commandMap An array with command names as keys and service ids as values */ public function __construct(ContainerInterface $container, array $commandMap) { $this->container = $container; $this->commandMap = $commandMap; } /** * {@inheritdoc} */ public function get($name) { if (!$this->has($name)) { throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); } return $this->container->get($this->commandMap[$name]); } /** * {@inheritdoc} */ public function has($name) { return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]); } /** * {@inheritdoc} */ public function getNames() { return array_keys($this->commandMap); } } symfony-3.4.6/src/Symfony/Component/Console/CommandLoader/FactoryCommandLoader.php000066400000000000000000000024671324732107100303130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\CommandLoader; use Symfony\Component\Console\Exception\CommandNotFoundException; /** * A simple command loader using factories to instantiate commands lazily. * * @author Maxime Steinhausser */ class FactoryCommandLoader implements CommandLoaderInterface { private $factories; /** * @param callable[] $factories Indexed by command names */ public function __construct(array $factories) { $this->factories = $factories; } /** * {@inheritdoc} */ public function has($name) { return isset($this->factories[$name]); } /** * {@inheritdoc} */ public function get($name) { if (!isset($this->factories[$name])) { throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); } $factory = $this->factories[$name]; return $factory(); } /** * {@inheritdoc} */ public function getNames() { return array_keys($this->factories); } } symfony-3.4.6/src/Symfony/Component/Console/ConsoleEvents.php000066400000000000000000000034411324732107100243310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console; /** * Contains all events dispatched by an Application. * * @author Francesco Levorato */ final class ConsoleEvents { /** * The COMMAND event allows you to attach listeners before any command is * executed by the console. It also allows you to modify the command, input and output * before they are handled to the command. * * @Event("Symfony\Component\Console\Event\ConsoleCommandEvent") */ const COMMAND = 'console.command'; /** * The TERMINATE event allows you to attach listeners after a command is * executed by the console. * * @Event("Symfony\Component\Console\Event\ConsoleTerminateEvent") */ const TERMINATE = 'console.terminate'; /** * The EXCEPTION event occurs when an uncaught exception appears * while executing Command#run(). * * This event allows you to deal with the exception or * to modify the thrown exception. * * @Event("Symfony\Component\Console\Event\ConsoleExceptionEvent") * * @deprecated The console.exception event is deprecated since version 3.3 and will be removed in 4.0. Use the console.error event instead. */ const EXCEPTION = 'console.exception'; /** * The ERROR event occurs when an uncaught exception or error appears. * * This event allows you to deal with the exception/error or * to modify the thrown exception. * * @Event("Symfony\Component\Console\Event\ConsoleErrorEvent") */ const ERROR = 'console.error'; } symfony-3.4.6/src/Symfony/Component/Console/DependencyInjection/000077500000000000000000000000001324732107100247505ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php000066400000000000000000000077021324732107100316300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\DependencyInjection; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\TypedReference; /** * Registers console commands. * * @author Grégoire Pineau */ class AddConsoleCommandPass implements CompilerPassInterface { private $commandLoaderServiceId; private $commandTag; public function __construct($commandLoaderServiceId = 'console.command_loader', $commandTag = 'console.command') { $this->commandLoaderServiceId = $commandLoaderServiceId; $this->commandTag = $commandTag; } public function process(ContainerBuilder $container) { $commandServices = $container->findTaggedServiceIds($this->commandTag, true); $lazyCommandMap = array(); $lazyCommandRefs = array(); $serviceIds = array(); $lazyServiceIds = array(); foreach ($commandServices as $id => $tags) { $definition = $container->getDefinition($id); $class = $container->getParameterBag()->resolveValue($definition->getClass()); $commandId = 'console.command.'.strtolower(str_replace('\\', '_', $class)); if (isset($tags[0]['command'])) { $commandName = $tags[0]['command']; } else { if (!$r = $container->getReflectionClass($class)) { throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } if (!$r->isSubclassOf(Command::class)) { throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class)); } $commandName = $class::getDefaultName(); } if (null === $commandName) { if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) { $commandId = $commandId.'_'.$id; } if (!$definition->isPublic() || $definition->isPrivate()) { $container->setAlias($commandId, $id)->setPublic(true); $id = $commandId; } $serviceIds[$commandId] = $id; continue; } $serviceIds[$commandId] = $id; $lazyServiceIds[$id] = true; unset($tags[0]); $lazyCommandMap[$commandName] = $id; $lazyCommandRefs[$id] = new TypedReference($id, $class); $aliases = array(); foreach ($tags as $tag) { if (isset($tag['command'])) { $aliases[] = $tag['command']; $lazyCommandMap[$tag['command']] = $id; } } $definition->addMethodCall('setName', array($commandName)); if ($aliases) { $definition->addMethodCall('setAliases', array($aliases)); } } $container ->register($this->commandLoaderServiceId, ContainerCommandLoader::class) ->setPublic(true) ->setArguments(array(ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap)); $container->setParameter('console.command.ids', $serviceIds); $container->setParameter('console.lazy_command.ids', $lazyServiceIds); } } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/000077500000000000000000000000001324732107100231455ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php000066400000000000000000000074371324732107100303400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\CommandNotFoundException; /** * @author Jean-François Simon * * @internal */ class ApplicationDescription { const GLOBAL_NAMESPACE = '_global'; private $application; private $namespace; private $showHidden; /** * @var array */ private $namespaces; /** * @var Command[] */ private $commands; /** * @var Command[] */ private $aliases; /** * @param Application $application * @param string|null $namespace * @param bool $showHidden */ public function __construct(Application $application, $namespace = null, $showHidden = false) { $this->application = $application; $this->namespace = $namespace; $this->showHidden = $showHidden; } /** * @return array */ public function getNamespaces() { if (null === $this->namespaces) { $this->inspectApplication(); } return $this->namespaces; } /** * @return Command[] */ public function getCommands() { if (null === $this->commands) { $this->inspectApplication(); } return $this->commands; } /** * @param string $name * * @return Command * * @throws CommandNotFoundException */ public function getCommand($name) { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); } return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; } private function inspectApplication() { $this->commands = array(); $this->namespaces = array(); $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); foreach ($this->sortCommands($all) as $namespace => $commands) { $names = array(); /** @var Command $command */ foreach ($commands as $name => $command) { if (!$command->getName() || (!$this->showHidden && $command->isHidden())) { continue; } if ($command->getName() === $name) { $this->commands[$name] = $command; } else { $this->aliases[$name] = $command; } $names[] = $name; } $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names); } } /** * @return array */ private function sortCommands(array $commands) { $namespacedCommands = array(); $globalCommands = array(); foreach ($commands as $name => $command) { $key = $this->application->extractNamespace($name, 1); if (!$key) { $globalCommands['_global'][$name] = $command; } else { $namespacedCommands[$key][$name] = $command; } } ksort($namespacedCommands); $namespacedCommands = array_merge($globalCommands, $namespacedCommands); foreach ($namespacedCommands as &$commandsSet) { ksort($commandsSet); } // unset reference to keep scope clear unset($commandsSet); return $namespacedCommands; } } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/Descriptor.php000066400000000000000000000062011324732107100257730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * @author Jean-François Simon * * @internal */ abstract class Descriptor implements DescriptorInterface { /** * @var OutputInterface */ protected $output; /** * {@inheritdoc} */ public function describe(OutputInterface $output, $object, array $options = array()) { $this->output = $output; switch (true) { case $object instanceof InputArgument: $this->describeInputArgument($object, $options); break; case $object instanceof InputOption: $this->describeInputOption($object, $options); break; case $object instanceof InputDefinition: $this->describeInputDefinition($object, $options); break; case $object instanceof Command: $this->describeCommand($object, $options); break; case $object instanceof Application: $this->describeApplication($object, $options); break; default: throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); } } /** * Writes content to output. * * @param string $content * @param bool $decorated */ protected function write($content, $decorated = false) { $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); } /** * Describes an InputArgument instance. * * @return string|mixed */ abstract protected function describeInputArgument(InputArgument $argument, array $options = array()); /** * Describes an InputOption instance. * * @return string|mixed */ abstract protected function describeInputOption(InputOption $option, array $options = array()); /** * Describes an InputDefinition instance. * * @return string|mixed */ abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array()); /** * Describes a Command instance. * * @return string|mixed */ abstract protected function describeCommand(Command $command, array $options = array()); /** * Describes an Application instance. * * @return string|mixed */ abstract protected function describeApplication(Application $application, array $options = array()); } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php000066400000000000000000000013411324732107100276140ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Output\OutputInterface; /** * Descriptor interface. * * @author Jean-François Simon */ interface DescriptorInterface { /** * Describes an InputArgument instance. * * @param OutputInterface $output * @param object $object * @param array $options */ public function describe(OutputInterface $output, $object, array $options = array()); } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php000066400000000000000000000121441324732107100266300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; /** * JSON descriptor. * * @author Jean-François Simon * * @internal */ class JsonDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeInputArgument(InputArgument $argument, array $options = array()) { $this->writeData($this->getInputArgumentData($argument), $options); } /** * {@inheritdoc} */ protected function describeInputOption(InputOption $option, array $options = array()) { $this->writeData($this->getInputOptionData($option), $options); } /** * {@inheritdoc} */ protected function describeInputDefinition(InputDefinition $definition, array $options = array()) { $this->writeData($this->getInputDefinitionData($definition), $options); } /** * {@inheritdoc} */ protected function describeCommand(Command $command, array $options = array()) { $this->writeData($this->getCommandData($command), $options); } /** * {@inheritdoc} */ protected function describeApplication(Application $application, array $options = array()) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace, true); $commands = array(); foreach ($description->getCommands() as $command) { $commands[] = $this->getCommandData($command); } $data = array(); if ('UNKNOWN' !== $application->getName()) { $data['application']['name'] = $application->getName(); if ('UNKNOWN' !== $application->getVersion()) { $data['application']['version'] = $application->getVersion(); } } $data['commands'] = $commands; if ($describedNamespace) { $data['namespace'] = $describedNamespace; } else { $data['namespaces'] = array_values($description->getNamespaces()); } $this->writeData($data, $options); } /** * Writes data as json. * * @return array|string */ private function writeData(array $data, array $options) { $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0)); } /** * @return array */ private function getInputArgumentData(InputArgument $argument) { return array( 'name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), ); } /** * @return array */ private function getInputOptionData(InputOption $option) { return array( 'name' => '--'.$option->getName(), 'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '', 'accept_value' => $option->acceptValue(), 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), ); } /** * @return array */ private function getInputDefinitionData(InputDefinition $definition) { $inputArguments = array(); foreach ($definition->getArguments() as $name => $argument) { $inputArguments[$name] = $this->getInputArgumentData($argument); } $inputOptions = array(); foreach ($definition->getOptions() as $name => $option) { $inputOptions[$name] = $this->getInputOptionData($option); } return array('arguments' => $inputArguments, 'options' => $inputOptions); } /** * @return array */ private function getCommandData(Command $command) { $command->getSynopsis(); $command->mergeApplicationDefinition(false); return array( 'name' => $command->getName(), 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), 'hidden' => $command->isHidden(), ); } } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php000066400000000000000000000137431324732107100275070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** * Markdown descriptor. * * @author Jean-François Simon * * @internal */ class MarkdownDescriptor extends Descriptor { /** * {@inheritdoc} */ public function describe(OutputInterface $output, $object, array $options = array()) { $decorated = $output->isDecorated(); $output->setDecorated(false); parent::describe($output, $object, $options); $output->setDecorated($decorated); } /** * {@inheritdoc} */ protected function write($content, $decorated = true) { parent::write($content, $decorated); } /** * {@inheritdoc} */ protected function describeInputArgument(InputArgument $argument, array $options = array()) { $this->write( '#### `'.($argument->getName() ?: '')."`\n\n" .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '') .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`' ); } /** * {@inheritdoc} */ protected function describeInputOption(InputOption $option, array $options = array()) { $name = '--'.$option->getName(); if ($option->getShortcut()) { $name .= '|-'.implode('|-', explode('|', $option->getShortcut())).''; } $this->write( '#### `'.$name.'`'."\n\n" .($option->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $option->getDescription())."\n\n" : '') .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' ); } /** * {@inheritdoc} */ protected function describeInputDefinition(InputDefinition $definition, array $options = array()) { if ($showArguments = count($definition->getArguments()) > 0) { $this->write('### Arguments'); foreach ($definition->getArguments() as $argument) { $this->write("\n\n"); $this->write($this->describeInputArgument($argument)); } } if (count($definition->getOptions()) > 0) { if ($showArguments) { $this->write("\n\n"); } $this->write('### Options'); foreach ($definition->getOptions() as $option) { $this->write("\n\n"); $this->write($this->describeInputOption($option)); } } } /** * {@inheritdoc} */ protected function describeCommand(Command $command, array $options = array()) { $command->getSynopsis(); $command->mergeApplicationDefinition(false); $this->write( '`'.$command->getName()."`\n" .str_repeat('-', Helper::strlen($command->getName()) + 2)."\n\n" .($command->getDescription() ? $command->getDescription()."\n\n" : '') .'### Usage'."\n\n" .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) { return $carry.'* `'.$usage.'`'."\n"; }) ); if ($help = $command->getProcessedHelp()) { $this->write("\n"); $this->write($help); } if ($command->getNativeDefinition()) { $this->write("\n\n"); $this->describeInputDefinition($command->getNativeDefinition()); } } /** * {@inheritdoc} */ protected function describeApplication(Application $application, array $options = array()) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace); $title = $this->getApplicationTitle($application); $this->write($title."\n".str_repeat('=', Helper::strlen($title))); foreach ($description->getNamespaces() as $namespace) { if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { $this->write("\n\n"); $this->write('**'.$namespace['id'].':**'); } $this->write("\n\n"); $this->write(implode("\n", array_map(function ($commandName) use ($description) { return sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName())); }, $namespace['commands']))); } foreach ($description->getCommands() as $command) { $this->write("\n\n"); $this->write($this->describeCommand($command)); } } private function getApplicationTitle(Application $application) { if ('UNKNOWN' !== $application->getName()) { if ('UNKNOWN' !== $application->getVersion()) { return sprintf('%s %s', $application->getName(), $application->getVersion()); } return $application->getName(); } return 'Console Tool'; } } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/TextDescriptor.php000066400000000000000000000302141324732107100266410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; /** * Text descriptor. * * @author Jean-François Simon * * @internal */ class TextDescriptor extends Descriptor { /** * {@inheritdoc} */ protected function describeInputArgument(InputArgument $argument, array $options = array()) { if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { $default = sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault())); } else { $default = ''; } $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName()); $spacingWidth = $totalWidth - strlen($argument->getName()); $this->writeText(sprintf(' %s %s%s%s', $argument->getName(), str_repeat(' ', $spacingWidth), // + 4 = 2 spaces before , 2 spaces after preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()), $default ), $options); } /** * {@inheritdoc} */ protected function describeInputOption(InputOption $option, array $options = array()) { if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { $default = sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault())); } else { $default = ''; } $value = ''; if ($option->acceptValue()) { $value = '='.strtoupper($option->getName()); if ($option->isValueOptional()) { $value = '['.$value.']'; } } $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option)); $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value) ); $spacingWidth = $totalWidth - Helper::strlen($synopsis); $this->writeText(sprintf(' %s %s%s%s%s', $synopsis, str_repeat(' ', $spacingWidth), // + 4 = 2 spaces before , 2 spaces after preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : '' ), $options); } /** * {@inheritdoc} */ protected function describeInputDefinition(InputDefinition $definition, array $options = array()) { $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); foreach ($definition->getArguments() as $argument) { $totalWidth = max($totalWidth, Helper::strlen($argument->getName())); } if ($definition->getArguments()) { $this->writeText('Arguments:', $options); $this->writeText("\n"); foreach ($definition->getArguments() as $argument) { $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth))); $this->writeText("\n"); } } if ($definition->getArguments() && $definition->getOptions()) { $this->writeText("\n"); } if ($definition->getOptions()) { $laterOptions = array(); $this->writeText('Options:', $options); foreach ($definition->getOptions() as $option) { if (strlen($option->getShortcut()) > 1) { $laterOptions[] = $option; continue; } $this->writeText("\n"); $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth))); } foreach ($laterOptions as $option) { $this->writeText("\n"); $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth))); } } } /** * {@inheritdoc} */ protected function describeCommand(Command $command, array $options = array()) { $command->getSynopsis(true); $command->getSynopsis(false); $command->mergeApplicationDefinition(false); $this->writeText('Usage:', $options); foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) { $this->writeText("\n"); $this->writeText(' '.OutputFormatter::escape($usage), $options); } $this->writeText("\n"); $definition = $command->getNativeDefinition(); if ($definition->getOptions() || $definition->getArguments()) { $this->writeText("\n"); $this->describeInputDefinition($definition, $options); $this->writeText("\n"); } if ($help = $command->getProcessedHelp()) { $this->writeText("\n"); $this->writeText('Help:', $options); $this->writeText("\n"); $this->writeText(' '.str_replace("\n", "\n ", $help), $options); $this->writeText("\n"); } } /** * {@inheritdoc} */ protected function describeApplication(Application $application, array $options = array()) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace); if (isset($options['raw_text']) && $options['raw_text']) { $width = $this->getColumnWidth($description->getCommands()); foreach ($description->getCommands() as $command) { $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options); $this->writeText("\n"); } } else { if ('' != $help = $application->getHelp()) { $this->writeText("$help\n\n", $options); } $this->writeText("Usage:\n", $options); $this->writeText(" command [options] [arguments]\n\n", $options); $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options); $this->writeText("\n"); $this->writeText("\n"); $commands = $description->getCommands(); $namespaces = $description->getNamespaces(); if ($describedNamespace && $namespaces) { // make sure all alias commands are included when describing a specific namespace $describedNamespaceInfo = reset($namespaces); foreach ($describedNamespaceInfo['commands'] as $name) { $commands[$name] = $description->getCommand($name); } } // calculate max. width based on available commands per namespace $width = $this->getColumnWidth(call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) { return array_intersect($namespace['commands'], array_keys($commands)); }, $namespaces))); if ($describedNamespace) { $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); } else { $this->writeText('Available commands:', $options); } foreach ($namespaces as $namespace) { $namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) { return isset($commands[$name]); }); if (!$namespace['commands']) { continue; } if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { $this->writeText("\n"); $this->writeText(' '.$namespace['id'].'', $options); } foreach ($namespace['commands'] as $name) { $this->writeText("\n"); $spacingWidth = $width - Helper::strlen($name); $command = $commands[$name]; $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : ''; $this->writeText(sprintf(' %s%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options); } } $this->writeText("\n"); } } /** * {@inheritdoc} */ private function writeText($content, array $options = array()) { $this->write( isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true ); } /** * Formats command aliases to show them in the command description. * * @return string */ private function getCommandAliasesText(Command $command) { $text = ''; $aliases = $command->getAliases(); if ($aliases) { $text = '['.implode('|', $aliases).'] '; } return $text; } /** * Formats input option/argument default value. * * @param mixed $default * * @return string */ private function formatDefaultValue($default) { if (INF === $default) { return 'INF'; } if (is_string($default)) { $default = OutputFormatter::escape($default); } elseif (is_array($default)) { foreach ($default as $key => $value) { if (is_string($value)) { $default[$key] = OutputFormatter::escape($value); } } } return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } /** * @param (Command|string)[] $commands * * @return int */ private function getColumnWidth(array $commands) { $widths = array(); foreach ($commands as $command) { if ($command instanceof Command) { $widths[] = Helper::strlen($command->getName()); foreach ($command->getAliases() as $alias) { $widths[] = Helper::strlen($alias); } } else { $widths[] = Helper::strlen($command); } } return $widths ? max($widths) + 2 : 0; } /** * @param InputOption[] $options * * @return int */ private function calculateTotalWidthForOptions(array $options) { $totalWidth = 0; foreach ($options as $option) { // "-" + shortcut + ", --" + name $nameLength = 1 + max(Helper::strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName()); if ($option->acceptValue()) { $valueLength = 1 + Helper::strlen($option->getName()); // = + value $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] $nameLength += $valueLength; } $totalWidth = max($totalWidth, $nameLength); } return $totalWidth; } } symfony-3.4.6/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php000066400000000000000000000221771324732107100264660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Descriptor; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; /** * XML descriptor. * * @author Jean-François Simon * * @internal */ class XmlDescriptor extends Descriptor { /** * @return \DOMDocument */ public function getInputDefinitionDocument(InputDefinition $definition) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($definitionXML = $dom->createElement('definition')); $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); foreach ($definition->getArguments() as $argument) { $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument)); } $definitionXML->appendChild($optionsXML = $dom->createElement('options')); foreach ($definition->getOptions() as $option) { $this->appendDocument($optionsXML, $this->getInputOptionDocument($option)); } return $dom; } /** * @return \DOMDocument */ public function getCommandDocument(Command $command) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($commandXML = $dom->createElement('command')); $command->getSynopsis(); $command->mergeApplicationDefinition(false); $commandXML->setAttribute('id', $command->getName()); $commandXML->setAttribute('name', $command->getName()); $commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0); $commandXML->appendChild($usagesXML = $dom->createElement('usages')); foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) { $usagesXML->appendChild($dom->createElement('usage', $usage)); } $commandXML->appendChild($descriptionXML = $dom->createElement('description')); $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription()))); $commandXML->appendChild($helpXML = $dom->createElement('help')); $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp()))); $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition()); $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0)); return $dom; } /** * @param Application $application * @param string|null $namespace * * @return \DOMDocument */ public function getApplicationDocument(Application $application, $namespace = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($rootXml = $dom->createElement('symfony')); if ('UNKNOWN' !== $application->getName()) { $rootXml->setAttribute('name', $application->getName()); if ('UNKNOWN' !== $application->getVersion()) { $rootXml->setAttribute('version', $application->getVersion()); } } $rootXml->appendChild($commandsXML = $dom->createElement('commands')); $description = new ApplicationDescription($application, $namespace, true); if ($namespace) { $commandsXML->setAttribute('namespace', $namespace); } foreach ($description->getCommands() as $command) { $this->appendDocument($commandsXML, $this->getCommandDocument($command)); } if (!$namespace) { $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces')); foreach ($description->getNamespaces() as $namespaceDescription) { $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace')); $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']); foreach ($namespaceDescription['commands'] as $name) { $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command')); $commandXML->appendChild($dom->createTextNode($name)); } } } return $dom; } /** * {@inheritdoc} */ protected function describeInputArgument(InputArgument $argument, array $options = array()) { $this->writeDocument($this->getInputArgumentDocument($argument)); } /** * {@inheritdoc} */ protected function describeInputOption(InputOption $option, array $options = array()) { $this->writeDocument($this->getInputOptionDocument($option)); } /** * {@inheritdoc} */ protected function describeInputDefinition(InputDefinition $definition, array $options = array()) { $this->writeDocument($this->getInputDefinitionDocument($definition)); } /** * {@inheritdoc} */ protected function describeCommand(Command $command, array $options = array()) { $this->writeDocument($this->getCommandDocument($command)); } /** * {@inheritdoc} */ protected function describeApplication(Application $application, array $options = array()) { $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null)); } /** * Appends document children to parent node. */ private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent) { foreach ($importedParent->childNodes as $childNode) { $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true)); } } /** * Writes DOM document. * * @return \DOMDocument|string */ private function writeDocument(\DOMDocument $dom) { $dom->formatOutput = true; $this->write($dom->saveXML()); } /** * @return \DOMDocument */ private function getInputArgumentDocument(InputArgument $argument) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($objectXML = $dom->createElement('argument')); $objectXML->setAttribute('name', $argument->getName()); $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); $objectXML->appendChild($descriptionXML = $dom->createElement('description')); $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); foreach ($defaults as $default) { $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); $defaultXML->appendChild($dom->createTextNode($default)); } return $dom; } /** * @return \DOMDocument */ private function getInputOptionDocument(InputOption $option) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($objectXML = $dom->createElement('option')); $objectXML->setAttribute('name', '--'.$option->getName()); $pos = strpos($option->getShortcut(), '|'); if (false !== $pos) { $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos)); $objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut()))); } else { $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); } $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); $objectXML->appendChild($descriptionXML = $dom->createElement('description')); $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); if ($option->acceptValue()) { $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); if (!empty($defaults)) { foreach ($defaults as $default) { $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); $defaultXML->appendChild($dom->createTextNode($default)); } } } return $dom; } } symfony-3.4.6/src/Symfony/Component/Console/Event/000077500000000000000000000000001324732107100221105ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php000066400000000000000000000024451324732107100265310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; /** * Allows to do things before the command is executed, like skipping the command or changing the input. * * @author Fabien Potencier */ class ConsoleCommandEvent extends ConsoleEvent { /** * The return code for skipped commands, this will also be passed into the terminate event. */ const RETURN_CODE_DISABLED = 113; /** * Indicates if the command should be run or skipped. */ private $commandShouldRun = true; /** * Disables the command, so it won't be run. * * @return bool */ public function disableCommand() { return $this->commandShouldRun = false; } /** * Enables the command. * * @return bool */ public function enableCommand() { return $this->commandShouldRun = true; } /** * Returns true if the command is runnable, false otherwise. * * @return bool */ public function commandShouldRun() { return $this->commandShouldRun; } } symfony-3.4.6/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php000066400000000000000000000043011324732107100262350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Allows to handle throwables thrown while running a command. * * @author Wouter de Jong */ final class ConsoleErrorEvent extends ConsoleEvent { private $error; private $exitCode; public function __construct(InputInterface $input, OutputInterface $output, $error, Command $command = null) { parent::__construct($command, $input, $output); $this->setError($error); } /** * Returns the thrown error/exception. * * @return \Throwable */ public function getError() { return $this->error; } /** * Replaces the thrown error/exception. * * @param \Throwable $error */ public function setError($error) { if (!$error instanceof \Throwable && !$error instanceof \Exception) { throw new InvalidArgumentException(sprintf('The error passed to ConsoleErrorEvent must be an instance of \Throwable or \Exception, "%s" was passed instead.', is_object($error) ? get_class($error) : gettype($error))); } $this->error = $error; } /** * Sets the exit code. * * @param int $exitCode The command exit code */ public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); } /** * Gets the exit code. * * @return int The command exit code */ public function getExitCode() { return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1); } } symfony-3.4.6/src/Symfony/Component/Console/Event/ConsoleEvent.php000066400000000000000000000027041324732107100252300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\Event; /** * Allows to inspect input and output of a command. * * @author Francesco Levorato */ class ConsoleEvent extends Event { protected $command; private $input; private $output; public function __construct(Command $command = null, InputInterface $input, OutputInterface $output) { $this->command = $command; $this->input = $input; $this->output = $output; } /** * Gets the command that is executed. * * @return Command|null A Command instance */ public function getCommand() { return $this->command; } /** * Gets the input instance. * * @return InputInterface An InputInterface instance */ public function getInput() { return $this->input; } /** * Gets the output instance. * * @return OutputInterface An OutputInterface instance */ public function getOutput() { return $this->output; } } symfony-3.4.6/src/Symfony/Component/Console/Event/ConsoleExceptionEvent.php000066400000000000000000000035231324732107100271070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; @trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED); use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Allows to handle exception thrown in a command. * * @author Fabien Potencier * * @deprecated since version 3.3, to be removed in 4.0. Use ConsoleErrorEvent instead. */ class ConsoleExceptionEvent extends ConsoleEvent { private $exception; private $exitCode; public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode) { parent::__construct($command, $input, $output); $this->setException($exception); $this->exitCode = (int) $exitCode; } /** * Returns the thrown exception. * * @return \Exception The thrown exception */ public function getException() { return $this->exception; } /** * Replaces the thrown exception. * * This exception will be thrown if no response is set in the event. * * @param \Exception $exception The thrown exception */ public function setException(\Exception $exception) { $this->exception = $exception; } /** * Gets the exit code. * * @return int The command exit code */ public function getExitCode() { return $this->exitCode; } } symfony-3.4.6/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php000066400000000000000000000024321324732107100270770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Event; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Allows to manipulate the exit code of a command after its execution. * * @author Francesco Levorato */ class ConsoleTerminateEvent extends ConsoleEvent { /** * The exit code of the command. * * @var int */ private $exitCode; public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode) { parent::__construct($command, $input, $output); $this->setExitCode($exitCode); } /** * Sets the exit code. * * @param int $exitCode The command exit code */ public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; } /** * Gets the exit code. * * @return int The command exit code */ public function getExitCode() { return $this->exitCode; } } symfony-3.4.6/src/Symfony/Component/Console/EventListener/000077500000000000000000000000001324732107100236165ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/EventListener/ErrorListener.php000066400000000000000000000053701324732107100271330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\EventListener; use Psr\Log\LoggerInterface; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * @author James Halsall * @author Robin Chalas */ class ErrorListener implements EventSubscriberInterface { private $logger; public function __construct(LoggerInterface $logger = null) { $this->logger = $logger; } public function onConsoleError(ConsoleErrorEvent $event) { if (null === $this->logger) { return; } $error = $event->getError(); if (!$inputString = $this->getInputString($event)) { return $this->logger->error('An error occurred while using the console. Message: "{message}"', array('error' => $error, 'message' => $error->getMessage())); } $this->logger->error('Error thrown while running command "{command}". Message: "{message}"', array('error' => $error, 'command' => $inputString, 'message' => $error->getMessage())); } public function onConsoleTerminate(ConsoleTerminateEvent $event) { if (null === $this->logger) { return; } $exitCode = $event->getExitCode(); if (0 === $exitCode) { return; } if (!$inputString = $this->getInputString($event)) { return $this->logger->debug('The console exited with code "{code}"', array('code' => $exitCode)); } $this->logger->debug('Command "{command}" exited with code "{code}"', array('command' => $inputString, 'code' => $exitCode)); } public static function getSubscribedEvents() { return array( ConsoleEvents::ERROR => array('onConsoleError', -128), ConsoleEvents::TERMINATE => array('onConsoleTerminate', -128), ); } private static function getInputString(ConsoleEvent $event) { $commandName = $event->getCommand() ? $event->getCommand()->getName() : null; $input = $event->getInput(); if (method_exists($input, '__toString')) { if ($commandName) { return str_replace(array("'$commandName'", "\"$commandName\""), $commandName, (string) $input); } return (string) $input; } return $commandName; } } symfony-3.4.6/src/Symfony/Component/Console/Exception/000077500000000000000000000000001324732107100227655ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Exception/CommandNotFoundException.php000066400000000000000000000023021324732107100304050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * Represents an incorrect command name typed in the console. * * @author Jérôme Tamarelle */ class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface { private $alternatives; /** * @param string $message Exception message to throw * @param array $alternatives List of similar defined names * @param int $code Exception code * @param \Exception $previous Previous exception used for the exception chaining */ public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); $this->alternatives = $alternatives; } /** * @return array A list of similar defined names */ public function getAlternatives() { return $this->alternatives; } } symfony-3.4.6/src/Symfony/Component/Console/Exception/ExceptionInterface.php000066400000000000000000000006261324732107100272610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * ExceptionInterface. * * @author Jérôme Tamarelle */ interface ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Console/Exception/InvalidArgumentException.php000066400000000000000000000006761324732107100304570ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Console/Exception/InvalidOptionException.php000066400000000000000000000007741324732107100301440ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * Represents an incorrect option name typed in the console. * * @author Jérôme Tamarelle */ class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Console/Exception/LogicException.php000066400000000000000000000006521324732107100264150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ class LogicException extends \LogicException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Console/Exception/RuntimeException.php000066400000000000000000000006561324732107100270070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ class RuntimeException extends \RuntimeException implements ExceptionInterface { } symfony-3.4.6/src/Symfony/Component/Console/Formatter/000077500000000000000000000000001324732107100227725ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Formatter/OutputFormatter.php000066400000000000000000000151371324732107100266760ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Formatter; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * Formatter class for console output. * * @author Konstantin Kudryashov */ class OutputFormatter implements OutputFormatterInterface { private $decorated; private $styles = array(); private $styleStack; /** * Escapes "<" special char in given text. * * @param string $text Text to escape * * @return string Escaped text */ public static function escape($text) { $text = preg_replace('/([^\\\\]?) FormatterStyle" instances */ public function __construct($decorated = false, array $styles = array()) { $this->decorated = (bool) $decorated; $this->setStyle('error', new OutputFormatterStyle('white', 'red')); $this->setStyle('info', new OutputFormatterStyle('green')); $this->setStyle('comment', new OutputFormatterStyle('yellow')); $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); foreach ($styles as $name => $style) { $this->setStyle($name, $style); } $this->styleStack = new OutputFormatterStyleStack(); } /** * {@inheritdoc} */ public function setDecorated($decorated) { $this->decorated = (bool) $decorated; } /** * {@inheritdoc} */ public function isDecorated() { return $this->decorated; } /** * {@inheritdoc} */ public function setStyle($name, OutputFormatterStyleInterface $style) { $this->styles[strtolower($name)] = $style; } /** * {@inheritdoc} */ public function hasStyle($name) { return isset($this->styles[strtolower($name)]); } /** * {@inheritdoc} */ public function getStyle($name) { if (!$this->hasStyle($name)) { throw new InvalidArgumentException(sprintf('Undefined style: %s', $name)); } return $this->styles[strtolower($name)]; } /** * {@inheritdoc} */ public function format($message) { $message = (string) $message; $offset = 0; $output = ''; $tagRegex = '[a-z][a-z0-9,_=;-]*+'; preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { $pos = $match[1]; $text = $match[0]; if (0 != $pos && '\\' == $message[$pos - 1]) { continue; } // add the text up to the next tag $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset)); $offset = $pos + strlen($text); // opening tag? if ($open = '/' != $text[1]) { $tag = $matches[1][$i][0]; } else { $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : ''; } if (!$open && !$tag) { // $this->styleStack->pop(); } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) { $output .= $this->applyCurrentStyle($text); } elseif ($open) { $this->styleStack->push($style); } else { $this->styleStack->pop($style); } } $output .= $this->applyCurrentStyle(substr($message, $offset)); if (false !== strpos($output, "\0")) { return strtr($output, array("\0" => '\\', '\\<' => '<')); } return str_replace('\\<', '<', $output); } /** * @return OutputFormatterStyleStack */ public function getStyleStack() { return $this->styleStack; } /** * Tries to create new style instance from string. * * @param string $string * * @return OutputFormatterStyle|false false if string is not format string */ private function createStyleFromString($string) { if (isset($this->styles[$string])) { return $this->styles[$string]; } if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { return false; } $style = new OutputFormatterStyle(); foreach ($matches as $match) { array_shift($match); if ('fg' == $match[0]) { $style->setForeground($match[1]); } elseif ('bg' == $match[0]) { $style->setBackground($match[1]); } elseif ('options' === $match[0]) { preg_match_all('([^,;]+)', $match[1], $options); $options = array_shift($options); foreach ($options as $option) { try { $style->setOption($option); } catch (\InvalidArgumentException $e) { @trigger_error(sprintf('Unknown style options are deprecated since Symfony 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED); return false; } } } else { return false; } } return $style; } /** * Applies current style from stack to text, if must be applied. * * @param string $text Input text * * @return string Styled text */ private function applyCurrentStyle($text) { return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; } } symfony-3.4.6/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php000066400000000000000000000032461324732107100305150ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Formatter; /** * Formatter interface for console output. * * @author Konstantin Kudryashov */ interface OutputFormatterInterface { /** * Sets the decorated flag. * * @param bool $decorated Whether to decorate the messages or not */ public function setDecorated($decorated); /** * Gets the decorated flag. * * @return bool true if the output will decorate messages, false otherwise */ public function isDecorated(); /** * Sets a new style. * * @param string $name The style name * @param OutputFormatterStyleInterface $style The style instance */ public function setStyle($name, OutputFormatterStyleInterface $style); /** * Checks if output formatter has style with specified name. * * @param string $name * * @return bool */ public function hasStyle($name); /** * Gets style options from style with specified name. * * @param string $name * * @return OutputFormatterStyleInterface * * @throws \InvalidArgumentException When style isn't defined */ public function getStyle($name); /** * Formats a message according to the given styles. * * @param string $message The message to style * * @return string The styled message */ public function format($message); } symfony-3.4.6/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php000066400000000000000000000152051324732107100277130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Formatter; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * Formatter style class for defining styles. * * @author Konstantin Kudryashov */ class OutputFormatterStyle implements OutputFormatterStyleInterface { private static $availableForegroundColors = array( 'black' => array('set' => 30, 'unset' => 39), 'red' => array('set' => 31, 'unset' => 39), 'green' => array('set' => 32, 'unset' => 39), 'yellow' => array('set' => 33, 'unset' => 39), 'blue' => array('set' => 34, 'unset' => 39), 'magenta' => array('set' => 35, 'unset' => 39), 'cyan' => array('set' => 36, 'unset' => 39), 'white' => array('set' => 37, 'unset' => 39), 'default' => array('set' => 39, 'unset' => 39), ); private static $availableBackgroundColors = array( 'black' => array('set' => 40, 'unset' => 49), 'red' => array('set' => 41, 'unset' => 49), 'green' => array('set' => 42, 'unset' => 49), 'yellow' => array('set' => 43, 'unset' => 49), 'blue' => array('set' => 44, 'unset' => 49), 'magenta' => array('set' => 45, 'unset' => 49), 'cyan' => array('set' => 46, 'unset' => 49), 'white' => array('set' => 47, 'unset' => 49), 'default' => array('set' => 49, 'unset' => 49), ); private static $availableOptions = array( 'bold' => array('set' => 1, 'unset' => 22), 'underscore' => array('set' => 4, 'unset' => 24), 'blink' => array('set' => 5, 'unset' => 25), 'reverse' => array('set' => 7, 'unset' => 27), 'conceal' => array('set' => 8, 'unset' => 28), ); private $foreground; private $background; private $options = array(); /** * Initializes output formatter style. * * @param string|null $foreground The style foreground color name * @param string|null $background The style background color name * @param array $options The style options */ public function __construct($foreground = null, $background = null, array $options = array()) { if (null !== $foreground) { $this->setForeground($foreground); } if (null !== $background) { $this->setBackground($background); } if (count($options)) { $this->setOptions($options); } } /** * Sets style foreground color. * * @param string|null $color The color name * * @throws InvalidArgumentException When the color name isn't defined */ public function setForeground($color = null) { if (null === $color) { $this->foreground = null; return; } if (!isset(static::$availableForegroundColors[$color])) { throw new InvalidArgumentException(sprintf( 'Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors)) )); } $this->foreground = static::$availableForegroundColors[$color]; } /** * Sets style background color. * * @param string|null $color The color name * * @throws InvalidArgumentException When the color name isn't defined */ public function setBackground($color = null) { if (null === $color) { $this->background = null; return; } if (!isset(static::$availableBackgroundColors[$color])) { throw new InvalidArgumentException(sprintf( 'Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors)) )); } $this->background = static::$availableBackgroundColors[$color]; } /** * Sets some specific style option. * * @param string $option The option name * * @throws InvalidArgumentException When the option name isn't defined */ public function setOption($option) { if (!isset(static::$availableOptions[$option])) { throw new InvalidArgumentException(sprintf( 'Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)) )); } if (!in_array(static::$availableOptions[$option], $this->options)) { $this->options[] = static::$availableOptions[$option]; } } /** * Unsets some specific style option. * * @param string $option The option name * * @throws InvalidArgumentException When the option name isn't defined */ public function unsetOption($option) { if (!isset(static::$availableOptions[$option])) { throw new InvalidArgumentException(sprintf( 'Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)) )); } $pos = array_search(static::$availableOptions[$option], $this->options); if (false !== $pos) { unset($this->options[$pos]); } } /** * {@inheritdoc} */ public function setOptions(array $options) { $this->options = array(); foreach ($options as $option) { $this->setOption($option); } } /** * Applies the style to a given text. * * @param string $text The text to style * * @return string */ public function apply($text) { $setCodes = array(); $unsetCodes = array(); if (null !== $this->foreground) { $setCodes[] = $this->foreground['set']; $unsetCodes[] = $this->foreground['unset']; } if (null !== $this->background) { $setCodes[] = $this->background['set']; $unsetCodes[] = $this->background['unset']; } if (count($this->options)) { foreach ($this->options as $option) { $setCodes[] = $option['set']; $unsetCodes[] = $option['unset']; } } if (0 === count($setCodes)) { return $text; } return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes)); } } symfony-3.4.6/src/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php000066400000000000000000000024671324732107100315420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Formatter; /** * Formatter style interface for defining styles. * * @author Konstantin Kudryashov */ interface OutputFormatterStyleInterface { /** * Sets style foreground color. * * @param string $color The color name */ public function setForeground($color = null); /** * Sets style background color. * * @param string $color The color name */ public function setBackground($color = null); /** * Sets some specific style option. * * @param string $option The option name */ public function setOption($option); /** * Unsets some specific style option. * * @param string $option The option name */ public function unsetOption($option); /** * Sets multiple style options at once. */ public function setOptions(array $options); /** * Applies the style to a given text. * * @param string $text The text to style * * @return string */ public function apply($text); } symfony-3.4.6/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php000066400000000000000000000046701324732107100307050ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Formatter; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * @author Jean-François Simon */ class OutputFormatterStyleStack { /** * @var OutputFormatterStyleInterface[] */ private $styles; private $emptyStyle; public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle(); $this->reset(); } /** * Resets stack (ie. empty internal arrays). */ public function reset() { $this->styles = array(); } /** * Pushes a style in the stack. */ public function push(OutputFormatterStyleInterface $style) { $this->styles[] = $style; } /** * Pops a style from the stack. * * @return OutputFormatterStyleInterface * * @throws InvalidArgumentException When style tags incorrectly nested */ public function pop(OutputFormatterStyleInterface $style = null) { if (empty($this->styles)) { return $this->emptyStyle; } if (null === $style) { return array_pop($this->styles); } foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { if ($style->apply('') === $stackedStyle->apply('')) { $this->styles = array_slice($this->styles, 0, $index); return $stackedStyle; } } throw new InvalidArgumentException('Incorrectly nested style tag found.'); } /** * Computes current style with stacks top codes. * * @return OutputFormatterStyle */ public function getCurrent() { if (empty($this->styles)) { return $this->emptyStyle; } return $this->styles[count($this->styles) - 1]; } /** * @return $this */ public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) { $this->emptyStyle = $emptyStyle; return $this; } /** * @return OutputFormatterStyleInterface */ public function getEmptyStyle() { return $this->emptyStyle; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/000077500000000000000000000000001324732107100222465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php000066400000000000000000000101261324732107100270310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; /** * Helps outputting debug information when running an external program from a command. * * An external program can be a Process, an HTTP request, or anything else. * * @author Fabien Potencier */ class DebugFormatterHelper extends Helper { private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'); private $started = array(); private $count = -1; /** * Starts a debug formatting session. * * @param string $id The id of the formatting session * @param string $message The message to display * @param string $prefix The prefix to use * * @return string */ public function start($id, $message, $prefix = 'RUN') { $this->started[$id] = array('border' => ++$this->count % count($this->colors)); return sprintf("%s %s %s\n", $this->getBorder($id), $prefix, $message); } /** * Adds progress to a formatting session. * * @param string $id The id of the formatting session * @param string $buffer The message to display * @param bool $error Whether to consider the buffer as error * @param string $prefix The prefix for output * @param string $errorPrefix The prefix for error output * * @return string */ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR') { $message = ''; if ($error) { if (isset($this->started[$id]['out'])) { $message .= "\n"; unset($this->started[$id]['out']); } if (!isset($this->started[$id]['err'])) { $message .= sprintf('%s %s ', $this->getBorder($id), $errorPrefix); $this->started[$id]['err'] = true; } $message .= str_replace("\n", sprintf("\n%s %s ", $this->getBorder($id), $errorPrefix), $buffer); } else { if (isset($this->started[$id]['err'])) { $message .= "\n"; unset($this->started[$id]['err']); } if (!isset($this->started[$id]['out'])) { $message .= sprintf('%s %s ', $this->getBorder($id), $prefix); $this->started[$id]['out'] = true; } $message .= str_replace("\n", sprintf("\n%s %s ", $this->getBorder($id), $prefix), $buffer); } return $message; } /** * Stops a formatting session. * * @param string $id The id of the formatting session * @param string $message The message to display * @param bool $successful Whether to consider the result as success * @param string $prefix The prefix for the end output * * @return string */ public function stop($id, $message, $successful, $prefix = 'RES') { $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : ''; if ($successful) { return sprintf("%s%s %s %s\n", $trailingEOL, $this->getBorder($id), $prefix, $message); } $message = sprintf("%s%s %s %s\n", $trailingEOL, $this->getBorder($id), $prefix, $message); unset($this->started[$id]['out'], $this->started[$id]['err']); return $message; } /** * @param string $id The id of the formatting session * * @return string */ private function getBorder($id) { return sprintf(' ', $this->colors[$this->started[$id]['border']]); } /** * {@inheritdoc} */ public function getName() { return 'debug_formatter'; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/DescriptorHelper.php000066400000000000000000000050611324732107100262370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Descriptor\DescriptorInterface; use Symfony\Component\Console\Descriptor\JsonDescriptor; use Symfony\Component\Console\Descriptor\MarkdownDescriptor; use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * This class adds helper method to describe objects in various formats. * * @author Jean-François Simon */ class DescriptorHelper extends Helper { /** * @var DescriptorInterface[] */ private $descriptors = array(); public function __construct() { $this ->register('txt', new TextDescriptor()) ->register('xml', new XmlDescriptor()) ->register('json', new JsonDescriptor()) ->register('md', new MarkdownDescriptor()) ; } /** * Describes an object if supported. * * Available options are: * * format: string, the output format name * * raw_text: boolean, sets output type as raw * * @param OutputInterface $output * @param object $object * @param array $options * * @throws InvalidArgumentException when the given format is not supported */ public function describe(OutputInterface $output, $object, array $options = array()) { $options = array_merge(array( 'raw_text' => false, 'format' => 'txt', ), $options); if (!isset($this->descriptors[$options['format']])) { throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); } $descriptor = $this->descriptors[$options['format']]; $descriptor->describe($output, $object, $options); } /** * Registers a descriptor. * * @param string $format * @param DescriptorInterface $descriptor * * @return $this */ public function register($format, DescriptorInterface $descriptor) { $this->descriptors[$format] = $descriptor; return $this; } /** * {@inheritdoc} */ public function getName() { return 'descriptor'; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/FormatterHelper.php000066400000000000000000000056221324732107100260670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Formatter\OutputFormatter; /** * The Formatter class provides helpers to format messages. * * @author Fabien Potencier */ class FormatterHelper extends Helper { /** * Formats a message within a section. * * @param string $section The section name * @param string $message The message * @param string $style The style to apply to the section * * @return string The format section */ public function formatSection($section, $message, $style = 'info') { return sprintf('<%s>[%s] %s', $style, $section, $style, $message); } /** * Formats a message as a block of text. * * @param string|array $messages The message to write in the block * @param string $style The style to apply to the whole block * @param bool $large Whether to return a large block * * @return string The formatter message */ public function formatBlock($messages, $style, $large = false) { if (!is_array($messages)) { $messages = array($messages); } $len = 0; $lines = array(); foreach ($messages as $message) { $message = OutputFormatter::escape($message); $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); $len = max($this->strlen($message) + ($large ? 4 : 2), $len); } $messages = $large ? array(str_repeat(' ', $len)) : array(); for ($i = 0; isset($lines[$i]); ++$i) { $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i])); } if ($large) { $messages[] = str_repeat(' ', $len); } for ($i = 0; isset($messages[$i]); ++$i) { $messages[$i] = sprintf('<%s>%s', $style, $messages[$i], $style); } return implode("\n", $messages); } /** * Truncates a message to the given length. * * @param string $message * @param int $length * @param string $suffix * * @return string */ public function truncate($message, $length, $suffix = '...') { $computedLength = $length - $this->strlen($suffix); if ($computedLength > $this->strlen($message)) { return $message; } if (false === $encoding = mb_detect_encoding($message, null, true)) { return substr($message, 0, $length).$suffix; } return mb_substr($message, 0, $length, $encoding).$suffix; } /** * {@inheritdoc} */ public function getName() { return 'formatter'; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/Helper.php000066400000000000000000000073371324732107100242100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** * Helper is the base class for all helper classes. * * @author Fabien Potencier */ abstract class Helper implements HelperInterface { protected $helperSet = null; /** * {@inheritdoc} */ public function setHelperSet(HelperSet $helperSet = null) { $this->helperSet = $helperSet; } /** * {@inheritdoc} */ public function getHelperSet() { return $this->helperSet; } /** * Returns the length of a string, using mb_strwidth if it is available. * * @param string $string The string to check its length * * @return int The length of the string */ public static function strlen($string) { if (false === $encoding = mb_detect_encoding($string, null, true)) { return strlen($string); } return mb_strwidth($string, $encoding); } /** * Returns the subset of a string, using mb_substr if it is available. * * @param string $string String to subset * @param int $from Start offset * @param int|null $length Length to read * * @return string The string subset */ public static function substr($string, $from, $length = null) { if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); } return mb_substr($string, $from, $length, $encoding); } public static function formatTime($secs) { static $timeFormats = array( array(0, '< 1 sec'), array(1, '1 sec'), array(2, 'secs', 1), array(60, '1 min'), array(120, 'mins', 60), array(3600, '1 hr'), array(7200, 'hrs', 3600), array(86400, '1 day'), array(172800, 'days', 86400), ); foreach ($timeFormats as $index => $format) { if ($secs >= $format[0]) { if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0]) || $index == count($timeFormats) - 1 ) { if (2 == count($format)) { return $format[1]; } return floor($secs / $format[2]).' '.$format[1]; } } } } public static function formatMemory($memory) { if ($memory >= 1024 * 1024 * 1024) { return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024); } if ($memory >= 1024 * 1024) { return sprintf('%.1f MiB', $memory / 1024 / 1024); } if ($memory >= 1024) { return sprintf('%d KiB', $memory / 1024); } return sprintf('%d B', $memory); } public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string) { return self::strlen(self::removeDecoration($formatter, $string)); } public static function removeDecoration(OutputFormatterInterface $formatter, $string) { $isDecorated = $formatter->isDecorated(); $formatter->setDecorated(false); // remove <...> formatting $string = $formatter->format($string); // remove already formatted characters $string = preg_replace("/\033\[[^m]*m/", '', $string); $formatter->setDecorated($isDecorated); return $string; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/HelperInterface.php000066400000000000000000000015601324732107100260210ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; /** * HelperInterface is the interface all helpers must implement. * * @author Fabien Potencier */ interface HelperInterface { /** * Sets the helper set associated with this helper. */ public function setHelperSet(HelperSet $helperSet = null); /** * Gets the helper set associated with this helper. * * @return HelperSet A HelperSet instance */ public function getHelperSet(); /** * Returns the canonical name of this helper. * * @return string The canonical name */ public function getName(); } symfony-3.4.6/src/Symfony/Component/Console/Helper/HelperSet.php000066400000000000000000000047121324732107100246560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * HelperSet represents a set of helpers to be used with a command. * * @author Fabien Potencier */ class HelperSet implements \IteratorAggregate { /** * @var Helper[] */ private $helpers = array(); private $command; /** * @param Helper[] $helpers An array of helper */ public function __construct(array $helpers = array()) { foreach ($helpers as $alias => $helper) { $this->set($helper, is_int($alias) ? null : $alias); } } /** * Sets a helper. * * @param HelperInterface $helper The helper instance * @param string $alias An alias */ public function set(HelperInterface $helper, $alias = null) { $this->helpers[$helper->getName()] = $helper; if (null !== $alias) { $this->helpers[$alias] = $helper; } $helper->setHelperSet($this); } /** * Returns true if the helper if defined. * * @param string $name The helper name * * @return bool true if the helper is defined, false otherwise */ public function has($name) { return isset($this->helpers[$name]); } /** * Gets a helper value. * * @param string $name The helper name * * @return HelperInterface The helper instance * * @throws InvalidArgumentException if the helper is not defined */ public function get($name) { if (!$this->has($name)) { throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); } return $this->helpers[$name]; } public function setCommand(Command $command = null) { $this->command = $command; } /** * Gets the command associated with this helper set. * * @return Command A Command instance */ public function getCommand() { return $this->command; } /** * @return Helper[] */ public function getIterator() { return new \ArrayIterator($this->helpers); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/InputAwareHelper.php000066400000000000000000000013531324732107100262000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputAwareInterface; /** * An implementation of InputAwareInterface for Helpers. * * @author Wouter J */ abstract class InputAwareHelper extends Helper implements InputAwareInterface { protected $input; /** * {@inheritdoc} */ public function setInput(InputInterface $input) { $this->input = $input; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/ProcessHelper.php000066400000000000000000000113621324732107100255400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Process; /** * The ProcessHelper class provides helpers to run external processes. * * @author Fabien Potencier */ class ProcessHelper extends Helper { /** * Runs an external process. * * @param OutputInterface $output An OutputInterface instance * @param string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run * @param string|null $error An error message that must be displayed if something went wrong * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * @param int $verbosity The threshold for verbosity * * @return Process The process that ran */ public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $formatter = $this->getHelperSet()->get('debug_formatter'); if ($cmd instanceof Process) { $process = $cmd; } else { $process = new Process($cmd); } if ($verbosity <= $output->getVerbosity()) { $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine()))); } if ($output->isDebug()) { $callback = $this->wrapCallback($output, $process, $callback); } $process->run($callback); if ($verbosity <= $output->getVerbosity()) { $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode()); $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful())); } if (!$process->isSuccessful() && null !== $error) { $output->writeln(sprintf('%s', $this->escapeString($error))); } return $process; } /** * Runs the process. * * This is identical to run() except that an exception is thrown if the process * exits with a non-zero exit code. * * @param OutputInterface $output An OutputInterface instance * @param string|Process $cmd An instance of Process or a command to run * @param string|null $error An error message that must be displayed if something went wrong * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * * @return Process The process that ran * * @throws ProcessFailedException * * @see run() */ public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null) { $process = $this->run($output, $cmd, $error, $callback); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return $process; } /** * Wraps a Process callback to add debugging output. * * @param OutputInterface $output An OutputInterface interface * @param Process $process The Process * @param callable|null $callback A PHP callable * * @return callable */ public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $formatter = $this->getHelperSet()->get('debug_formatter'); return function ($type, $buffer) use ($output, $process, $callback, $formatter) { $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); if (null !== $callback) { call_user_func($callback, $type, $buffer); } }; } private function escapeString($str) { return str_replace('<', '\\<', $str); } /** * {@inheritdoc} */ public function getName() { return 'process'; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/ProgressBar.php000066400000000000000000000417011324732107100252130ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Terminal; /** * The ProgressBar provides helpers to display progress output. * * @author Fabien Potencier * @author Chris Jones */ final class ProgressBar { private $barWidth = 28; private $barChar; private $emptyBarChar = '-'; private $progressChar = '>'; private $format; private $internalFormat; private $redrawFreq = 1; private $output; private $step = 0; private $max; private $startTime; private $stepWidth; private $percent = 0.0; private $formatLineCount; private $messages = array(); private $overwrite = true; private $terminal; private $firstRun = true; private static $formatters; private static $formats; /** * @param OutputInterface $output An OutputInterface instance * @param int $max Maximum steps (0 if unknown) */ public function __construct(OutputInterface $output, $max = 0) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->output = $output; $this->setMaxSteps($max); $this->terminal = new Terminal(); if (!$this->output->isDecorated()) { // disable overwrite when output does not support ANSI codes. $this->overwrite = false; // set a reasonable redraw frequency so output isn't flooded $this->setRedrawFrequency($max / 10); } $this->startTime = time(); } /** * Sets a placeholder formatter for a given name. * * This method also allow you to override an existing placeholder. * * @param string $name The placeholder name (including the delimiter char like %) * @param callable $callable A PHP callable */ public static function setPlaceholderFormatterDefinition($name, callable $callable) { if (!self::$formatters) { self::$formatters = self::initPlaceholderFormatters(); } self::$formatters[$name] = $callable; } /** * Gets the placeholder formatter for a given name. * * @param string $name The placeholder name (including the delimiter char like %) * * @return callable|null A PHP callable */ public static function getPlaceholderFormatterDefinition($name) { if (!self::$formatters) { self::$formatters = self::initPlaceholderFormatters(); } return isset(self::$formatters[$name]) ? self::$formatters[$name] : null; } /** * Sets a format for a given name. * * This method also allow you to override an existing format. * * @param string $name The format name * @param string $format A format string */ public static function setFormatDefinition($name, $format) { if (!self::$formats) { self::$formats = self::initFormats(); } self::$formats[$name] = $format; } /** * Gets the format for a given name. * * @param string $name The format name * * @return string|null A format string */ public static function getFormatDefinition($name) { if (!self::$formats) { self::$formats = self::initFormats(); } return isset(self::$formats[$name]) ? self::$formats[$name] : null; } /** * Associates a text with a named placeholder. * * The text is displayed when the progress bar is rendered but only * when the corresponding placeholder is part of the custom format line * (by wrapping the name with %). * * @param string $message The text to associate with the placeholder * @param string $name The name of the placeholder */ public function setMessage($message, $name = 'message') { $this->messages[$name] = $message; } public function getMessage($name = 'message') { return $this->messages[$name]; } /** * Gets the progress bar start time. * * @return int The progress bar start time */ public function getStartTime() { return $this->startTime; } /** * Gets the progress bar maximal steps. * * @return int The progress bar max steps */ public function getMaxSteps() { return $this->max; } /** * Gets the current step position. * * @return int The progress bar step */ public function getProgress() { return $this->step; } /** * Gets the progress bar step width. * * @return int The progress bar step width */ private function getStepWidth() { return $this->stepWidth; } /** * Gets the current progress bar percent. * * @return float The current progress bar percent */ public function getProgressPercent() { return $this->percent; } /** * Sets the progress bar width. * * @param int $size The progress bar size */ public function setBarWidth($size) { $this->barWidth = max(1, (int) $size); } /** * Gets the progress bar width. * * @return int The progress bar size */ public function getBarWidth() { return $this->barWidth; } /** * Sets the bar character. * * @param string $char A character */ public function setBarCharacter($char) { $this->barChar = $char; } /** * Gets the bar character. * * @return string A character */ public function getBarCharacter() { if (null === $this->barChar) { return $this->max ? '=' : $this->emptyBarChar; } return $this->barChar; } /** * Sets the empty bar character. * * @param string $char A character */ public function setEmptyBarCharacter($char) { $this->emptyBarChar = $char; } /** * Gets the empty bar character. * * @return string A character */ public function getEmptyBarCharacter() { return $this->emptyBarChar; } /** * Sets the progress bar character. * * @param string $char A character */ public function setProgressCharacter($char) { $this->progressChar = $char; } /** * Gets the progress bar character. * * @return string A character */ public function getProgressCharacter() { return $this->progressChar; } /** * Sets the progress bar format. * * @param string $format The format */ public function setFormat($format) { $this->format = null; $this->internalFormat = $format; } /** * Sets the redraw frequency. * * @param int|float $freq The frequency in steps */ public function setRedrawFrequency($freq) { $this->redrawFreq = max((int) $freq, 1); } /** * Starts the progress output. * * @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged */ public function start($max = null) { $this->startTime = time(); $this->step = 0; $this->percent = 0.0; if (null !== $max) { $this->setMaxSteps($max); } $this->display(); } /** * Advances the progress output X steps. * * @param int $step Number of steps to advance */ public function advance($step = 1) { $this->setProgress($this->step + $step); } /** * Sets whether to overwrite the progressbar, false for new line. * * @param bool $overwrite */ public function setOverwrite($overwrite) { $this->overwrite = (bool) $overwrite; } /** * Sets the current progress. * * @param int $step The current progress */ public function setProgress($step) { $step = (int) $step; if ($this->max && $step > $this->max) { $this->max = $step; } elseif ($step < 0) { $step = 0; } $prevPeriod = (int) ($this->step / $this->redrawFreq); $currPeriod = (int) ($step / $this->redrawFreq); $this->step = $step; $this->percent = $this->max ? (float) $this->step / $this->max : 0; if ($prevPeriod !== $currPeriod || $this->max === $step) { $this->display(); } } /** * Finishes the progress output. */ public function finish() { if (!$this->max) { $this->max = $this->step; } if ($this->step === $this->max && !$this->overwrite) { // prevent double 100% output return; } $this->setProgress($this->max); } /** * Outputs the current progress string. */ public function display() { if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { return; } if (null === $this->format) { $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); } $this->overwrite($this->buildLine()); } /** * Removes the progress bar from the current line. * * This is useful if you wish to write some output * while a progress bar is running. * Call display() to show the progress bar again. */ public function clear() { if (!$this->overwrite) { return; } if (null === $this->format) { $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); } $this->overwrite(''); } /** * Sets the progress bar format. * * @param string $format The format */ private function setRealFormat($format) { // try to use the _nomax variant if available if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { $this->format = self::getFormatDefinition($format.'_nomax'); } elseif (null !== self::getFormatDefinition($format)) { $this->format = self::getFormatDefinition($format); } else { $this->format = $format; } $this->formatLineCount = substr_count($this->format, "\n"); } /** * Sets the progress bar maximal steps. * * @param int $max The progress bar max steps */ private function setMaxSteps($max) { $this->max = max(0, (int) $max); $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4; } /** * Overwrites a previous message to the output. * * @param string $message The message */ private function overwrite($message) { if ($this->overwrite) { if (!$this->firstRun) { // Move the cursor to the beginning of the line $this->output->write("\x0D"); // Erase the line $this->output->write("\x1B[2K"); // Erase previous lines if ($this->formatLineCount > 0) { $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount)); } } } elseif ($this->step > 0) { $this->output->writeln(''); } $this->firstRun = false; $this->output->write($message); } private function determineBestFormat() { switch ($this->output->getVerbosity()) { // OutputInterface::VERBOSITY_QUIET: display is disabled anyway case OutputInterface::VERBOSITY_VERBOSE: return $this->max ? 'verbose' : 'verbose_nomax'; case OutputInterface::VERBOSITY_VERY_VERBOSE: return $this->max ? 'very_verbose' : 'very_verbose_nomax'; case OutputInterface::VERBOSITY_DEBUG: return $this->max ? 'debug' : 'debug_nomax'; default: return $this->max ? 'normal' : 'normal_nomax'; } } private static function initPlaceholderFormatters() { return array( 'bar' => function (ProgressBar $bar, OutputInterface $output) { $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth()); $display = str_repeat($bar->getBarCharacter(), $completeBars); if ($completeBars < $bar->getBarWidth()) { $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter()); $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars); } return $display; }, 'elapsed' => function (ProgressBar $bar) { return Helper::formatTime(time() - $bar->getStartTime()); }, 'remaining' => function (ProgressBar $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); } if (!$bar->getProgress()) { $remaining = 0; } else { $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress())); } return Helper::formatTime($remaining); }, 'estimated' => function (ProgressBar $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); } if (!$bar->getProgress()) { $estimated = 0; } else { $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps()); } return Helper::formatTime($estimated); }, 'memory' => function (ProgressBar $bar) { return Helper::formatMemory(memory_get_usage(true)); }, 'current' => function (ProgressBar $bar) { return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); }, 'max' => function (ProgressBar $bar) { return $bar->getMaxSteps(); }, 'percent' => function (ProgressBar $bar) { return floor($bar->getProgressPercent() * 100); }, ); } private static function initFormats() { return array( 'normal' => ' %current%/%max% [%bar%] %percent:3s%%', 'normal_nomax' => ' %current% [%bar%]', 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%', 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%', 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%', 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%', 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%', 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%', ); } /** * @return string */ private function buildLine() { $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i"; $callback = function ($matches) { if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) { $text = call_user_func($formatter, $this, $this->output); } elseif (isset($this->messages[$matches[1]])) { $text = $this->messages[$matches[1]]; } else { return $matches[0]; } if (isset($matches[2])) { $text = sprintf('%'.$matches[2], $text); } return $text; }; $line = preg_replace_callback($regex, $callback, $this->format); // gets string length for each sub line with multiline format $linesLength = array_map(function ($subLine) { return Helper::strlenWithoutDecoration($this->output->getFormatter(), rtrim($subLine, "\r")); }, explode("\n", $line)); $linesWidth = max($linesLength); $terminalWidth = $this->terminal->getWidth(); if ($linesWidth <= $terminalWidth) { return $line; } $this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth); return preg_replace_callback($regex, $callback, $this->format); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/ProgressIndicator.php000066400000000000000000000174131324732107100264260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Output\OutputInterface; /** * @author Kevin Bond */ class ProgressIndicator { private $output; private $startTime; private $format; private $message; private $indicatorValues; private $indicatorCurrent; private $indicatorChangeInterval; private $indicatorUpdateTime; private $started = false; private static $formatters; private static $formats; /** * @param OutputInterface $output * @param string|null $format Indicator format * @param int $indicatorChangeInterval Change interval in milliseconds * @param array|null $indicatorValues Animated indicator characters */ public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null) { $this->output = $output; if (null === $format) { $format = $this->determineBestFormat(); } if (null === $indicatorValues) { $indicatorValues = array('-', '\\', '|', '/'); } $indicatorValues = array_values($indicatorValues); if (2 > count($indicatorValues)) { throw new InvalidArgumentException('Must have at least 2 indicator value characters.'); } $this->format = self::getFormatDefinition($format); $this->indicatorChangeInterval = $indicatorChangeInterval; $this->indicatorValues = $indicatorValues; $this->startTime = time(); } /** * Sets the current indicator message. * * @param string|null $message */ public function setMessage($message) { $this->message = $message; $this->display(); } /** * Starts the indicator output. * * @param $message */ public function start($message) { if ($this->started) { throw new LogicException('Progress indicator already started.'); } $this->message = $message; $this->started = true; $this->startTime = time(); $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval; $this->indicatorCurrent = 0; $this->display(); } /** * Advances the indicator. */ public function advance() { if (!$this->started) { throw new LogicException('Progress indicator has not yet been started.'); } if (!$this->output->isDecorated()) { return; } $currentTime = $this->getCurrentTimeInMilliseconds(); if ($currentTime < $this->indicatorUpdateTime) { return; } $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval; ++$this->indicatorCurrent; $this->display(); } /** * Finish the indicator with message. * * @param $message */ public function finish($message) { if (!$this->started) { throw new LogicException('Progress indicator has not yet been started.'); } $this->message = $message; $this->display(); $this->output->writeln(''); $this->started = false; } /** * Gets the format for a given name. * * @param string $name The format name * * @return string|null A format string */ public static function getFormatDefinition($name) { if (!self::$formats) { self::$formats = self::initFormats(); } return isset(self::$formats[$name]) ? self::$formats[$name] : null; } /** * Sets a placeholder formatter for a given name. * * This method also allow you to override an existing placeholder. * * @param string $name The placeholder name (including the delimiter char like %) * @param callable $callable A PHP callable */ public static function setPlaceholderFormatterDefinition($name, $callable) { if (!self::$formatters) { self::$formatters = self::initPlaceholderFormatters(); } self::$formatters[$name] = $callable; } /** * Gets the placeholder formatter for a given name. * * @param string $name The placeholder name (including the delimiter char like %) * * @return callable|null A PHP callable */ public static function getPlaceholderFormatterDefinition($name) { if (!self::$formatters) { self::$formatters = self::initPlaceholderFormatters(); } return isset(self::$formatters[$name]) ? self::$formatters[$name] : null; } private function display() { if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { return; } $self = $this; $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) { if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { return call_user_func($formatter, $self); } return $matches[0]; }, $this->format)); } private function determineBestFormat() { switch ($this->output->getVerbosity()) { // OutputInterface::VERBOSITY_QUIET: display is disabled anyway case OutputInterface::VERBOSITY_VERBOSE: return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi'; case OutputInterface::VERBOSITY_VERY_VERBOSE: case OutputInterface::VERBOSITY_DEBUG: return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi'; default: return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi'; } } /** * Overwrites a previous message to the output. * * @param string $message The message */ private function overwrite($message) { if ($this->output->isDecorated()) { $this->output->write("\x0D\x1B[2K"); $this->output->write($message); } else { $this->output->writeln($message); } } private function getCurrentTimeInMilliseconds() { return round(microtime(true) * 1000); } private static function initPlaceholderFormatters() { return array( 'indicator' => function (ProgressIndicator $indicator) { return $indicator->indicatorValues[$indicator->indicatorCurrent % count($indicator->indicatorValues)]; }, 'message' => function (ProgressIndicator $indicator) { return $indicator->message; }, 'elapsed' => function (ProgressIndicator $indicator) { return Helper::formatTime(time() - $indicator->startTime); }, 'memory' => function () { return Helper::formatMemory(memory_get_usage(true)); }, ); } private static function initFormats() { return array( 'normal' => ' %indicator% %message%', 'normal_no_ansi' => ' %message%', 'verbose' => ' %indicator% %message% (%elapsed:6s%)', 'verbose_no_ansi' => ' %message% (%elapsed:6s%)', 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)', 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)', ); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/QuestionHelper.php000066400000000000000000000344201324732107100257310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\StreamableInputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Question\ChoiceQuestion; /** * The QuestionHelper class provides helpers to interact with the user. * * @author Fabien Potencier */ class QuestionHelper extends Helper { private $inputStream; private static $shell; private static $stty; /** * Asks a question to the user. * * @return mixed The user answer * * @throws RuntimeException If there is no data to read in the input stream */ public function ask(InputInterface $input, OutputInterface $output, Question $question) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } if (!$input->isInteractive()) { if ($question instanceof ChoiceQuestion) { $choices = $question->getChoices(); return $choices[$question->getDefault()]; } return $question->getDefault(); } if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) { $this->inputStream = $stream; } if (!$question->getValidator()) { return $this->doAsk($output, $question); } $interviewer = function () use ($output, $question) { return $this->doAsk($output, $question); }; return $this->validateAttempts($interviewer, $output, $question); } /** * Sets the input stream to read from when interacting with the user. * * This is mainly useful for testing purpose. * * @deprecated since version 3.2, to be removed in 4.0. Use * StreamableInputInterface::setStream() instead. * * @param resource $stream The input stream * * @throws InvalidArgumentException In case the stream is not a resource */ public function setInputStream($stream) { @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } $this->inputStream = $stream; } /** * Returns the helper's input stream. * * @deprecated since version 3.2, to be removed in 4.0. Use * StreamableInputInterface::getStream() instead. * * @return resource */ public function getInputStream() { if (0 === func_num_args() || func_get_arg(0)) { @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); } return $this->inputStream; } /** * {@inheritdoc} */ public function getName() { return 'question'; } /** * Prevents usage of stty. */ public static function disableStty() { self::$stty = false; } /** * Asks the question to the user. * * @return bool|mixed|null|string * * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); $inputStream = $this->inputStream ?: STDIN; $autocomplete = $question->getAutocompleterValues(); if (null === $autocomplete || !$this->hasSttyAvailable()) { $ret = false; if ($question->isHidden()) { try { $ret = trim($this->getHiddenResponse($output, $inputStream)); } catch (RuntimeException $e) { if (!$question->isHiddenFallback()) { throw $e; } } } if (false === $ret) { $ret = fgets($inputStream, 4096); if (false === $ret) { throw new RuntimeException('Aborted'); } $ret = trim($ret); } } else { $ret = trim($this->autocomplete($output, $question, $inputStream, is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false))); } $ret = strlen($ret) > 0 ? $ret : $question->getDefault(); if ($normalizer = $question->getNormalizer()) { return $normalizer($ret); } return $ret; } /** * Outputs the question prompt. */ protected function writePrompt(OutputInterface $output, Question $question) { $message = $question->getQuestion(); if ($question instanceof ChoiceQuestion) { $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices()))); $messages = (array) $question->getQuestion(); foreach ($question->getChoices() as $key => $value) { $width = $maxWidth - $this->strlen($key); $messages[] = ' ['.$key.str_repeat(' ', $width).'] '.$value; } $output->writeln($messages); $message = $question->getPrompt(); } $output->write($message); } /** * Outputs an error message. */ protected function writeError(OutputInterface $output, \Exception $error) { if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) { $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'); } else { $message = ''.$error->getMessage().''; } $output->writeln($message); } /** * Autocompletes a question. * * @param OutputInterface $output * @param Question $question * @param resource $inputStream * @param array $autocomplete * * @return string */ private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete) { $ret = ''; $i = 0; $ofs = -1; $matches = $autocomplete; $numMatches = count($matches); $sttyMode = shell_exec('stty -g'); // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) shell_exec('stty -icanon -echo'); // Add highlighted text style $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white')); // Read a keypress while (!feof($inputStream)) { $c = fread($inputStream, 1); // Backspace Character if ("\177" === $c) { if (0 === $numMatches && 0 !== $i) { --$i; // Move cursor backwards $output->write("\033[1D"); } if (0 === $i) { $ofs = -1; $matches = $autocomplete; $numMatches = count($matches); } else { $numMatches = 0; } // Pop the last character off the end of our string $ret = substr($ret, 0, $i); } elseif ("\033" === $c) { // Did we read an escape sequence? $c .= fread($inputStream, 2); // A = Up Arrow. B = Down Arrow if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { if ('A' === $c[2] && -1 === $ofs) { $ofs = 0; } if (0 === $numMatches) { continue; } $ofs += ('A' === $c[2]) ? -1 : 1; $ofs = ($numMatches + $ofs) % $numMatches; } } elseif (ord($c) < 32) { if ("\t" === $c || "\n" === $c) { if ($numMatches > 0 && -1 !== $ofs) { $ret = $matches[$ofs]; // Echo out remaining chars for current match $output->write(substr($ret, $i)); $i = strlen($ret); } if ("\n" === $c) { $output->write($c); break; } $numMatches = 0; } continue; } else { $output->write($c); $ret .= $c; ++$i; $numMatches = 0; $ofs = 0; foreach ($autocomplete as $value) { // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) if (0 === strpos($value, $ret) && $i !== strlen($value)) { $matches[$numMatches++] = $value; } } } // Erase characters from cursor to end of line $output->write("\033[K"); if ($numMatches > 0 && -1 !== $ofs) { // Save cursor position $output->write("\0337"); // Write highlighted text $output->write(''.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).''); // Restore cursor position $output->write("\0338"); } } // Reset stty so it behaves normally again shell_exec(sprintf('stty %s', $sttyMode)); return $ret; } /** * Gets a hidden response from user. * * @param OutputInterface $output An Output instance * @param resource $inputStream The handler resource * * @return string The answer * * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ private function getHiddenResponse(OutputInterface $output, $inputStream) { if ('\\' === DIRECTORY_SEPARATOR) { $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; // handle code running from a phar if ('phar:' === substr(__FILE__, 0, 5)) { $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; copy($exe, $tmpExe); $exe = $tmpExe; } $value = rtrim(shell_exec($exe)); $output->writeln(''); if (isset($tmpExe)) { unlink($tmpExe); } return $value; } if ($this->hasSttyAvailable()) { $sttyMode = shell_exec('stty -g'); shell_exec('stty -echo'); $value = fgets($inputStream, 4096); shell_exec(sprintf('stty %s', $sttyMode)); if (false === $value) { throw new RuntimeException('Aborted'); } $value = trim($value); $output->writeln(''); return $value; } if (false !== $shell = $this->getShell()) { $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword'; $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); $value = rtrim(shell_exec($command)); $output->writeln(''); return $value; } throw new RuntimeException('Unable to hide the response.'); } /** * Validates an attempt. * * @param callable $interviewer A callable that will ask for a question and return the result * @param OutputInterface $output An Output instance * @param Question $question A Question instance * * @return mixed The validated response * * @throws \Exception In case the max number of attempts has been reached and no valid response has been given */ private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) { $error = null; $attempts = $question->getMaxAttempts(); while (null === $attempts || $attempts--) { if (null !== $error) { $this->writeError($output, $error); } try { return call_user_func($question->getValidator(), $interviewer()); } catch (RuntimeException $e) { throw $e; } catch (\Exception $error) { } } throw $error; } /** * Returns a valid unix shell. * * @return string|bool The valid shell name, false in case no valid shell is found */ private function getShell() { if (null !== self::$shell) { return self::$shell; } self::$shell = false; if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; } } } return self::$shell; } /** * Returns whether Stty is available or not. * * @return bool */ private function hasSttyAvailable() { if (null !== self::$stty) { return self::$stty; } exec('stty 2>&1', $output, $exitcode); return self::$stty = 0 === $exitcode; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php000066400000000000000000000077001324732107100273170ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Formatter\OutputFormatter; /** * Symfony Style Guide compliant question helper. * * @author Kevin Bond */ class SymfonyQuestionHelper extends QuestionHelper { /** * {@inheritdoc} * * To be removed in 4.0 */ public function ask(InputInterface $input, OutputInterface $output, Question $question) { $validator = $question->getValidator(); $question->setValidator(function ($value) use ($validator) { if (null !== $validator) { $value = $validator($value); } else { // make required if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) { @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED); throw new LogicException('A value is required.'); } } return $value; }); return parent::ask($input, $output, $question); } /** * {@inheritdoc} */ protected function writePrompt(OutputInterface $output, Question $question) { $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); $default = $question->getDefault(); switch (true) { case null === $default: $text = sprintf(' %s:', $text); break; case $question instanceof ConfirmationQuestion: $text = sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no'); break; case $question instanceof ChoiceQuestion && $question->isMultiselect(): $choices = $question->getChoices(); $default = explode(',', $default); foreach ($default as $key => $value) { $default[$key] = $choices[trim($value)]; } $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape(implode(', ', $default))); break; case $question instanceof ChoiceQuestion: $choices = $question->getChoices(); $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape($choices[$default])); break; default: $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape($default)); } $output->writeln($text); if ($question instanceof ChoiceQuestion) { $width = max(array_map('strlen', array_keys($question->getChoices()))); foreach ($question->getChoices() as $key => $value) { $output->writeln(sprintf(" [%-${width}s] %s", $key, $value)); } } $output->write(' > '); } /** * {@inheritdoc} */ protected function writeError(OutputInterface $output, \Exception $error) { if ($output instanceof SymfonyStyle) { $output->newLine(); $output->error($error->getMessage()); return; } parent::writeError($output, $error); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/Table.php000066400000000000000000000472531324732107100240210ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * Provides helpers to display a table. * * @author Fabien Potencier * @author Саша Стаменковић * @author Abdellatif Ait boudad * @author Max Grigorian */ class Table { /** * Table headers. */ private $headers = array(); /** * Table rows. */ private $rows = array(); /** * Column widths cache. */ private $effectiveColumnWidths = array(); /** * Number of columns cache. * * @var int */ private $numberOfColumns; /** * @var OutputInterface */ private $output; /** * @var TableStyle */ private $style; /** * @var array */ private $columnStyles = array(); /** * User set column widths. * * @var array */ private $columnWidths = array(); private static $styles; public function __construct(OutputInterface $output) { $this->output = $output; if (!self::$styles) { self::$styles = self::initStyles(); } $this->setStyle('default'); } /** * Sets a style definition. * * @param string $name The style name * @param TableStyle $style A TableStyle instance */ public static function setStyleDefinition($name, TableStyle $style) { if (!self::$styles) { self::$styles = self::initStyles(); } self::$styles[$name] = $style; } /** * Gets a style definition by name. * * @param string $name The style name * * @return TableStyle */ public static function getStyleDefinition($name) { if (!self::$styles) { self::$styles = self::initStyles(); } if (isset(self::$styles[$name])) { return self::$styles[$name]; } throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name)); } /** * Sets table style. * * @param TableStyle|string $name The style name or a TableStyle instance * * @return $this */ public function setStyle($name) { $this->style = $this->resolveStyle($name); return $this; } /** * Gets the current table style. * * @return TableStyle */ public function getStyle() { return $this->style; } /** * Sets table column style. * * @param int $columnIndex Column index * @param TableStyle|string $name The style name or a TableStyle instance * * @return $this */ public function setColumnStyle($columnIndex, $name) { $columnIndex = (int) $columnIndex; $this->columnStyles[$columnIndex] = $this->resolveStyle($name); return $this; } /** * Gets the current style for a column. * * If style was not set, it returns the global table style. * * @param int $columnIndex Column index * * @return TableStyle */ public function getColumnStyle($columnIndex) { if (isset($this->columnStyles[$columnIndex])) { return $this->columnStyles[$columnIndex]; } return $this->getStyle(); } /** * Sets the minimum width of a column. * * @param int $columnIndex Column index * @param int $width Minimum column width in characters * * @return $this */ public function setColumnWidth($columnIndex, $width) { $this->columnWidths[(int) $columnIndex] = (int) $width; return $this; } /** * Sets the minimum width of all columns. * * @param array $widths * * @return $this */ public function setColumnWidths(array $widths) { $this->columnWidths = array(); foreach ($widths as $index => $width) { $this->setColumnWidth($index, $width); } return $this; } public function setHeaders(array $headers) { $headers = array_values($headers); if (!empty($headers) && !is_array($headers[0])) { $headers = array($headers); } $this->headers = $headers; return $this; } public function setRows(array $rows) { $this->rows = array(); return $this->addRows($rows); } public function addRows(array $rows) { foreach ($rows as $row) { $this->addRow($row); } return $this; } public function addRow($row) { if ($row instanceof TableSeparator) { $this->rows[] = $row; return $this; } if (!is_array($row)) { throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.'); } $this->rows[] = array_values($row); return $this; } public function setRow($column, array $row) { $this->rows[$column] = $row; return $this; } /** * Renders table to output. * * Example: * * +---------------+-----------------------+------------------+ * | ISBN | Title | Author | * +---------------+-----------------------+------------------+ * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | * +---------------+-----------------------+------------------+ * */ public function render() { $this->calculateNumberOfColumns(); $rows = $this->buildTableRows($this->rows); $headers = $this->buildTableRows($this->headers); $this->calculateColumnsWidth(array_merge($headers, $rows)); $this->renderRowSeparator(); if (!empty($headers)) { foreach ($headers as $header) { $this->renderRow($header, $this->style->getCellHeaderFormat()); $this->renderRowSeparator(); } } foreach ($rows as $row) { if ($row instanceof TableSeparator) { $this->renderRowSeparator(); } else { $this->renderRow($row, $this->style->getCellRowFormat()); } } if (!empty($rows)) { $this->renderRowSeparator(); } $this->cleanup(); } /** * Renders horizontal header separator. * * Example: +-----+-----------+-------+ */ private function renderRowSeparator() { if (0 === $count = $this->numberOfColumns) { return; } if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) { return; } $markup = $this->style->getCrossingChar(); for ($column = 0; $column < $count; ++$column) { $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->effectiveColumnWidths[$column]).$this->style->getCrossingChar(); } $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup)); } /** * Renders vertical column separator. */ private function renderColumnSeparator() { return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()); } /** * Renders table row. * * Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | * * @param array $row * @param string $cellFormat */ private function renderRow(array $row, $cellFormat) { if (empty($row)) { return; } $rowContent = $this->renderColumnSeparator(); foreach ($this->getRowColumns($row) as $column) { $rowContent .= $this->renderCell($row, $column, $cellFormat); $rowContent .= $this->renderColumnSeparator(); } $this->output->writeln($rowContent); } /** * Renders table cell with padding. * * @param array $row * @param int $column * @param string $cellFormat */ private function renderCell(array $row, $column, $cellFormat) { $cell = isset($row[$column]) ? $row[$column] : ''; $width = $this->effectiveColumnWidths[$column]; if ($cell instanceof TableCell && $cell->getColspan() > 1) { // add the width of the following columns(numbers of colspan). foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) { $width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn]; } } // str_pad won't work properly with multi-byte strings, we need to fix the padding if (false !== $encoding = mb_detect_encoding($cell, null, true)) { $width += strlen($cell) - mb_strwidth($cell, $encoding); } $style = $this->getColumnStyle($column); if ($cell instanceof TableSeparator) { return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width)); } $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell); $content = sprintf($style->getCellRowContentFormat(), $cell); return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType())); } /** * Calculate number of columns for this table. */ private function calculateNumberOfColumns() { if (null !== $this->numberOfColumns) { return; } $columns = array(0); foreach (array_merge($this->headers, $this->rows) as $row) { if ($row instanceof TableSeparator) { continue; } $columns[] = $this->getNumberOfColumns($row); } $this->numberOfColumns = max($columns); } private function buildTableRows($rows) { $unmergedRows = array(); for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) { $rows = $this->fillNextRows($rows, $rowKey); // Remove any new line breaks and replace it with a new line foreach ($rows[$rowKey] as $column => $cell) { if (!strstr($cell, "\n")) { continue; } $lines = explode("\n", str_replace("\n", "\n", $cell)); foreach ($lines as $lineKey => $line) { if ($cell instanceof TableCell) { $line = new TableCell($line, array('colspan' => $cell->getColspan())); } if (0 === $lineKey) { $rows[$rowKey][$column] = $line; } else { $unmergedRows[$rowKey][$lineKey][$column] = $line; } } } } $tableRows = array(); foreach ($rows as $rowKey => $row) { $tableRows[] = $this->fillCells($row); if (isset($unmergedRows[$rowKey])) { $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]); } } return $tableRows; } /** * fill rows that contains rowspan > 1. * * @param array $rows * @param int $line * * @return array * * @throws InvalidArgumentException */ private function fillNextRows(array $rows, $line) { $unmergedRows = array(); foreach ($rows[$line] as $column => $cell) { if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(is_object($cell) && method_exists($cell, '__toString'))) { throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', gettype($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; $lines = array($cell); if (strstr($cell, "\n")) { $lines = explode("\n", str_replace("\n", "\n", $cell)); $nbLines = count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines; $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan())); unset($lines[0]); } // create a two dimensional array (rowspan x colspan) $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows); foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : ''; $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan())); if ($nbLines === $unmergedRowKey - $line) { break; } } } } foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { // we need to know if $unmergedRow will be merged or inserted into $rows if (isset($rows[$unmergedRowKey]) && is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) { foreach ($unmergedRow as $cellKey => $cell) { // insert cell into row at cellKey position array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell)); } } else { $row = $this->copyRow($rows, $unmergedRowKey - 1); foreach ($unmergedRow as $column => $cell) { if (!empty($cell)) { $row[$column] = $unmergedRow[$column]; } } array_splice($rows, $unmergedRowKey, 0, array($row)); } } return $rows; } /** * fill cells for a row that contains colspan > 1. * * @return array */ private function fillCells($row) { $newRow = array(); foreach ($row as $column => $cell) { $newRow[] = $cell; if ($cell instanceof TableCell && $cell->getColspan() > 1) { foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) { // insert empty value at column position $newRow[] = ''; } } } return $newRow ?: $row; } /** * @param array $rows * @param int $line * * @return array */ private function copyRow(array $rows, $line) { $row = $rows[$line]; foreach ($row as $cellKey => $cellValue) { $row[$cellKey] = ''; if ($cellValue instanceof TableCell) { $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan())); } } return $row; } /** * Gets number of columns by row. * * @return int */ private function getNumberOfColumns(array $row) { $columns = count($row); foreach ($row as $column) { $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0; } return $columns; } /** * Gets list of columns for the given row. * * @return array */ private function getRowColumns(array $row) { $columns = range(0, $this->numberOfColumns - 1); foreach ($row as $cellKey => $cell) { if ($cell instanceof TableCell && $cell->getColspan() > 1) { // exclude grouped columns. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1)); } } return $columns; } /** * Calculates columns widths. */ private function calculateColumnsWidth(array $rows) { for ($column = 0; $column < $this->numberOfColumns; ++$column) { $lengths = array(); foreach ($rows as $row) { if ($row instanceof TableSeparator) { continue; } foreach ($row as $i => $cell) { if ($cell instanceof TableCell) { $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); $textLength = Helper::strlen($textContent); if ($textLength > 0) { $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan())); foreach ($contentColumns as $position => $content) { $row[$i + $position] = $content; } } } } $lengths[] = $this->getCellWidth($row, $column); } $this->effectiveColumnWidths[$column] = max($lengths) + strlen($this->style->getCellRowContentFormat()) - 2; } } /** * Gets column width. * * @return int */ private function getColumnSeparatorWidth() { return strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar())); } /** * Gets cell width. * * @param array $row * @param int $column * * @return int */ private function getCellWidth(array $row, $column) { $cellWidth = 0; if (isset($row[$column])) { $cell = $row[$column]; $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell); } $columnWidth = isset($this->columnWidths[$column]) ? $this->columnWidths[$column] : 0; return max($cellWidth, $columnWidth); } /** * Called after rendering to cleanup cache data. */ private function cleanup() { $this->effectiveColumnWidths = array(); $this->numberOfColumns = null; } private static function initStyles() { $borderless = new TableStyle(); $borderless ->setHorizontalBorderChar('=') ->setVerticalBorderChar(' ') ->setCrossingChar(' ') ; $compact = new TableStyle(); $compact ->setHorizontalBorderChar('') ->setVerticalBorderChar(' ') ->setCrossingChar('') ->setCellRowContentFormat('%s') ; $styleGuide = new TableStyle(); $styleGuide ->setHorizontalBorderChar('-') ->setVerticalBorderChar(' ') ->setCrossingChar(' ') ->setCellHeaderFormat('%s') ; return array( 'default' => new TableStyle(), 'borderless' => $borderless, 'compact' => $compact, 'symfony-style-guide' => $styleGuide, ); } private function resolveStyle($name) { if ($name instanceof TableStyle) { return $name; } if (isset(self::$styles[$name])) { return self::$styles[$name]; } throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name)); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/TableCell.php000066400000000000000000000031711324732107100246100ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * @author Abdellatif Ait boudad */ class TableCell { private $value; private $options = array( 'rowspan' => 1, 'colspan' => 1, ); /** * @param string $value * @param array $options */ public function __construct($value = '', array $options = array()) { if (is_numeric($value) && !is_string($value)) { $value = (string) $value; } $this->value = $value; // check option names if ($diff = array_diff(array_keys($options), array_keys($this->options))) { throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); } $this->options = array_merge($this->options, $options); } /** * Returns the cell value. * * @return string */ public function __toString() { return $this->value; } /** * Gets number of colspan. * * @return int */ public function getColspan() { return (int) $this->options['colspan']; } /** * Gets number of rowspan. * * @return int */ public function getRowspan() { return (int) $this->options['rowspan']; } } symfony-3.4.6/src/Symfony/Component/Console/Helper/TableSeparator.php000066400000000000000000000010301324732107100256610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; /** * Marks a row as being a separator. * * @author Fabien Potencier */ class TableSeparator extends TableCell { public function __construct(array $options = array()) { parent::__construct('', $options); } } symfony-3.4.6/src/Symfony/Component/Console/Helper/TableStyle.php000066400000000000000000000122101324732107100250230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * Defines the styles for a Table. * * @author Fabien Potencier * @author Саша Стаменковић */ class TableStyle { private $paddingChar = ' '; private $horizontalBorderChar = '-'; private $verticalBorderChar = '|'; private $crossingChar = '+'; private $cellHeaderFormat = '%s'; private $cellRowFormat = '%s'; private $cellRowContentFormat = ' %s '; private $borderFormat = '%s'; private $padType = STR_PAD_RIGHT; /** * Sets padding character, used for cell padding. * * @param string $paddingChar * * @return $this */ public function setPaddingChar($paddingChar) { if (!$paddingChar) { throw new LogicException('The padding char must not be empty'); } $this->paddingChar = $paddingChar; return $this; } /** * Gets padding character, used for cell padding. * * @return string */ public function getPaddingChar() { return $this->paddingChar; } /** * Sets horizontal border character. * * @param string $horizontalBorderChar * * @return $this */ public function setHorizontalBorderChar($horizontalBorderChar) { $this->horizontalBorderChar = $horizontalBorderChar; return $this; } /** * Gets horizontal border character. * * @return string */ public function getHorizontalBorderChar() { return $this->horizontalBorderChar; } /** * Sets vertical border character. * * @param string $verticalBorderChar * * @return $this */ public function setVerticalBorderChar($verticalBorderChar) { $this->verticalBorderChar = $verticalBorderChar; return $this; } /** * Gets vertical border character. * * @return string */ public function getVerticalBorderChar() { return $this->verticalBorderChar; } /** * Sets crossing character. * * @param string $crossingChar * * @return $this */ public function setCrossingChar($crossingChar) { $this->crossingChar = $crossingChar; return $this; } /** * Gets crossing character. * * @return string $crossingChar */ public function getCrossingChar() { return $this->crossingChar; } /** * Sets header cell format. * * @param string $cellHeaderFormat * * @return $this */ public function setCellHeaderFormat($cellHeaderFormat) { $this->cellHeaderFormat = $cellHeaderFormat; return $this; } /** * Gets header cell format. * * @return string */ public function getCellHeaderFormat() { return $this->cellHeaderFormat; } /** * Sets row cell format. * * @param string $cellRowFormat * * @return $this */ public function setCellRowFormat($cellRowFormat) { $this->cellRowFormat = $cellRowFormat; return $this; } /** * Gets row cell format. * * @return string */ public function getCellRowFormat() { return $this->cellRowFormat; } /** * Sets row cell content format. * * @param string $cellRowContentFormat * * @return $this */ public function setCellRowContentFormat($cellRowContentFormat) { $this->cellRowContentFormat = $cellRowContentFormat; return $this; } /** * Gets row cell content format. * * @return string */ public function getCellRowContentFormat() { return $this->cellRowContentFormat; } /** * Sets table border format. * * @param string $borderFormat * * @return $this */ public function setBorderFormat($borderFormat) { $this->borderFormat = $borderFormat; return $this; } /** * Gets table border format. * * @return string */ public function getBorderFormat() { return $this->borderFormat; } /** * Sets cell padding type. * * @param int $padType STR_PAD_* * * @return $this */ public function setPadType($padType) { if (!in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) { throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } $this->padType = $padType; return $this; } /** * Gets cell padding type. * * @return int */ public function getPadType() { return $this->padType; } } symfony-3.4.6/src/Symfony/Component/Console/Input/000077500000000000000000000000001324732107100221265ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Input/ArgvInput.php000066400000000000000000000253241324732107100245640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\RuntimeException; /** * ArgvInput represents an input coming from the CLI arguments. * * Usage: * * $input = new ArgvInput(); * * By default, the `$_SERVER['argv']` array is used for the input values. * * This can be overridden by explicitly passing the input values in the constructor: * * $input = new ArgvInput($_SERVER['argv']); * * If you pass it yourself, don't forget that the first element of the array * is the name of the running application. * * When passing an argument to the constructor, be sure that it respects * the same rules as the argv one. It's almost always better to use the * `StringInput` when you want to provide your own input. * * @author Fabien Potencier * * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 */ class ArgvInput extends Input { private $tokens; private $parsed; /** * @param array|null $argv An array of parameters from the CLI (in the argv format) * @param InputDefinition|null $definition A InputDefinition instance */ public function __construct(array $argv = null, InputDefinition $definition = null) { if (null === $argv) { $argv = $_SERVER['argv']; } // strip the application name array_shift($argv); $this->tokens = $argv; parent::__construct($definition); } protected function setTokens(array $tokens) { $this->tokens = $tokens; } /** * {@inheritdoc} */ protected function parse() { $parseOptions = true; $this->parsed = $this->tokens; while (null !== $token = array_shift($this->parsed)) { if ($parseOptions && '' == $token) { $this->parseArgument($token); } elseif ($parseOptions && '--' == $token) { $parseOptions = false; } elseif ($parseOptions && 0 === strpos($token, '--')) { $this->parseLongOption($token); } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { $this->parseShortOption($token); } else { $this->parseArgument($token); } } } /** * Parses a short option. * * @param string $token The current token */ private function parseShortOption($token) { $name = substr($token, 1); if (strlen($name) > 1) { if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) { // an option with a value (with no space) $this->addShortOption($name[0], substr($name, 1)); } else { $this->parseShortOptionSet($name); } } else { $this->addShortOption($name, null); } } /** * Parses a short option set. * * @param string $name The current token * * @throws RuntimeException When option given doesn't exist */ private function parseShortOptionSet($name) { $len = strlen($name); for ($i = 0; $i < $len; ++$i) { if (!$this->definition->hasShortcut($name[$i])) { throw new RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); } $option = $this->definition->getOptionForShortcut($name[$i]); if ($option->acceptValue()) { $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); break; } else { $this->addLongOption($option->getName(), null); } } } /** * Parses a long option. * * @param string $token The current token */ private function parseLongOption($token) { $name = substr($token, 2); if (false !== $pos = strpos($name, '=')) { if (0 === strlen($value = substr($name, $pos + 1))) { // if no value after "=" then substr() returns "" since php7 only, false before // see http://php.net/manual/fr/migration70.incompatible.php#119151 if (\PHP_VERSION_ID < 70000 && false === $value) { $value = ''; } array_unshift($this->parsed, $value); } $this->addLongOption(substr($name, 0, $pos), $value); } else { $this->addLongOption($name, null); } } /** * Parses an argument. * * @param string $token The current token * * @throws RuntimeException When too many arguments are given */ private function parseArgument($token) { $c = count($this->arguments); // if input is expecting another argument, add it if ($this->definition->hasArgument($c)) { $arg = $this->definition->getArgument($c); $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token; // if last argument isArray(), append token to last argument } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { $arg = $this->definition->getArgument($c - 1); $this->arguments[$arg->getName()][] = $token; // unexpected argument } else { $all = $this->definition->getArguments(); if (count($all)) { throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)))); } throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token)); } } /** * Adds a short option value. * * @param string $shortcut The short option key * @param mixed $value The value for the option * * @throws RuntimeException When option given doesn't exist */ private function addShortOption($shortcut, $value) { if (!$this->definition->hasShortcut($shortcut)) { throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); } /** * Adds a long option value. * * @param string $name The long option key * @param mixed $value The value for the option * * @throws RuntimeException When option given doesn't exist */ private function addLongOption($name, $value) { if (!$this->definition->hasOption($name)) { throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name)); } $option = $this->definition->getOption($name); if (null !== $value && !$option->acceptValue()) { throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name)); } if (in_array($value, array('', null), true) && $option->acceptValue() && count($this->parsed)) { // if option accepts an optional or mandatory argument // let's see if there is one provided $next = array_shift($this->parsed); if ((isset($next[0]) && '-' !== $next[0]) || in_array($next, array('', null), true)) { $value = $next; } else { array_unshift($this->parsed, $next); } } if (null === $value) { if ($option->isValueRequired()) { throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isArray() && !$option->isValueOptional()) { $value = true; } } if ($option->isArray()) { $this->options[$name][] = $value; } else { $this->options[$name] = $value; } } /** * {@inheritdoc} */ public function getFirstArgument() { foreach ($this->tokens as $token) { if ($token && '-' === $token[0]) { continue; } return $token; } } /** * {@inheritdoc} */ public function hasParameterOption($values, $onlyParams = false) { $values = (array) $values; foreach ($this->tokens as $token) { if ($onlyParams && '--' === $token) { return false; } foreach ($values as $value) { // Options with values: // For long options, test for '--option=' at beginning // For short options, test for '-o' at beginning $leading = 0 === strpos($value, '--') ? $value.'=' : $value; if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) { return true; } } } return false; } /** * {@inheritdoc} */ public function getParameterOption($values, $default = false, $onlyParams = false) { $values = (array) $values; $tokens = $this->tokens; while (0 < count($tokens)) { $token = array_shift($tokens); if ($onlyParams && '--' === $token) { return false; } foreach ($values as $value) { if ($token === $value) { return array_shift($tokens); } // Options with values: // For long options, test for '--option=' at beginning // For short options, test for '-o' at beginning $leading = 0 === strpos($value, '--') ? $value.'=' : $value; if ('' !== $leading && 0 === strpos($token, $leading)) { return substr($token, strlen($leading)); } } } return $default; } /** * Returns a stringified representation of the args passed to the command. * * @return string */ public function __toString() { $tokens = array_map(function ($token) { if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { return $match[1].$this->escapeToken($match[2]); } if ($token && '-' !== $token[0]) { return $this->escapeToken($token); } return $token; }, $this->tokens); return implode(' ', $tokens); } } symfony-3.4.6/src/Symfony/Component/Console/Input/ArrayInput.php000066400000000000000000000127151324732107100247430ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\InvalidOptionException; /** * ArrayInput represents an input provided as an array. * * Usage: * * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); * * @author Fabien Potencier */ class ArrayInput extends Input { private $parameters; public function __construct(array $parameters, InputDefinition $definition = null) { $this->parameters = $parameters; parent::__construct($definition); } /** * {@inheritdoc} */ public function getFirstArgument() { foreach ($this->parameters as $key => $value) { if ($key && '-' === $key[0]) { continue; } return $value; } } /** * {@inheritdoc} */ public function hasParameterOption($values, $onlyParams = false) { $values = (array) $values; foreach ($this->parameters as $k => $v) { if (!is_int($k)) { $v = $k; } if ($onlyParams && '--' === $v) { return false; } if (in_array($v, $values)) { return true; } } return false; } /** * {@inheritdoc} */ public function getParameterOption($values, $default = false, $onlyParams = false) { $values = (array) $values; foreach ($this->parameters as $k => $v) { if ($onlyParams && ('--' === $k || (is_int($k) && '--' === $v))) { return false; } if (is_int($k)) { if (in_array($v, $values)) { return true; } } elseif (in_array($k, $values)) { return $v; } } return $default; } /** * Returns a stringified representation of the args passed to the command. * * @return string */ public function __toString() { $params = array(); foreach ($this->parameters as $param => $val) { if ($param && '-' === $param[0]) { if (is_array($val)) { foreach ($val as $v) { $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : ''); } } else { $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); } } else { $params[] = is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val); } } return implode(' ', $params); } /** * {@inheritdoc} */ protected function parse() { foreach ($this->parameters as $key => $value) { if ('--' === $key) { return; } if (0 === strpos($key, '--')) { $this->addLongOption(substr($key, 2), $value); } elseif ('-' === $key[0]) { $this->addShortOption(substr($key, 1), $value); } else { $this->addArgument($key, $value); } } } /** * Adds a short option value. * * @param string $shortcut The short option key * @param mixed $value The value for the option * * @throws InvalidOptionException When option given doesn't exist */ private function addShortOption($shortcut, $value) { if (!$this->definition->hasShortcut($shortcut)) { throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); } /** * Adds a long option value. * * @param string $name The long option key * @param mixed $value The value for the option * * @throws InvalidOptionException When option given doesn't exist * @throws InvalidOptionException When a required value is missing */ private function addLongOption($name, $value) { if (!$this->definition->hasOption($name)) { throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name)); } $option = $this->definition->getOption($name); if (null === $value) { if ($option->isValueRequired()) { throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isValueOptional()) { $value = true; } } $this->options[$name] = $value; } /** * Adds an argument value. * * @param string $name The argument name * @param mixed $value The value for the argument * * @throws InvalidArgumentException When argument given doesn't exist */ private function addArgument($name, $value) { if (!$this->definition->hasArgument($name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } $this->arguments[$name] = $value; } } symfony-3.4.6/src/Symfony/Component/Console/Input/Input.php000066400000000000000000000116031324732107100237370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; /** * Input is the base class for all concrete Input classes. * * Three concrete classes are provided by default: * * * `ArgvInput`: The input comes from the CLI arguments (argv) * * `StringInput`: The input is provided as a string * * `ArrayInput`: The input is provided as an array * * @author Fabien Potencier */ abstract class Input implements InputInterface, StreamableInputInterface { protected $definition; protected $stream; protected $options = array(); protected $arguments = array(); protected $interactive = true; public function __construct(InputDefinition $definition = null) { if (null === $definition) { $this->definition = new InputDefinition(); } else { $this->bind($definition); $this->validate(); } } /** * {@inheritdoc} */ public function bind(InputDefinition $definition) { $this->arguments = array(); $this->options = array(); $this->definition = $definition; $this->parse(); } /** * Processes command line arguments. */ abstract protected function parse(); /** * {@inheritdoc} */ public function validate() { $definition = $this->definition; $givenArguments = $this->arguments; $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) { return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired(); }); if (count($missingArguments) > 0) { throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments))); } } /** * {@inheritdoc} */ public function isInteractive() { return $this->interactive; } /** * {@inheritdoc} */ public function setInteractive($interactive) { $this->interactive = (bool) $interactive; } /** * {@inheritdoc} */ public function getArguments() { return array_merge($this->definition->getArgumentDefaults(), $this->arguments); } /** * {@inheritdoc} */ public function getArgument($name) { if (!$this->definition->hasArgument($name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); } /** * {@inheritdoc} */ public function setArgument($name, $value) { if (!$this->definition->hasArgument($name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } $this->arguments[$name] = $value; } /** * {@inheritdoc} */ public function hasArgument($name) { return $this->definition->hasArgument($name); } /** * {@inheritdoc} */ public function getOptions() { return array_merge($this->definition->getOptionDefaults(), $this->options); } /** * {@inheritdoc} */ public function getOption($name) { if (!$this->definition->hasOption($name)) { throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); } return array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); } /** * {@inheritdoc} */ public function setOption($name, $value) { if (!$this->definition->hasOption($name)) { throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); } $this->options[$name] = $value; } /** * {@inheritdoc} */ public function hasOption($name) { return $this->definition->hasOption($name); } /** * Escapes a token through escapeshellarg if it contains unsafe chars. * * @param string $token * * @return string */ public function escapeToken($token) { return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); } /** * {@inheritdoc} */ public function setStream($stream) { $this->stream = $stream; } /** * {@inheritdoc} */ public function getStream() { return $this->stream; } } symfony-3.4.6/src/Symfony/Component/Console/Input/InputArgument.php000066400000000000000000000063741324732107100254530ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * Represents a command line argument. * * @author Fabien Potencier */ class InputArgument { const REQUIRED = 1; const OPTIONAL = 2; const IS_ARRAY = 4; private $name; private $mode; private $default; private $description; /** * @param string $name The argument name * @param int $mode The argument mode: self::REQUIRED or self::OPTIONAL * @param string $description A description text * @param mixed $default The default value (for self::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid */ public function __construct($name, $mode = null, $description = '', $default = null) { if (null === $mode) { $mode = self::OPTIONAL; } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); } $this->name = $name; $this->mode = $mode; $this->description = $description; $this->setDefault($default); } /** * Returns the argument name. * * @return string The argument name */ public function getName() { return $this->name; } /** * Returns true if the argument is required. * * @return bool true if parameter mode is self::REQUIRED, false otherwise */ public function isRequired() { return self::REQUIRED === (self::REQUIRED & $this->mode); } /** * Returns true if the argument can take multiple values. * * @return bool true if mode is self::IS_ARRAY, false otherwise */ public function isArray() { return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); } /** * Sets the default value. * * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ public function setDefault($default = null) { if (self::REQUIRED === $this->mode && null !== $default) { throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); } if ($this->isArray()) { if (null === $default) { $default = array(); } elseif (!is_array($default)) { throw new LogicException('A default value for an array argument must be an array.'); } } $this->default = $default; } /** * Returns the default value. * * @return mixed The default value */ public function getDefault() { return $this->default; } /** * Returns the description text. * * @return string The description text */ public function getDescription() { return $this->description; } } symfony-3.4.6/src/Symfony/Component/Console/Input/InputAwareInterface.php000066400000000000000000000011361324732107100265400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; /** * InputAwareInterface should be implemented by classes that depends on the * Console Input. * * @author Wouter J */ interface InputAwareInterface { /** * Sets the Console Input. * * @param InputInterface */ public function setInput(InputInterface $input); } symfony-3.4.6/src/Symfony/Component/Console/Input/InputDefinition.php000066400000000000000000000260011324732107100257460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * A InputDefinition represents a set of valid command line arguments and options. * * Usage: * * $definition = new InputDefinition(array( * new InputArgument('name', InputArgument::REQUIRED), * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), * )); * * @author Fabien Potencier */ class InputDefinition { private $arguments; private $requiredCount; private $hasAnArrayArgument = false; private $hasOptional; private $options; private $shortcuts; /** * @param array $definition An array of InputArgument and InputOption instance */ public function __construct(array $definition = array()) { $this->setDefinition($definition); } /** * Sets the definition of the input. */ public function setDefinition(array $definition) { $arguments = array(); $options = array(); foreach ($definition as $item) { if ($item instanceof InputOption) { $options[] = $item; } else { $arguments[] = $item; } } $this->setArguments($arguments); $this->setOptions($options); } /** * Sets the InputArgument objects. * * @param InputArgument[] $arguments An array of InputArgument objects */ public function setArguments($arguments = array()) { $this->arguments = array(); $this->requiredCount = 0; $this->hasOptional = false; $this->hasAnArrayArgument = false; $this->addArguments($arguments); } /** * Adds an array of InputArgument objects. * * @param InputArgument[] $arguments An array of InputArgument objects */ public function addArguments($arguments = array()) { if (null !== $arguments) { foreach ($arguments as $argument) { $this->addArgument($argument); } } } /** * @throws LogicException When incorrect argument is given */ public function addArgument(InputArgument $argument) { if (isset($this->arguments[$argument->getName()])) { throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName())); } if ($this->hasAnArrayArgument) { throw new LogicException('Cannot add an argument after an array argument.'); } if ($argument->isRequired() && $this->hasOptional) { throw new LogicException('Cannot add a required argument after an optional one.'); } if ($argument->isArray()) { $this->hasAnArrayArgument = true; } if ($argument->isRequired()) { ++$this->requiredCount; } else { $this->hasOptional = true; } $this->arguments[$argument->getName()] = $argument; } /** * Returns an InputArgument by name or by position. * * @param string|int $name The InputArgument name or position * * @return InputArgument An InputArgument object * * @throws InvalidArgumentException When argument given doesn't exist */ public function getArgument($name) { if (!$this->hasArgument($name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; return $arguments[$name]; } /** * Returns true if an InputArgument object exists by name or position. * * @param string|int $name The InputArgument name or position * * @return bool true if the InputArgument object exists, false otherwise */ public function hasArgument($name) { $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; return isset($arguments[$name]); } /** * Gets the array of InputArgument objects. * * @return InputArgument[] An array of InputArgument objects */ public function getArguments() { return $this->arguments; } /** * Returns the number of InputArguments. * * @return int The number of InputArguments */ public function getArgumentCount() { return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); } /** * Returns the number of required InputArguments. * * @return int The number of required InputArguments */ public function getArgumentRequiredCount() { return $this->requiredCount; } /** * Gets the default values. * * @return array An array of default values */ public function getArgumentDefaults() { $values = array(); foreach ($this->arguments as $argument) { $values[$argument->getName()] = $argument->getDefault(); } return $values; } /** * Sets the InputOption objects. * * @param InputOption[] $options An array of InputOption objects */ public function setOptions($options = array()) { $this->options = array(); $this->shortcuts = array(); $this->addOptions($options); } /** * Adds an array of InputOption objects. * * @param InputOption[] $options An array of InputOption objects */ public function addOptions($options = array()) { foreach ($options as $option) { $this->addOption($option); } } /** * @throws LogicException When option given already exist */ public function addOption(InputOption $option) { if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName())); } if ($option->getShortcut()) { foreach (explode('|', $option->getShortcut()) as $shortcut) { if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) { throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut)); } } } $this->options[$option->getName()] = $option; if ($option->getShortcut()) { foreach (explode('|', $option->getShortcut()) as $shortcut) { $this->shortcuts[$shortcut] = $option->getName(); } } } /** * Returns an InputOption by name. * * @param string $name The InputOption name * * @return InputOption A InputOption object * * @throws InvalidArgumentException When option given doesn't exist */ public function getOption($name) { if (!$this->hasOption($name)) { throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); } return $this->options[$name]; } /** * Returns true if an InputOption object exists by name. * * This method can't be used to check if the user included the option when * executing the command (use getOption() instead). * * @param string $name The InputOption name * * @return bool true if the InputOption object exists, false otherwise */ public function hasOption($name) { return isset($this->options[$name]); } /** * Gets the array of InputOption objects. * * @return InputOption[] An array of InputOption objects */ public function getOptions() { return $this->options; } /** * Returns true if an InputOption object exists by shortcut. * * @param string $name The InputOption shortcut * * @return bool true if the InputOption object exists, false otherwise */ public function hasShortcut($name) { return isset($this->shortcuts[$name]); } /** * Gets an InputOption by shortcut. * * @param string $shortcut The Shortcut name * * @return InputOption An InputOption object */ public function getOptionForShortcut($shortcut) { return $this->getOption($this->shortcutToName($shortcut)); } /** * Gets an array of default values. * * @return array An array of all default values */ public function getOptionDefaults() { $values = array(); foreach ($this->options as $option) { $values[$option->getName()] = $option->getDefault(); } return $values; } /** * Returns the InputOption name given a shortcut. * * @param string $shortcut The shortcut * * @return string The InputOption name * * @throws InvalidArgumentException When option given does not exist */ private function shortcutToName($shortcut) { if (!isset($this->shortcuts[$shortcut])) { throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); } return $this->shortcuts[$shortcut]; } /** * Gets the synopsis. * * @param bool $short Whether to return the short version (with options folded) or not * * @return string The synopsis */ public function getSynopsis($short = false) { $elements = array(); if ($short && $this->getOptions()) { $elements[] = '[options]'; } elseif (!$short) { foreach ($this->getOptions() as $option) { $value = ''; if ($option->acceptValue()) { $value = sprintf( ' %s%s%s', $option->isValueOptional() ? '[' : '', strtoupper($option->getName()), $option->isValueOptional() ? ']' : '' ); } $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value); } } if (count($elements) && $this->getArguments()) { $elements[] = '[--]'; } foreach ($this->getArguments() as $argument) { $element = '<'.$argument->getName().'>'; if (!$argument->isRequired()) { $element = '['.$element.']'; } elseif ($argument->isArray()) { $element = $element.' ('.$element.')'; } if ($argument->isArray()) { $element .= '...'; } $elements[] = $element; } return implode(' ', $elements); } } symfony-3.4.6/src/Symfony/Component/Console/Input/InputInterface.php000066400000000000000000000114571324732107100255670ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; /** * InputInterface is the interface implemented by all input classes. * * @author Fabien Potencier */ interface InputInterface { /** * Returns the first argument from the raw parameters (not parsed). * * @return string|null The value of the first argument or null otherwise */ public function getFirstArgument(); /** * Returns true if the raw parameters (not parsed) contain a value. * * This method is to be used to introspect the input parameters * before they have been validated. It must be used carefully. * Does not necessarily return the correct result for short options * when multiple flags are combined in the same option. * * @param string|array $values The values to look for in the raw parameters (can be an array) * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal * * @return bool true if the value is contained in the raw parameters */ public function hasParameterOption($values, $onlyParams = false); /** * Returns the value of a raw option (not parsed). * * This method is to be used to introspect the input parameters * before they have been validated. It must be used carefully. * Does not necessarily return the correct result for short options * when multiple flags are combined in the same option. * * @param string|array $values The value(s) to look for in the raw parameters (can be an array) * @param mixed $default The default value to return if no result is found * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal * * @return mixed The option value */ public function getParameterOption($values, $default = false, $onlyParams = false); /** * Binds the current Input instance with the given arguments and options. */ public function bind(InputDefinition $definition); /** * Validates the input. * * @throws RuntimeException When not enough arguments are given */ public function validate(); /** * Returns all the given arguments merged with the default values. * * @return array */ public function getArguments(); /** * Returns the argument value for a given argument name. * * @param string $name The argument name * * @return mixed The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ public function getArgument($name); /** * Sets an argument value by name. * * @param string $name The argument name * @param string $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ public function setArgument($name, $value); /** * Returns true if an InputArgument object exists by name or position. * * @param string|int $name The InputArgument name or position * * @return bool true if the InputArgument object exists, false otherwise */ public function hasArgument($name); /** * Returns all the given options merged with the default values. * * @return array */ public function getOptions(); /** * Returns the option value for a given option name. * * @param string $name The option name * * @return mixed The option value * * @throws InvalidArgumentException When option given doesn't exist */ public function getOption($name); /** * Sets an option value by name. * * @param string $name The option name * @param string|bool $value The option value * * @throws InvalidArgumentException When option given doesn't exist */ public function setOption($name, $value); /** * Returns true if an InputOption object exists by name. * * @param string $name The InputOption name * * @return bool true if the InputOption object exists, false otherwise */ public function hasOption($name); /** * Is this input means interactive? * * @return bool */ public function isInteractive(); /** * Sets the input interactivity. * * @param bool $interactive If the input should be interactive */ public function setInteractive($interactive); } symfony-3.4.6/src/Symfony/Component/Console/Input/InputOption.php000066400000000000000000000134411324732107100251320ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * Represents a command line option. * * @author Fabien Potencier */ class InputOption { const VALUE_NONE = 1; const VALUE_REQUIRED = 2; const VALUE_OPTIONAL = 4; const VALUE_IS_ARRAY = 8; private $name; private $shortcut; private $mode; private $default; private $description; /** * @param string $name The option name * @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts * @param int $mode The option mode: One of the VALUE_* constants * @param string $description A description text * @param mixed $default The default value (must be null for self::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible */ public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) { if (0 === strpos($name, '--')) { $name = substr($name, 2); } if (empty($name)) { throw new InvalidArgumentException('An option name cannot be empty.'); } if (empty($shortcut)) { $shortcut = null; } if (null !== $shortcut) { if (is_array($shortcut)) { $shortcut = implode('|', $shortcut); } $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-')); $shortcuts = array_filter($shortcuts); $shortcut = implode('|', $shortcuts); if (empty($shortcut)) { throw new InvalidArgumentException('An option shortcut cannot be empty.'); } } if (null === $mode) { $mode = self::VALUE_NONE; } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); } $this->name = $name; $this->shortcut = $shortcut; $this->mode = $mode; $this->description = $description; if ($this->isArray() && !$this->acceptValue()) { throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); } $this->setDefault($default); } /** * Returns the option shortcut. * * @return string The shortcut */ public function getShortcut() { return $this->shortcut; } /** * Returns the option name. * * @return string The name */ public function getName() { return $this->name; } /** * Returns true if the option accepts a value. * * @return bool true if value mode is not self::VALUE_NONE, false otherwise */ public function acceptValue() { return $this->isValueRequired() || $this->isValueOptional(); } /** * Returns true if the option requires a value. * * @return bool true if value mode is self::VALUE_REQUIRED, false otherwise */ public function isValueRequired() { return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); } /** * Returns true if the option takes an optional value. * * @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise */ public function isValueOptional() { return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); } /** * Returns true if the option can take multiple values. * * @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise */ public function isArray() { return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); } /** * Sets the default value. * * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ public function setDefault($default = null) { if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); } if ($this->isArray()) { if (null === $default) { $default = array(); } elseif (!is_array($default)) { throw new LogicException('A default value for an array option must be an array.'); } } $this->default = $this->acceptValue() ? $default : false; } /** * Returns the default value. * * @return mixed The default value */ public function getDefault() { return $this->default; } /** * Returns the description text. * * @return string The description text */ public function getDescription() { return $this->description; } /** * Checks whether the given option equals this one. * * @return bool */ public function equals(InputOption $option) { return $option->getName() === $this->getName() && $option->getShortcut() === $this->getShortcut() && $option->getDefault() === $this->getDefault() && $option->isArray() === $this->isArray() && $option->isValueRequired() === $this->isValueRequired() && $option->isValueOptional() === $this->isValueOptional() ; } } symfony-3.4.6/src/Symfony/Component/Console/Input/StreamableInputInterface.php000066400000000000000000000015511324732107100275610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; /** * StreamableInputInterface is the interface implemented by all input classes * that have an input stream. * * @author Robin Chalas */ interface StreamableInputInterface extends InputInterface { /** * Sets the input stream to read from when interacting with the user. * * This is mainly useful for testing purpose. * * @param resource $stream The input stream */ public function setStream($stream); /** * Returns the input stream. * * @return resource|null */ public function getStream(); } symfony-3.4.6/src/Symfony/Component/Console/Input/StringInput.php000066400000000000000000000045201324732107100251260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Input; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * StringInput represents an input provided as a string. * * Usage: * * $input = new StringInput('foo --bar="foobar"'); * * @author Fabien Potencier */ class StringInput extends ArgvInput { const REGEX_STRING = '([^\s]+?)(?:\s|(?setTokens($this->tokenize($input)); } /** * Tokenizes a string. * * @param string $input The input to tokenize * * @return array An array of tokens * * @throws InvalidArgumentException When unable to parse input (should never happen) */ private function tokenize($input) { $tokens = array(); $length = strlen($input); $cursor = 0; while ($cursor < $length) { if (preg_match('/\s+/A', $input, $match, null, $cursor)) { } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2)); } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { $tokens[] = stripcslashes($match[1]); } else { // should never happen throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10))); } $cursor += strlen($match[0]); } return $tokens; } } symfony-3.4.6/src/Symfony/Component/Console/LICENSE000066400000000000000000000020511324732107100220320ustar00rootroot00000000000000Copyright (c) 2004-2018 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. symfony-3.4.6/src/Symfony/Component/Console/Logger/000077500000000000000000000000001324732107100222465ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Logger/ConsoleLogger.php000066400000000000000000000104251324732107100255230ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Logger; use Psr\Log\AbstractLogger; use Psr\Log\InvalidArgumentException; use Psr\Log\LogLevel; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; /** * PSR-3 compliant console logger. * * @author Kévin Dunglas * * @see http://www.php-fig.org/psr/psr-3/ */ class ConsoleLogger extends AbstractLogger { const INFO = 'info'; const ERROR = 'error'; private $output; private $verbosityLevelMap = array( LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL, LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL, LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL, LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL, LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE, LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE, LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG, ); private $formatLevelMap = array( LogLevel::EMERGENCY => self::ERROR, LogLevel::ALERT => self::ERROR, LogLevel::CRITICAL => self::ERROR, LogLevel::ERROR => self::ERROR, LogLevel::WARNING => self::INFO, LogLevel::NOTICE => self::INFO, LogLevel::INFO => self::INFO, LogLevel::DEBUG => self::INFO, ); private $errored = false; public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array()) { $this->output = $output; $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap; $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap; } /** * {@inheritdoc} */ public function log($level, $message, array $context = array()) { if (!isset($this->verbosityLevelMap[$level])) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); } $output = $this->output; // Write to the error output if necessary and available if (self::ERROR === $this->formatLevelMap[$level]) { if ($this->output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->errored = true; } // the if condition check isn't necessary -- it's the same one that $output will do internally anyway. // We only do it for efficiency here as the message formatting is relatively expensive. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) { $output->writeln(sprintf('<%1$s>[%2$s] %3$s', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]); } } /** * Returns true when any messages have been logged at error levels. * * @return bool */ public function hasErrored() { return $this->errored; } /** * Interpolates context values into the message placeholders. * * @author PHP Framework Interoperability Group * * @param string $message * @param array $context * * @return string */ private function interpolate($message, array $context) { if (false === strpos($message, '{')) { return $message; } $replacements = array(); foreach ($context as $key => $val) { if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); } elseif (\is_object($val)) { $replacements["{{$key}}"] = '[object '.\get_class($val).']'; } else { $replacements["{{$key}}"] = '['.\gettype($val).']'; } } return strtr($message, $replacements); } } symfony-3.4.6/src/Symfony/Component/Console/Output/000077500000000000000000000000001324732107100223275ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Output/BufferedOutput.php000066400000000000000000000015101324732107100260000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; /** * @author Jean-François Simon */ class BufferedOutput extends Output { private $buffer = ''; /** * Empties buffer and returns its content. * * @return string */ public function fetch() { $content = $this->buffer; $this->buffer = ''; return $content; } /** * {@inheritdoc} */ protected function doWrite($message, $newline) { $this->buffer .= $message; if ($newline) { $this->buffer .= PHP_EOL; } } } symfony-3.4.6/src/Symfony/Component/Console/Output/ConsoleOutput.php000066400000000000000000000076521324732107100256750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** * ConsoleOutput is the default class for all CLI output. It uses STDOUT and STDERR. * * This class is a convenient wrapper around `StreamOutput` for both STDOUT and STDERR. * * $output = new ConsoleOutput(); * * This is equivalent to: * * $output = new StreamOutput(fopen('php://stdout', 'w')); * $stdErr = new StreamOutput(fopen('php://stderr', 'w')); * * @author Fabien Potencier */ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface { private $stderr; /** * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) { parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); $actualDecorated = $this->isDecorated(); $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); if (null === $decorated) { $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); } } /** * {@inheritdoc} */ public function setDecorated($decorated) { parent::setDecorated($decorated); $this->stderr->setDecorated($decorated); } /** * {@inheritdoc} */ public function setFormatter(OutputFormatterInterface $formatter) { parent::setFormatter($formatter); $this->stderr->setFormatter($formatter); } /** * {@inheritdoc} */ public function setVerbosity($level) { parent::setVerbosity($level); $this->stderr->setVerbosity($level); } /** * {@inheritdoc} */ public function getErrorOutput() { return $this->stderr; } /** * {@inheritdoc} */ public function setErrorOutput(OutputInterface $error) { $this->stderr = $error; } /** * Returns true if current environment supports writing console output to * STDOUT. * * @return bool */ protected function hasStdoutSupport() { return false === $this->isRunningOS400(); } /** * Returns true if current environment supports writing console output to * STDERR. * * @return bool */ protected function hasStderrSupport() { return false === $this->isRunningOS400(); } /** * Checks if current executing environment is IBM iSeries (OS400), which * doesn't properly convert character-encodings between ASCII to EBCDIC. * * @return bool */ private function isRunningOS400() { $checks = array( function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), PHP_OS, ); return false !== stripos(implode(';', $checks), 'OS400'); } /** * @return resource */ private function openOutputStream() { if (!$this->hasStdoutSupport()) { return fopen('php://output', 'w'); } return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w'); } /** * @return resource */ private function openErrorStream() { return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w'); } } symfony-3.4.6/src/Symfony/Component/Console/Output/ConsoleOutputInterface.php000066400000000000000000000013361324732107100275070ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; /** * ConsoleOutputInterface is the interface implemented by ConsoleOutput class. * This adds information about stderr output stream. * * @author Dariusz Górecki */ interface ConsoleOutputInterface extends OutputInterface { /** * Gets the OutputInterface for errors. * * @return OutputInterface */ public function getErrorOutput(); public function setErrorOutput(OutputInterface $error); } symfony-3.4.6/src/Symfony/Component/Console/Output/NullOutput.php000066400000000000000000000041561324732107100252010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** * NullOutput suppresses all output. * * $output = new NullOutput(); * * @author Fabien Potencier * @author Tobias Schultze */ class NullOutput implements OutputInterface { /** * {@inheritdoc} */ public function setFormatter(OutputFormatterInterface $formatter) { // do nothing } /** * {@inheritdoc} */ public function getFormatter() { // to comply with the interface we must return a OutputFormatterInterface return new OutputFormatter(); } /** * {@inheritdoc} */ public function setDecorated($decorated) { // do nothing } /** * {@inheritdoc} */ public function isDecorated() { return false; } /** * {@inheritdoc} */ public function setVerbosity($level) { // do nothing } /** * {@inheritdoc} */ public function getVerbosity() { return self::VERBOSITY_QUIET; } /** * {@inheritdoc} */ public function isQuiet() { return true; } /** * {@inheritdoc} */ public function isVerbose() { return false; } /** * {@inheritdoc} */ public function isVeryVerbose() { return false; } /** * {@inheritdoc} */ public function isDebug() { return false; } /** * {@inheritdoc} */ public function writeln($messages, $options = self::OUTPUT_NORMAL) { // do nothing } /** * {@inheritdoc} */ public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL) { // do nothing } } symfony-3.4.6/src/Symfony/Component/Console/Output/Output.php000066400000000000000000000105731324732107100243460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Formatter\OutputFormatter; /** * Base class for output classes. * * There are five levels of verbosity: * * * normal: no option passed (normal output) * * verbose: -v (more output) * * very verbose: -vv (highly extended output) * * debug: -vvv (all debug output) * * quiet: -q (no output) * * @author Fabien Potencier */ abstract class Output implements OutputInterface { private $verbosity; private $formatter; /** * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) * @param bool $decorated Whether to decorate messages * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null) { $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; $this->formatter = $formatter ?: new OutputFormatter(); $this->formatter->setDecorated($decorated); } /** * {@inheritdoc} */ public function setFormatter(OutputFormatterInterface $formatter) { $this->formatter = $formatter; } /** * {@inheritdoc} */ public function getFormatter() { return $this->formatter; } /** * {@inheritdoc} */ public function setDecorated($decorated) { $this->formatter->setDecorated($decorated); } /** * {@inheritdoc} */ public function isDecorated() { return $this->formatter->isDecorated(); } /** * {@inheritdoc} */ public function setVerbosity($level) { $this->verbosity = (int) $level; } /** * {@inheritdoc} */ public function getVerbosity() { return $this->verbosity; } /** * {@inheritdoc} */ public function isQuiet() { return self::VERBOSITY_QUIET === $this->verbosity; } /** * {@inheritdoc} */ public function isVerbose() { return self::VERBOSITY_VERBOSE <= $this->verbosity; } /** * {@inheritdoc} */ public function isVeryVerbose() { return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; } /** * {@inheritdoc} */ public function isDebug() { return self::VERBOSITY_DEBUG <= $this->verbosity; } /** * {@inheritdoc} */ public function writeln($messages, $options = self::OUTPUT_NORMAL) { $this->write($messages, true, $options); } /** * {@inheritdoc} */ public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL) { $messages = (array) $messages; $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN; $type = $types & $options ?: self::OUTPUT_NORMAL; $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG; $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL; if ($verbosity > $this->getVerbosity()) { return; } foreach ($messages as $message) { switch ($type) { case OutputInterface::OUTPUT_NORMAL: $message = $this->formatter->format($message); break; case OutputInterface::OUTPUT_RAW: break; case OutputInterface::OUTPUT_PLAIN: $message = strip_tags($this->formatter->format($message)); break; } $this->doWrite($message, $newline); } } /** * Writes a message to the output. * * @param string $message A message to write to the output * @param bool $newline Whether to add a newline or not */ abstract protected function doWrite($message, $newline); } symfony-3.4.6/src/Symfony/Component/Console/Output/OutputInterface.php000066400000000000000000000064131324732107100261650ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** * OutputInterface is the interface implemented by all Output classes. * * @author Fabien Potencier */ interface OutputInterface { const VERBOSITY_QUIET = 16; const VERBOSITY_NORMAL = 32; const VERBOSITY_VERBOSE = 64; const VERBOSITY_VERY_VERBOSE = 128; const VERBOSITY_DEBUG = 256; const OUTPUT_NORMAL = 1; const OUTPUT_RAW = 2; const OUTPUT_PLAIN = 4; /** * Writes a message to the output. * * @param string|array $messages The message as an array of lines or a single string * @param bool $newline Whether to add a newline * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL */ public function write($messages, $newline = false, $options = 0); /** * Writes a message to the output and adds a newline at the end. * * @param string|array $messages The message as an array of lines of a single string * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL */ public function writeln($messages, $options = 0); /** * Sets the verbosity of the output. * * @param int $level The level of verbosity (one of the VERBOSITY constants) */ public function setVerbosity($level); /** * Gets the current verbosity of the output. * * @return int The current level of verbosity (one of the VERBOSITY constants) */ public function getVerbosity(); /** * Returns whether verbosity is quiet (-q). * * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise */ public function isQuiet(); /** * Returns whether verbosity is verbose (-v). * * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise */ public function isVerbose(); /** * Returns whether verbosity is very verbose (-vv). * * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise */ public function isVeryVerbose(); /** * Returns whether verbosity is debug (-vvv). * * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise */ public function isDebug(); /** * Sets the decorated flag. * * @param bool $decorated Whether to decorate the messages */ public function setDecorated($decorated); /** * Gets the decorated flag. * * @return bool true if the output will decorate messages, false otherwise */ public function isDecorated(); public function setFormatter(OutputFormatterInterface $formatter); /** * Returns current output formatter instance. * * @return OutputFormatterInterface */ public function getFormatter(); } symfony-3.4.6/src/Symfony/Component/Console/Output/StreamOutput.php000066400000000000000000000065461324732107100255270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** * StreamOutput writes the output to a given stream. * * Usage: * * $output = new StreamOutput(fopen('php://stdout', 'w')); * * As `StreamOutput` can use any stream, you can also use a file: * * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); * * @author Fabien Potencier */ class StreamOutput extends Output { private $stream; /** * @param resource $stream A stream resource * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) * * @throws InvalidArgumentException When first argument is not a real stream */ public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) { if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); } $this->stream = $stream; if (null === $decorated) { $decorated = $this->hasColorSupport(); } parent::__construct($verbosity, $decorated, $formatter); } /** * Gets the stream attached to this StreamOutput instance. * * @return resource A stream resource */ public function getStream() { return $this->stream; } /** * {@inheritdoc} */ protected function doWrite($message, $newline) { if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) { // should never happen throw new RuntimeException('Unable to write output.'); } fflush($this->stream); } /** * Returns true if the stream supports colorization. * * Colorization is disabled if not supported by the stream: * * - Windows != 10.0.10586 without Ansicon, ConEmu or Mintty * - non tty consoles * * @return bool true if the stream supports colorization, false otherwise */ protected function hasColorSupport() { if (DIRECTORY_SEPARATOR === '\\') { return function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($this->stream) || '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); } return function_exists('posix_isatty') && @posix_isatty($this->stream); } } symfony-3.4.6/src/Symfony/Component/Console/Question/000077500000000000000000000000001324732107100226365ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Question/ChoiceQuestion.php000066400000000000000000000117001324732107100262700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Question; use Symfony\Component\Console\Exception\InvalidArgumentException; /** * Represents a choice question. * * @author Fabien Potencier */ class ChoiceQuestion extends Question { private $choices; private $multiselect = false; private $prompt = ' > '; private $errorMessage = 'Value "%s" is invalid'; /** * @param string $question The question to ask to the user * @param array $choices The list of available choices * @param mixed $default The default answer to return */ public function __construct($question, array $choices, $default = null) { if (!$choices) { throw new \LogicException('Choice question must have at least 1 choice available.'); } parent::__construct($question, $default); $this->choices = $choices; $this->setValidator($this->getDefaultValidator()); $this->setAutocompleterValues($choices); } /** * Returns available choices. * * @return array */ public function getChoices() { return $this->choices; } /** * Sets multiselect option. * * When multiselect is set to true, multiple choices can be answered. * * @param bool $multiselect * * @return $this */ public function setMultiselect($multiselect) { $this->multiselect = $multiselect; $this->setValidator($this->getDefaultValidator()); return $this; } /** * Returns whether the choices are multiselect. * * @return bool */ public function isMultiselect() { return $this->multiselect; } /** * Gets the prompt for choices. * * @return string */ public function getPrompt() { return $this->prompt; } /** * Sets the prompt for choices. * * @param string $prompt * * @return $this */ public function setPrompt($prompt) { $this->prompt = $prompt; return $this; } /** * Sets the error message for invalid values. * * The error message has a string placeholder (%s) for the invalid value. * * @param string $errorMessage * * @return $this */ public function setErrorMessage($errorMessage) { $this->errorMessage = $errorMessage; $this->setValidator($this->getDefaultValidator()); return $this; } /** * Returns the default answer validator. * * @return callable */ private function getDefaultValidator() { $choices = $this->choices; $errorMessage = $this->errorMessage; $multiselect = $this->multiselect; $isAssoc = $this->isAssoc($choices); return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) { // Collapse all spaces. $selectedChoices = str_replace(' ', '', $selected); if ($multiselect) { // Check for a separated comma values if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) { throw new InvalidArgumentException(sprintf($errorMessage, $selected)); } $selectedChoices = explode(',', $selectedChoices); } else { $selectedChoices = array($selected); } $multiselectChoices = array(); foreach ($selectedChoices as $value) { $results = array(); foreach ($choices as $key => $choice) { if ($choice === $value) { $results[] = $key; } } if (count($results) > 1) { throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results))); } $result = array_search($value, $choices); if (!$isAssoc) { if (false !== $result) { $result = $choices[$result]; } elseif (isset($choices[$value])) { $result = $choices[$value]; } } elseif (false === $result && isset($choices[$value])) { $result = $value; } if (false === $result) { throw new InvalidArgumentException(sprintf($errorMessage, $value)); } $multiselectChoices[] = (string) $result; } if ($multiselect) { return $multiselectChoices; } return current($multiselectChoices); }; } } symfony-3.4.6/src/Symfony/Component/Console/Question/ConfirmationQuestion.php000066400000000000000000000030341324732107100275270ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Question; /** * Represents a yes/no question. * * @author Fabien Potencier */ class ConfirmationQuestion extends Question { private $trueAnswerRegex; /** * @param string $question The question to ask to the user * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer */ public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') { parent::__construct($question, (bool) $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); } /** * Returns the default answer normalizer. * * @return callable */ private function getDefaultNormalizer() { $default = $this->getDefault(); $regex = $this->trueAnswerRegex; return function ($answer) use ($default, $regex) { if (is_bool($answer)) { return $answer; } $answerIsTrue = (bool) preg_match($regex, $answer); if (false === $default) { return $answer && $answerIsTrue; } return !$answer || $answerIsTrue; }; } } symfony-3.4.6/src/Symfony/Component/Console/Question/Question.php000066400000000000000000000127461324732107100251700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Question; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; /** * Represents a Question. * * @author Fabien Potencier */ class Question { private $question; private $attempts; private $hidden = false; private $hiddenFallback = true; private $autocompleterValues; private $validator; private $default; private $normalizer; /** * @param string $question The question to ask to the user * @param mixed $default The default answer to return if the user enters nothing */ public function __construct($question, $default = null) { $this->question = $question; $this->default = $default; } /** * Returns the question. * * @return string */ public function getQuestion() { return $this->question; } /** * Returns the default answer. * * @return mixed */ public function getDefault() { return $this->default; } /** * Returns whether the user response must be hidden. * * @return bool */ public function isHidden() { return $this->hidden; } /** * Sets whether the user response must be hidden or not. * * @param bool $hidden * * @return $this * * @throws LogicException In case the autocompleter is also used */ public function setHidden($hidden) { if ($this->autocompleterValues) { throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->hidden = (bool) $hidden; return $this; } /** * In case the response can not be hidden, whether to fallback on non-hidden question or not. * * @return bool */ public function isHiddenFallback() { return $this->hiddenFallback; } /** * Sets whether to fallback on non-hidden question if the response can not be hidden. * * @param bool $fallback * * @return $this */ public function setHiddenFallback($fallback) { $this->hiddenFallback = (bool) $fallback; return $this; } /** * Gets values for the autocompleter. * * @return null|iterable */ public function getAutocompleterValues() { return $this->autocompleterValues; } /** * Sets values for the autocompleter. * * @param null|iterable $values * * @return $this * * @throws InvalidArgumentException * @throws LogicException */ public function setAutocompleterValues($values) { if (is_array($values)) { $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values); } if (null !== $values && !is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.'); } if ($this->hidden) { throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->autocompleterValues = $values; return $this; } /** * Sets a validator for the question. * * @param null|callable $validator * * @return $this */ public function setValidator(callable $validator = null) { $this->validator = $validator; return $this; } /** * Gets the validator for the question. * * @return null|callable */ public function getValidator() { return $this->validator; } /** * Sets the maximum number of attempts. * * Null means an unlimited number of attempts. * * @param null|int $attempts * * @return $this * * @throws InvalidArgumentException in case the number of attempts is invalid */ public function setMaxAttempts($attempts) { if (null !== $attempts && $attempts < 1) { throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); } $this->attempts = $attempts; return $this; } /** * Gets the maximum number of attempts. * * Null means an unlimited number of attempts. * * @return null|int */ public function getMaxAttempts() { return $this->attempts; } /** * Sets a normalizer for the response. * * The normalizer can be a callable (a string), a closure or a class implementing __invoke. * * @param callable $normalizer * * @return $this */ public function setNormalizer(callable $normalizer) { $this->normalizer = $normalizer; return $this; } /** * Gets the normalizer for the response. * * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. * * @return callable */ public function getNormalizer() { return $this->normalizer; } protected function isAssoc($array) { return (bool) count(array_filter(array_keys($array), 'is_string')); } } symfony-3.4.6/src/Symfony/Component/Console/README.md000066400000000000000000000012641324732107100223110ustar00rootroot00000000000000Console Component ================= The Console component eases the creation of beautiful and testable command line interfaces. Resources --------- * [Documentation](https://symfony.com/doc/current/components/console/index.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) Credits ------- `Resources/bin/hiddeninput.exe` is a third party binary provided within this component. Find sources and license at https://github.com/Seldaek/hidden-input. symfony-3.4.6/src/Symfony/Component/Console/Resources/000077500000000000000000000000001324732107100230015ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Resources/bin/000077500000000000000000000000001324732107100235515ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Style/000077500000000000000000000000001324732107100221275ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Style/OutputStyle.php000066400000000000000000000057751324732107100251770ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Style; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; /** * Decorates output to add console style guide helpers. * * @author Kevin Bond */ abstract class OutputStyle implements OutputInterface, StyleInterface { private $output; public function __construct(OutputInterface $output) { $this->output = $output; } /** * {@inheritdoc} */ public function newLine($count = 1) { $this->output->write(str_repeat(PHP_EOL, $count)); } /** * @param int $max * * @return ProgressBar */ public function createProgressBar($max = 0) { return new ProgressBar($this->output, $max); } /** * {@inheritdoc} */ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) { $this->output->write($messages, $newline, $type); } /** * {@inheritdoc} */ public function writeln($messages, $type = self::OUTPUT_NORMAL) { $this->output->writeln($messages, $type); } /** * {@inheritdoc} */ public function setVerbosity($level) { $this->output->setVerbosity($level); } /** * {@inheritdoc} */ public function getVerbosity() { return $this->output->getVerbosity(); } /** * {@inheritdoc} */ public function setDecorated($decorated) { $this->output->setDecorated($decorated); } /** * {@inheritdoc} */ public function isDecorated() { return $this->output->isDecorated(); } /** * {@inheritdoc} */ public function setFormatter(OutputFormatterInterface $formatter) { $this->output->setFormatter($formatter); } /** * {@inheritdoc} */ public function getFormatter() { return $this->output->getFormatter(); } /** * {@inheritdoc} */ public function isQuiet() { return $this->output->isQuiet(); } /** * {@inheritdoc} */ public function isVerbose() { return $this->output->isVerbose(); } /** * {@inheritdoc} */ public function isVeryVerbose() { return $this->output->isVeryVerbose(); } /** * {@inheritdoc} */ public function isDebug() { return $this->output->isDebug(); } protected function getErrorOutput() { if (!$this->output instanceof ConsoleOutputInterface) { return $this->output; } return $this->output->getErrorOutput(); } } symfony-3.4.6/src/Symfony/Component/Console/Style/StyleInterface.php000066400000000000000000000061171324732107100255660ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Style; /** * Output style helpers. * * @author Kevin Bond */ interface StyleInterface { /** * Formats a command title. * * @param string $message */ public function title($message); /** * Formats a section title. * * @param string $message */ public function section($message); /** * Formats a list. */ public function listing(array $elements); /** * Formats informational text. * * @param string|array $message */ public function text($message); /** * Formats a success result bar. * * @param string|array $message */ public function success($message); /** * Formats an error result bar. * * @param string|array $message */ public function error($message); /** * Formats an warning result bar. * * @param string|array $message */ public function warning($message); /** * Formats a note admonition. * * @param string|array $message */ public function note($message); /** * Formats a caution admonition. * * @param string|array $message */ public function caution($message); /** * Formats a table. */ public function table(array $headers, array $rows); /** * Asks a question. * * @param string $question * @param string|null $default * @param callable|null $validator * * @return mixed */ public function ask($question, $default = null, $validator = null); /** * Asks a question with the user input hidden. * * @param string $question * @param callable|null $validator * * @return mixed */ public function askHidden($question, $validator = null); /** * Asks for confirmation. * * @param string $question * @param bool $default * * @return bool */ public function confirm($question, $default = true); /** * Asks a choice question. * * @param string $question * @param array $choices * @param string|int|null $default * * @return mixed */ public function choice($question, array $choices, $default = null); /** * Add newline(s). * * @param int $count The number of newlines */ public function newLine($count = 1); /** * Starts the progress output. * * @param int $max Maximum steps (0 if unknown) */ public function progressStart($max = 0); /** * Advances the progress output X steps. * * @param int $step Number of steps to advance */ public function progressAdvance($step = 1); /** * Finishes the progress output. */ public function progressFinish(); } symfony-3.4.6/src/Symfony/Component/Console/Style/SymfonyStyle.php000066400000000000000000000274111324732107100253320ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Style; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Terminal; /** * Output decorator helpers for the Symfony Style Guide. * * @author Kevin Bond */ class SymfonyStyle extends OutputStyle { const MAX_LINE_LENGTH = 120; private $input; private $questionHelper; private $progressBar; private $lineLength; private $bufferedOutput; public function __construct(InputInterface $input, OutputInterface $output) { $this->input = $input; $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter()); // Windows cmd wraps lines as soon as the terminal width is reached, whether there are following chars or not. $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH; $this->lineLength = min($width - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH); parent::__construct($output); } /** * Formats a message as a block of text. * * @param string|array $messages The message to write in the block * @param string|null $type The block type (added in [] on first line) * @param string|null $style The style to apply to the whole block * @param string $prefix The prefix for the block * @param bool $padding Whether to add vertical padding * @param bool $escape Whether to escape the message */ public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = true) { $messages = is_array($messages) ? array_values($messages) : array($messages); $this->autoPrependBlock(); $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape)); $this->newLine(); } /** * {@inheritdoc} */ public function title($message) { $this->autoPrependBlock(); $this->writeln(array( sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))), )); $this->newLine(); } /** * {@inheritdoc} */ public function section($message) { $this->autoPrependBlock(); $this->writeln(array( sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))), )); $this->newLine(); } /** * {@inheritdoc} */ public function listing(array $elements) { $this->autoPrependText(); $elements = array_map(function ($element) { return sprintf(' * %s', $element); }, $elements); $this->writeln($elements); $this->newLine(); } /** * {@inheritdoc} */ public function text($message) { $this->autoPrependText(); $messages = is_array($message) ? array_values($message) : array($message); foreach ($messages as $message) { $this->writeln(sprintf(' %s', $message)); } } /** * Formats a command comment. * * @param string|array $message */ public function comment($message) { $this->block($message, null, null, ' // ', false, false); } /** * {@inheritdoc} */ public function success($message) { $this->block($message, 'OK', 'fg=black;bg=green', ' ', true); } /** * {@inheritdoc} */ public function error($message) { $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true); } /** * {@inheritdoc} */ public function warning($message) { $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true); } /** * {@inheritdoc} */ public function note($message) { $this->block($message, 'NOTE', 'fg=yellow', ' ! '); } /** * {@inheritdoc} */ public function caution($message) { $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true); } /** * {@inheritdoc} */ public function table(array $headers, array $rows) { $style = clone Table::getStyleDefinition('symfony-style-guide'); $style->setCellHeaderFormat('%s'); $table = new Table($this); $table->setHeaders($headers); $table->setRows($rows); $table->setStyle($style); $table->render(); $this->newLine(); } /** * {@inheritdoc} */ public function ask($question, $default = null, $validator = null) { $question = new Question($question, $default); $question->setValidator($validator); return $this->askQuestion($question); } /** * {@inheritdoc} */ public function askHidden($question, $validator = null) { $question = new Question($question); $question->setHidden(true); $question->setValidator($validator); return $this->askQuestion($question); } /** * {@inheritdoc} */ public function confirm($question, $default = true) { return $this->askQuestion(new ConfirmationQuestion($question, $default)); } /** * {@inheritdoc} */ public function choice($question, array $choices, $default = null) { if (null !== $default) { $values = array_flip($choices); $default = $values[$default]; } return $this->askQuestion(new ChoiceQuestion($question, $choices, $default)); } /** * {@inheritdoc} */ public function progressStart($max = 0) { $this->progressBar = $this->createProgressBar($max); $this->progressBar->start(); } /** * {@inheritdoc} */ public function progressAdvance($step = 1) { $this->getProgressBar()->advance($step); } /** * {@inheritdoc} */ public function progressFinish() { $this->getProgressBar()->finish(); $this->newLine(2); $this->progressBar = null; } /** * {@inheritdoc} */ public function createProgressBar($max = 0) { $progressBar = parent::createProgressBar($max); if ('\\' !== DIRECTORY_SEPARATOR) { $progressBar->setEmptyBarCharacter('░'); // light shade character \u2591 $progressBar->setProgressCharacter(''); $progressBar->setBarCharacter('▓'); // dark shade character \u2593 } return $progressBar; } /** * @return mixed */ public function askQuestion(Question $question) { if ($this->input->isInteractive()) { $this->autoPrependBlock(); } if (!$this->questionHelper) { $this->questionHelper = new SymfonyQuestionHelper(); } $answer = $this->questionHelper->ask($this->input, $this, $question); if ($this->input->isInteractive()) { $this->newLine(); $this->bufferedOutput->write("\n"); } return $answer; } /** * {@inheritdoc} */ public function writeln($messages, $type = self::OUTPUT_NORMAL) { parent::writeln($messages, $type); $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type); } /** * {@inheritdoc} */ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) { parent::write($messages, $newline, $type); $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type); } /** * {@inheritdoc} */ public function newLine($count = 1) { parent::newLine($count); $this->bufferedOutput->write(str_repeat("\n", $count)); } /** * Returns a new instance which makes use of stderr if available. * * @return self */ public function getErrorStyle() { return new self($this->input, $this->getErrorOutput()); } /** * @return ProgressBar */ private function getProgressBar() { if (!$this->progressBar) { throw new RuntimeException('The ProgressBar is not started.'); } return $this->progressBar; } private function autoPrependBlock() { $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { return $this->newLine(); //empty history, so we should start with a new line. } //Prepend new line for each non LF chars (This means no blank line was output before) $this->newLine(2 - substr_count($chars, "\n")); } private function autoPrependText() { $fetched = $this->bufferedOutput->fetch(); //Prepend new line if last char isn't EOL: if ("\n" !== substr($fetched, -1)) { $this->newLine(); } } private function reduceBuffer($messages) { // We need to know if the two last chars are PHP_EOL // Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer return array_map(function ($value) { return substr($value, -4); }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages)); } private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false) { $indentLength = 0; $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix); $lines = array(); if (null !== $type) { $type = sprintf('[%s] ', $type); $indentLength = strlen($type); $lineIndentation = str_repeat(' ', $indentLength); } // wrap and add newlines for each element foreach ($messages as $key => $message) { if ($escape) { $message = OutputFormatter::escape($message); } $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true))); if (count($messages) > 1 && $key < count($messages) - 1) { $lines[] = ''; } } $firstLineIndex = 0; if ($padding && $this->isDecorated()) { $firstLineIndex = 1; array_unshift($lines, ''); $lines[] = ''; } foreach ($lines as $i => &$line) { if (null !== $type) { $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line; } $line = $prefix.$line; $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line)); if ($style) { $line = sprintf('<%s>%s', $style, $line); } } return $lines; } } symfony-3.4.6/src/Symfony/Component/Console/Terminal.php000066400000000000000000000076441324732107100233260ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console; class Terminal { private static $width; private static $height; /** * Gets the terminal width. * * @return int */ public function getWidth() { $width = getenv('COLUMNS'); if (false !== $width) { return (int) trim($width); } if (null === self::$width) { self::initDimensions(); } return self::$width ?: 80; } /** * Gets the terminal height. * * @return int */ public function getHeight() { $height = getenv('LINES'); if (false !== $height) { return (int) trim($height); } if (null === self::$height) { self::initDimensions(); } return self::$height ?: 50; } private static function initDimensions() { if ('\\' === DIRECTORY_SEPARATOR) { if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) { // extract [w, H] from "wxh (WxH)" // or [w, h] from "wxh" self::$width = (int) $matches[1]; self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2]; } elseif (null !== $dimensions = self::getConsoleMode()) { // extract [w, h] from "wxh" self::$width = (int) $dimensions[0]; self::$height = (int) $dimensions[1]; } } elseif ($sttyString = self::getSttyColumns()) { if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { // extract [w, h] from "rows h; columns w;" self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) { // extract [w, h] from "; h rows; w columns" self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; } } } /** * Runs and parses mode CON if it's available, suppressing any error output. * * @return int[]|null An array composed of the width and the height or null if it could not be parsed */ private static function getConsoleMode() { if (!function_exists('proc_open')) { return; } $descriptorspec = array( 1 => array('pipe', 'w'), 2 => array('pipe', 'w'), ); $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); if (is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { return array((int) $matches[2], (int) $matches[1]); } } } /** * Runs and parses stty -a if it's available, suppressing any error output. * * @return string|null */ private static function getSttyColumns() { if (!function_exists('proc_open')) { return; } $descriptorspec = array( 1 => array('pipe', 'w'), 2 => array('pipe', 'w'), ); $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); if (is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); return $info; } } } symfony-3.4.6/src/Symfony/Component/Console/Tester/000077500000000000000000000000001324732107100222755ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Tester/ApplicationTester.php000066400000000000000000000130141324732107100264370ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tester; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\StreamOutput; /** * Eases the testing of console applications. * * When testing an application, don't forget to disable the auto exit flag: * * $application = new Application(); * $application->setAutoExit(false); * * @author Fabien Potencier */ class ApplicationTester { private $application; private $input; private $statusCode; /** * @var OutputInterface */ private $output; private $captureStreamsIndependently = false; public function __construct(Application $application) { $this->application = $application; } /** * Executes the application. * * Available options: * * * interactive: Sets the input interactive flag * * decorated: Sets the output decorated flag * * verbosity: Sets the output verbosity flag * * capture_stderr_separately: Make output of stdOut and stdErr separately available * * @param array $input An array of arguments and options * @param array $options An array of options * * @return int The command exit code */ public function run(array $input, $options = array()) { $this->input = new ArrayInput($input); if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); } $this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately']; if (!$this->captureStreamsIndependently) { $this->output = new StreamOutput(fopen('php://memory', 'w', false)); if (isset($options['decorated'])) { $this->output->setDecorated($options['decorated']); } if (isset($options['verbosity'])) { $this->output->setVerbosity($options['verbosity']); } } else { $this->output = new ConsoleOutput( isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null ); $errorOutput = new StreamOutput(fopen('php://memory', 'w', false)); $errorOutput->setFormatter($this->output->getFormatter()); $errorOutput->setVerbosity($this->output->getVerbosity()); $errorOutput->setDecorated($this->output->isDecorated()); $reflectedOutput = new \ReflectionObject($this->output); $strErrProperty = $reflectedOutput->getProperty('stderr'); $strErrProperty->setAccessible(true); $strErrProperty->setValue($this->output, $errorOutput); $reflectedParent = $reflectedOutput->getParentClass(); $streamProperty = $reflectedParent->getProperty('stream'); $streamProperty->setAccessible(true); $streamProperty->setValue($this->output, fopen('php://memory', 'w', false)); } return $this->statusCode = $this->application->run($this->input, $this->output); } /** * Gets the display returned by the last execution of the application. * * @param bool $normalize Whether to normalize end of lines to \n or not * * @return string The display */ public function getDisplay($normalize = false) { rewind($this->output->getStream()); $display = stream_get_contents($this->output->getStream()); if ($normalize) { $display = str_replace(PHP_EOL, "\n", $display); } return $display; } /** * Gets the output written to STDERR by the application. * * @param bool $normalize Whether to normalize end of lines to \n or not * * @return string */ public function getErrorOutput($normalize = false) { if (!$this->captureStreamsIndependently) { throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.'); } rewind($this->output->getErrorOutput()->getStream()); $display = stream_get_contents($this->output->getErrorOutput()->getStream()); if ($normalize) { $display = str_replace(PHP_EOL, "\n", $display); } return $display; } /** * Gets the input instance used by the last execution of the application. * * @return InputInterface The current input instance */ public function getInput() { return $this->input; } /** * Gets the output instance used by the last execution of the application. * * @return OutputInterface The current output instance */ public function getOutput() { return $this->output; } /** * Gets the status code returned by the last execution of the application. * * @return int The status code */ public function getStatusCode() { return $this->statusCode; } } symfony-3.4.6/src/Symfony/Component/Console/Tester/CommandTester.php000066400000000000000000000103051324732107100255520ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tester; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Eases the testing of console commands. * * @author Fabien Potencier * @author Robin Chalas */ class CommandTester { private $command; private $input; private $output; private $inputs = array(); private $statusCode; public function __construct(Command $command) { $this->command = $command; } /** * Executes the command. * * Available execution options: * * * interactive: Sets the input interactive flag * * decorated: Sets the output decorated flag * * verbosity: Sets the output verbosity flag * * @param array $input An array of command arguments and options * @param array $options An array of execution options * * @return int The command exit code */ public function execute(array $input, array $options = array()) { // set the command name automatically if the application requires // this argument and no command name was passed if (!isset($input['command']) && (null !== $application = $this->command->getApplication()) && $application->getDefinition()->hasArgument('command') ) { $input = array_merge(array('command' => $this->command->getName()), $input); } $this->input = new ArrayInput($input); if ($this->inputs) { $this->input->setStream(self::createStream($this->inputs)); } if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); } $this->output = new StreamOutput(fopen('php://memory', 'w', false)); $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false); if (isset($options['verbosity'])) { $this->output->setVerbosity($options['verbosity']); } return $this->statusCode = $this->command->run($this->input, $this->output); } /** * Gets the display returned by the last execution of the command. * * @param bool $normalize Whether to normalize end of lines to \n or not * * @return string The display */ public function getDisplay($normalize = false) { rewind($this->output->getStream()); $display = stream_get_contents($this->output->getStream()); if ($normalize) { $display = str_replace(PHP_EOL, "\n", $display); } return $display; } /** * Gets the input instance used by the last execution of the command. * * @return InputInterface The current input instance */ public function getInput() { return $this->input; } /** * Gets the output instance used by the last execution of the command. * * @return OutputInterface The current output instance */ public function getOutput() { return $this->output; } /** * Gets the status code returned by the last execution of the application. * * @return int The status code */ public function getStatusCode() { return $this->statusCode; } /** * Sets the user inputs. * * @param array $inputs An array of strings representing each input * passed to the command input stream * * @return CommandTester */ public function setInputs(array $inputs) { $this->inputs = $inputs; return $this; } private static function createStream(array $inputs) { $stream = fopen('php://memory', 'r+', false); fwrite($stream, implode(PHP_EOL, $inputs)); rewind($stream); return $stream; } } symfony-3.4.6/src/Symfony/Component/Console/Tests/000077500000000000000000000000001324732107100221315ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Tests/ApplicationTest.php000066400000000000000000002215151324732107100257530ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\CommandLoader\FactoryCommandLoader; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\Output; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Tester\ApplicationTester; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventDispatcher; class ApplicationTest extends TestCase { protected static $fixturesPath; public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__.'/Fixtures/'); require_once self::$fixturesPath.'/FooCommand.php'; require_once self::$fixturesPath.'/FooOptCommand.php'; require_once self::$fixturesPath.'/Foo1Command.php'; require_once self::$fixturesPath.'/Foo2Command.php'; require_once self::$fixturesPath.'/Foo3Command.php'; require_once self::$fixturesPath.'/Foo4Command.php'; require_once self::$fixturesPath.'/Foo5Command.php'; require_once self::$fixturesPath.'/FooSameCaseUppercaseCommand.php'; require_once self::$fixturesPath.'/FooSameCaseLowercaseCommand.php'; require_once self::$fixturesPath.'/FoobarCommand.php'; require_once self::$fixturesPath.'/BarBucCommand.php'; require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; require_once self::$fixturesPath.'/TestTiti.php'; require_once self::$fixturesPath.'/TestToto.php'; } protected function normalizeLineBreaks($text) { return str_replace(PHP_EOL, "\n", $text); } /** * Replaces the dynamic placeholders of the command help text with a static version. * The placeholder %command.full_name% includes the script path that is not predictable * and can not be tested against. */ protected function ensureStaticCommandHelp(Application $application) { foreach ($application->all() as $command) { $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp())); } } public function testConstructor() { $application = new Application('foo', 'bar'); $this->assertEquals('foo', $application->getName(), '__construct() takes the application name as its first argument'); $this->assertEquals('bar', $application->getVersion(), '__construct() takes the application version as its second argument'); $this->assertEquals(array('help', 'list'), array_keys($application->all()), '__construct() registered the help and list commands by default'); } public function testSetGetName() { $application = new Application(); $application->setName('foo'); $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application'); } public function testSetGetVersion() { $application = new Application(); $application->setVersion('bar'); $this->assertEquals('bar', $application->getVersion(), '->setVersion() sets the version of the application'); } public function testGetLongVersion() { $application = new Application('foo', 'bar'); $this->assertEquals('foo bar', $application->getLongVersion(), '->getLongVersion() returns the long version of the application'); } public function testHelp() { $application = new Application(); $this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); } public function testAll() { $application = new Application(); $commands = $application->all(); $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); $application->add(new \FooCommand()); $commands = $application->all('foo'); $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); } public function testAllWithCommandLoader() { $application = new Application(); $commands = $application->all(); $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); $application->add(new \FooCommand()); $commands = $application->all('foo'); $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); $application->setCommandLoader(new FactoryCommandLoader(array( 'foo:bar1' => function () { return new \Foo1Command(); }, ))); $commands = $application->all('foo'); $this->assertCount(2, $commands, '->all() takes a namespace as its first argument'); $this->assertInstanceOf(\FooCommand::class, $commands['foo:bar'], '->all() returns the registered commands'); $this->assertInstanceOf(\Foo1Command::class, $commands['foo:bar1'], '->all() returns the registered commands'); } public function testRegister() { $application = new Application(); $command = $application->register('foo'); $this->assertEquals('foo', $command->getName(), '->register() registers a new command'); } public function testAdd() { $application = new Application(); $application->add($foo = new \FooCommand()); $commands = $application->all(); $this->assertEquals($foo, $commands['foo:bar'], '->add() registers a command'); $application = new Application(); $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command())); $commands = $application->all(); $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands'); } /** * @expectedException \LogicException * @expectedExceptionMessage Command class "Foo5Command" is not correctly initialized. You probably forgot to call the parent constructor. */ public function testAddCommandWithEmptyConstructor() { $application = new Application(); $application->add(new \Foo5Command()); } public function testHasGet() { $application = new Application(); $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered'); $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered'); $application->add($foo = new \FooCommand()); $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered'); $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); $application = new Application(); $application->add($foo = new \FooCommand()); // simulate --help $r = new \ReflectionObject($application); $p = $r->getProperty('wantHelps'); $p->setAccessible(true); $p->setValue($application, true); $command = $application->get('foo:bar'); $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); } public function testHasGetWithCommandLoader() { $application = new Application(); $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered'); $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered'); $application->add($foo = new \FooCommand()); $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered'); $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); $application->setCommandLoader(new FactoryCommandLoader(array( 'foo:bar1' => function () { return new \Foo1Command(); }, ))); $this->assertTrue($application->has('afoobar'), '->has() returns true if an instance is registered for an alias even with command loader'); $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns an instance by name even with command loader'); $this->assertEquals($foo, $application->get('afoobar'), '->get() returns an instance by alias even with command loader'); $this->assertTrue($application->has('foo:bar1'), '->has() returns true for commands registered in the loader'); $this->assertInstanceOf(\Foo1Command::class, $foo1 = $application->get('foo:bar1'), '->get() returns a command by name from the command loader'); $this->assertTrue($application->has('afoobar1'), '->has() returns true for commands registered in the loader'); $this->assertEquals($foo1, $application->get('afoobar1'), '->get() returns a command by name from the command loader'); } public function testSilentHelp() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array('-h' => true, '-q' => true), array('decorated' => false)); $this->assertEmpty($tester->getDisplay(true)); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage The command "foofoo" does not exist. */ public function testGetInvalidCommand() { $application = new Application(); $application->get('foofoo'); } public function testGetNamespaces() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $this->assertEquals(array('foo'), $application->getNamespaces(), '->getNamespaces() returns an array of unique used namespaces'); } public function testFindNamespace() { $application = new Application(); $application->add(new \FooCommand()); $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); $application->add(new \Foo2Command()); $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); } public function testFindNamespaceWithSubnamespaces() { $application = new Application(); $application->add(new \FooSubnamespaced1Command()); $application->add(new \FooSubnamespaced2Command()); $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns commands even if the commands are only contained in subnamespaces'); } public function testFindAmbiguousNamespace() { $application = new Application(); $application->add(new \BarBucCommand()); $application->add(new \FooCommand()); $application->add(new \Foo2Command()); $expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1"; if (method_exists($this, 'expectException')) { $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage($expectedMsg); } else { $this->setExpectedException(CommandNotFoundException::class, $expectedMsg); } $application->findNamespace('f'); } public function testFindNonAmbiguous() { $application = new Application(); $application->add(new \TestTiti()); $application->add(new \TestToto()); $this->assertEquals('test-toto', $application->find('test')->getName()); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage There are no commands defined in the "bar" namespace. */ public function testFindInvalidNamespace() { $application = new Application(); $application->findNamespace('bar'); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage Command "foo1" is not defined */ public function testFindUniqueNameButNamespaceName() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); $application->find($commandName = 'foo1'); } public function testFind() { $application = new Application(); $application->add(new \FooCommand()); $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); } public function testFindCaseSensitiveFirst() { $application = new Application(); $application->add(new \FooSameCaseUppercaseCommand()); $application->add(new \FooSameCaseLowercaseCommand()); $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:B'), '->find() returns a command if the abbreviation is the correct case'); $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:BAR'), '->find() returns a command if the abbreviation is the correct case'); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation is the correct case'); } public function testFindCaseInsensitiveAsFallback() { $application = new Application(); $application->add(new \FooSameCaseLowercaseCommand()); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:B'), '->find() will fallback to case insensitivity'); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will fallback to case insensitivity'); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage Command "FoO:BaR" is ambiguous */ public function testFindCaseInsensitiveSuggestions() { $application = new Application(); $application->add(new \FooSameCaseLowercaseCommand()); $application->add(new \FooSameCaseUppercaseCommand()); $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will find two suggestions with case insensitivity'); } public function testFindWithCommandLoader() { $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader(array( 'foo:bar' => $f = function () { return new \FooCommand(); }, ))); $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); } /** * @dataProvider provideAmbiguousAbbreviations */ public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) { if (method_exists($this, 'expectException')) { $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); $this->expectExceptionMessage($expectedExceptionMessage); } else { $this->setExpectedException('Symfony\Component\Console\Exception\CommandNotFoundException', $expectedExceptionMessage); } $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); $application->find($abbreviation); } public function provideAmbiguousAbbreviations() { return array( array('f', 'Command "f" is not defined.'), array( 'a', "Command \"a\" is ambiguous.\nDid you mean one of these?\n". " afoobar The foo:bar command\n". " afoobar1 The foo:bar1 command\n". ' afoobar2 The foo1:bar command', ), array( 'foo:b', "Command \"foo:b\" is ambiguous.\nDid you mean one of these?\n". " foo:bar The foo:bar command\n". " foo:bar1 The foo:bar1 command\n". ' foo1:bar The foo1:bar command', ), ); } public function testFindCommandEqualNamespace() { $application = new Application(); $application->add(new \Foo3Command()); $application->add(new \Foo4Command()); $this->assertInstanceOf('Foo3Command', $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); $this->assertInstanceOf('Foo4Command', $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); } public function testFindCommandWithAmbiguousNamespacesButUniqueName() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \FoobarCommand()); $this->assertInstanceOf('FoobarCommand', $application->find('f:f')); } public function testFindCommandWithMissingNamespace() { $application = new Application(); $application->add(new \Foo4Command()); $this->assertInstanceOf('Foo4Command', $application->find('f::t')); } /** * @dataProvider provideInvalidCommandNamesSingle * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage Did you mean this */ public function testFindAlternativeExceptionMessageSingle($name) { $application = new Application(); $application->add(new \Foo3Command()); $application->find($name); } public function provideInvalidCommandNamesSingle() { return array( array('foo3:barr'), array('fooo3:bar'), ); } public function testFindAlternativeExceptionMessageMultiple() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); // Command + plural try { $application->find('foo:baR'); $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertRegExp('/foo1:bar/', $e->getMessage()); $this->assertRegExp('/foo:bar/', $e->getMessage()); } // Namespace + plural try { $application->find('foo2:bar'); $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertRegExp('/foo1/', $e->getMessage()); } $application->add(new \Foo3Command()); $application->add(new \Foo4Command()); // Subnamespace + plural try { $a = $application->find('foo3:'); $this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e); $this->assertRegExp('/foo3:bar/', $e->getMessage()); $this->assertRegExp('/foo3:bar:toh/', $e->getMessage()); } } public function testFindAlternativeCommands() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); try { $application->find($commandName = 'Unknown command'); $this->fail('->find() throws a CommandNotFoundException if command does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); $this->assertSame(array(), $e->getAlternatives()); $this->assertEquals(sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives'); } // Test if "bar1" command throw a "CommandNotFoundException" and does not contain // "foo:bar" as alternative because "bar1" is too far from "foo:bar" try { $application->find($commandName = 'bar1'); $this->fail('->find() throws a CommandNotFoundException if command does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); $this->assertSame(array('afoobar1', 'foo:bar1'), $e->getAlternatives()); $this->assertRegExp(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertRegExp('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"'); $this->assertRegExp('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"'); $this->assertNotRegExp('/foo:bar(?>!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative'); } } public function testFindAlternativeCommandsWithAnAlias() { $fooCommand = new \FooCommand(); $fooCommand->setAliases(array('foo2')); $application = new Application(); $application->add($fooCommand); $result = $application->find('foo'); $this->assertSame($fooCommand, $result); } public function testFindAlternativeNamespace() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); $application->add(new \Foo3Command()); try { $application->find('Unknown-namespace:Unknown-command'); $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist'); $this->assertSame(array(), $e->getAlternatives()); $this->assertEquals('There are no commands defined in the "Unknown-namespace" namespace.', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, without alternatives'); } try { $application->find('foo2:command'); $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist'); $this->assertCount(3, $e->getAlternatives()); $this->assertContains('foo', $e->getAlternatives()); $this->assertContains('foo1', $e->getAlternatives()); $this->assertContains('foo3', $e->getAlternatives()); $this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative'); $this->assertRegExp('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"'); $this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"'); $this->assertRegExp('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"'); } } public function testFindAlternativesOutput() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); $application->add(new \Foo3Command()); $expectedAlternatives = array( 'afoobar', 'afoobar1', 'afoobar2', 'foo1:bar', 'foo3:bar', 'foo:bar', 'foo:bar1', ); try { $application->find('foo'); $this->fail('->find() throws a CommandNotFoundException if command is not defined'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command is not defined'); $this->assertSame($expectedAlternatives, $e->getAlternatives()); $this->assertRegExp('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage()); } } public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() { $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock(); $application->expects($this->once()) ->method('getNamespaces') ->will($this->returnValue(array('foo:sublong', 'bar:sub'))); $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException * @expectedExceptionMessage Command "foo::bar" is not defined. */ public function testFindWithDoubleColonInNameThrowsException() { $application = new Application(); $application->add(new \FooCommand()); $application->add(new \Foo4Command()); $application->find('foo::bar'); } public function testSetCatchExceptions() { $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=120'); $tester = new ApplicationTester($application); $application->setCatchExceptions(true); $this->assertTrue($application->areExceptionsCaught()); $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getErrorOutput(true), '->setCatchExceptions() sets the catch exception flag'); $this->assertSame('', $tester->getDisplay(true)); $application->setCatchExceptions(false); try { $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->fail('->setCatchExceptions() sets the catch exception flag'); } catch (\Exception $e) { $this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag'); $this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag'); } } public function testAutoExitSetting() { $application = new Application(); $this->assertTrue($application->isAutoExitEnabled()); $application->setAutoExit(false); $this->assertFalse($application->isAutoExitEnabled()); } public function testRenderException() { $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=120'); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exception'); $tester->run(array('command' => 'foo'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE, 'capture_stderr_separately' => true)); $this->assertContains('Exception trace', $tester->getErrorOutput(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); $tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getErrorOutput(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); $application->add(new \Foo3Command()); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo3:bar'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); $tester->run(array('command' => 'foo3:bar'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); $this->assertRegExp('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose'); $this->assertRegExp('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose'); $this->assertRegExp('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose'); $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); $tester->run(array('command' => 'foo3:bar'), array('decorated' => true, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=32'); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getErrorOutput(true), '->renderException() wraps messages when they are bigger than the terminal'); putenv('COLUMNS=120'); } public function testRenderExceptionWithDoubleWidthCharacters() { $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=120'); $application->register('foo')->setCode(function () { throw new \Exception('エラーメッセージ'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); $tester->run(array('command' => 'foo'), array('decorated' => true, 'capture_stderr_separately' => true)); $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=32'); $application->register('foo')->setCode(function () { throw new \Exception('コマンドの実行中にエラーが発生しました。'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getErrorOutput(true), '->renderException() wraps messages when they are bigger than the terminal'); putenv('COLUMNS=120'); } public function testRenderExceptionEscapesLines() { $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=22'); $application->register('foo')->setCode(function () { throw new \Exception('dont break here !'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_escapeslines.txt', $tester->getDisplay(true), '->renderException() escapes lines containing formatting'); putenv('COLUMNS=120'); } public function testRenderExceptionLineBreaks() { $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') ->will($this->returnValue(120)); $application->register('foo')->setCode(function () { throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_linebreaks.txt', $tester->getDisplay(true), '->renderException() keep multiple line breaks'); } public function testRun() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add($command = new \Foo1Command()); $_SERVER['argv'] = array('cli.php', 'foo:bar1'); ob_start(); $application->run(); ob_end_clean(); $this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given'); $this->assertInstanceOf('Symfony\Component\Console\Output\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $this->ensureStaticCommandHelp($application); $tester = new ApplicationTester($application); $tester->run(array(), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); $tester->run(array('--help' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); $tester->run(array('-h' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); $tester->run(array('--ansi' => true)); $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed'); $tester->run(array('--no-ansi' => true)); $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed'); $tester->run(array('--version' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); $tester->run(array('-V' => true), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); $tester->run(array('command' => 'list', '--quiet' => true)); $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed'); $tester->run(array('command' => 'list', '-q' => true)); $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed'); $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed'); $tester->run(array('command' => 'list', '--verbose' => true)); $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed'); $tester->run(array('command' => 'list', '--verbose' => 1)); $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose=1 is passed'); $tester->run(array('command' => 'list', '--verbose' => 2)); $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to very verbose if --verbose=2 is passed'); $tester->run(array('command' => 'list', '--verbose' => 3)); $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to debug if --verbose=3 is passed'); $tester->run(array('command' => 'list', '--verbose' => 4)); $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if unknown --verbose level is passed'); $tester->run(array('command' => 'list', '-v' => true)); $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); $tester->run(array('command' => 'list', '-vv' => true)); $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); $tester->run(array('command' => 'list', '-vvv' => true)); $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add(new \FooCommand()); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false)); $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false)); $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); } /** * Issue #9285. * * If the "verbose" option is just before an argument in ArgvInput, * an argument value should not be treated as verbosity value. * This test will fail with "Not enough arguments." if broken */ public function testVerboseValueNotBreakArguments() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add(new \FooCommand()); $output = new StreamOutput(fopen('php://memory', 'w', false)); $input = new ArgvInput(array('cli.php', '-v', 'foo:bar')); $application->run($input, $output); $this->addToAssertionCount(1); $input = new ArgvInput(array('cli.php', '--verbose', 'foo:bar')); $application->run($input, $output); $this->addToAssertionCount(1); } public function testRunReturnsIntegerExitCode() { $exception = new \Exception('', 4); $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') ->will($this->throwException($exception)); $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); $this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception'); } public function testRunReturnsExitCodeOneForExceptionCodeZero() { $exception = new \Exception('', 0); $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') ->will($this->throwException($exception)); $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); $this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0'); } /** * @expectedException \LogicException * @expectedExceptionMessage An option with shortcut "e" already exists. */ public function testAddingOptionWithDuplicateShortcut() { $dispatcher = new EventDispatcher(); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->setDispatcher($dispatcher); $application->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'Environment')); $application ->register('foo') ->setAliases(array('f')) ->setDefinition(array(new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.'))) ->setCode(function (InputInterface $input, OutputInterface $output) {}) ; $input = new ArrayInput(array('command' => 'foo')); $output = new NullOutput(); $application->run($input, $output); } /** * @expectedException \LogicException * @dataProvider getAddingAlreadySetDefinitionElementData */ public function testAddingAlreadySetDefinitionElementData($def) { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application ->register('foo') ->setDefinition(array($def)) ->setCode(function (InputInterface $input, OutputInterface $output) {}) ; $input = new ArrayInput(array('command' => 'foo')); $output = new NullOutput(); $application->run($input, $output); } public function getAddingAlreadySetDefinitionElementData() { return array( array(new InputArgument('command', InputArgument::REQUIRED)), array(new InputOption('quiet', '', InputOption::VALUE_NONE)), array(new InputOption('query', 'q', InputOption::VALUE_NONE)), ); } public function testGetDefaultHelperSetReturnsDefaultValues() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $helperSet = $application->getHelperSet(); $this->assertTrue($helperSet->has('formatter')); } public function testAddingSingleHelperSetOverwritesDefaultValues() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->setHelperSet(new HelperSet(array(new FormatterHelper()))); $helperSet = $application->getHelperSet(); $this->assertTrue($helperSet->has('formatter')); // no other default helper set should be returned $this->assertFalse($helperSet->has('dialog')); $this->assertFalse($helperSet->has('progress')); } public function testOverwritingDefaultHelperSetOverwritesDefaultValues() { $application = new CustomApplication(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->setHelperSet(new HelperSet(array(new FormatterHelper()))); $helperSet = $application->getHelperSet(); $this->assertTrue($helperSet->has('formatter')); // no other default helper set should be returned $this->assertFalse($helperSet->has('dialog')); $this->assertFalse($helperSet->has('progress')); } public function testGetDefaultInputDefinitionReturnsDefaultValues() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $inputDefinition = $application->getDefinition(); $this->assertTrue($inputDefinition->hasArgument('command')); $this->assertTrue($inputDefinition->hasOption('help')); $this->assertTrue($inputDefinition->hasOption('quiet')); $this->assertTrue($inputDefinition->hasOption('verbose')); $this->assertTrue($inputDefinition->hasOption('version')); $this->assertTrue($inputDefinition->hasOption('ansi')); $this->assertTrue($inputDefinition->hasOption('no-ansi')); $this->assertTrue($inputDefinition->hasOption('no-interaction')); } public function testOverwritingDefaultInputDefinitionOverwritesDefaultValues() { $application = new CustomApplication(); $application->setAutoExit(false); $application->setCatchExceptions(false); $inputDefinition = $application->getDefinition(); // check whether the default arguments and options are not returned any more $this->assertFalse($inputDefinition->hasArgument('command')); $this->assertFalse($inputDefinition->hasOption('help')); $this->assertFalse($inputDefinition->hasOption('quiet')); $this->assertFalse($inputDefinition->hasOption('verbose')); $this->assertFalse($inputDefinition->hasOption('version')); $this->assertFalse($inputDefinition->hasOption('ansi')); $this->assertFalse($inputDefinition->hasOption('no-ansi')); $this->assertFalse($inputDefinition->hasOption('no-interaction')); $this->assertTrue($inputDefinition->hasOption('custom')); } public function testSettingCustomInputDefinitionOverwritesDefaultValues() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->setDefinition(new InputDefinition(array(new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.')))); $inputDefinition = $application->getDefinition(); // check whether the default arguments and options are not returned any more $this->assertFalse($inputDefinition->hasArgument('command')); $this->assertFalse($inputDefinition->hasOption('help')); $this->assertFalse($inputDefinition->hasOption('quiet')); $this->assertFalse($inputDefinition->hasOption('verbose')); $this->assertFalse($inputDefinition->hasOption('version')); $this->assertFalse($inputDefinition->hasOption('ansi')); $this->assertFalse($inputDefinition->hasOption('no-ansi')); $this->assertFalse($inputDefinition->hasOption('no-interaction')); $this->assertTrue($inputDefinition->hasOption('custom')); } public function testRunWithDispatcher() { $application = new Application(); $application->setAutoExit(false); $application->setDispatcher($this->getDispatcher()); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); $this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay()); } /** * @expectedException \LogicException * @expectedExceptionMessage error */ public function testRunWithExceptionAndDispatcher() { $application = new Application(); $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { throw new \RuntimeException('foo'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); } public function testRunDispatchesAllEventsWithException() { $application = new Application(); $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); throw new \RuntimeException('foo'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); $this->assertContains('before.foo.error.after.', $tester->getDisplay()); } public function testRunDispatchesAllEventsWithExceptionInListener() { $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.command', function () { throw new \RuntimeException('foo'); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); $this->assertContains('before.error.after.', $tester->getDisplay()); } /** * @requires PHP 7 */ public function testRunWithError() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); }); $tester = new ApplicationTester($application); try { $tester->run(array('command' => 'dym')); $this->fail('Error expected.'); } catch (\Error $e) { $this->assertSame('dymerr', $e->getMessage()); } } public function testRunAllowsErrorListenersToSilenceTheException() { $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { $event->getOutput()->write('silenced.'); $event->setExitCode(0); }); $dispatcher->addListener('console.command', function () { throw new \RuntimeException('foo'); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); $this->assertContains('before.error.silenced.after.', $tester->getDisplay()); $this->assertEquals(ConsoleCommandEvent::RETURN_CODE_DISABLED, $tester->getStatusCode()); } public function testConsoleErrorEventIsTriggeredOnCommandNotFound() { $dispatcher = new EventDispatcher(); $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { $this->assertNull($event->getCommand()); $this->assertInstanceOf(CommandNotFoundException::class, $event->getError()); $event->getOutput()->write('silenced command not found'); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'unknown')); $this->assertContains('silenced command not found', $tester->getDisplay()); $this->assertEquals(1, $tester->getStatusCode()); } /** * @group legacy * @expectedDeprecation The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead. */ public function testLegacyExceptionListenersAreStillTriggered() { $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { $event->getOutput()->write('caught.'); $event->setException(new \RuntimeException('replaced in caught.')); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { throw new \RuntimeException('foo'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); $this->assertContains('before.caught.error.after.', $tester->getDisplay()); $this->assertContains('replaced in caught.', $tester->getDisplay()); } /** * @requires PHP 7 */ public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent() { $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->setDispatcher(new EventDispatcher()); $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { new \UnknownClass(); }); $tester = new ApplicationTester($application); try { $tester->run(array('command' => 'dym')); $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); } catch (\Error $e) { $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); } } /** * @requires PHP 7 * @expectedException \LogicException * @expectedExceptionMessage error */ public function testRunWithErrorAndDispatcher() { $application = new Application(); $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'dym')); $this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); } /** * @requires PHP 7 */ public function testRunDispatchesAllEventsWithError() { $application = new Application(); $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'dym')); $this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); } /** * @requires PHP 7 */ public function testRunWithErrorFailingStatusCode() { $application = new Application(); $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('dus.'); throw new \Error('duserr'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'dus')); $this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1'); } public function testRunWithDispatcherSkippingCommand() { $application = new Application(); $application->setDispatcher($this->getDispatcher(true)); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $exitCode = $tester->run(array('command' => 'foo')); $this->assertContains('before.after.', $tester->getDisplay()); $this->assertEquals(ConsoleCommandEvent::RETURN_CODE_DISABLED, $exitCode); } public function testRunWithDispatcherAccessingInputOptions() { $noInteractionValue = null; $quietValue = null; $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { $input = $event->getInput(); $noInteractionValue = $input->getOption('no-interaction'); $quietValue = $input->getOption('quiet'); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo', '--no-interaction' => true)); $this->assertTrue($noInteractionValue); $this->assertFalse($quietValue); } public function testRunWithDispatcherAddingInputOptions() { $extraValue = null; $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { $definition = $event->getCommand()->getDefinition(); $input = $event->getInput(); $definition->addOption(new InputOption('extra', null, InputOption::VALUE_REQUIRED)); $input->bind($definition); $extraValue = $input->getOption('extra'); }); $application = new Application(); $application->setDispatcher($dispatcher); $application->setAutoExit(false); $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo', '--extra' => 'some test value')); $this->assertEquals('some test value', $extraValue); } /** * @group legacy */ public function testTerminalDimensions() { $application = new Application(); $originalDimensions = $application->getTerminalDimensions(); $this->assertCount(2, $originalDimensions); $width = 80; if ($originalDimensions[0] == $width) { $width = 100; } $application->setTerminalDimensions($width, 80); $this->assertSame(array($width, 80), $application->getTerminalDimensions()); } public function testSetRunCustomDefaultCommand() { $command = new \FooCommand(); $application = new Application(); $application->setAutoExit(false); $application->add($command); $application->setDefaultCommand($command->getName()); $tester = new ApplicationTester($application); $tester->run(array(), array('interactive' => false)); $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); $application = new CustomDefaultCommandApplication(); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array(), array('interactive' => false)); $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomDefaultCommandWithOption() { $command = new \FooOptCommand(); $application = new Application(); $application->setAutoExit(false); $application->add($command); $application->setDefaultCommand($command->getName()); $tester = new ApplicationTester($application); $tester->run(array('--fooopt' => 'opt'), array('interactive' => false)); $this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomSingleCommand() { $command = new \FooCommand(); $application = new Application(); $application->setAutoExit(false); $application->add($command); $application->setDefaultCommand($command->getName(), true); $tester = new ApplicationTester($application); $tester->run(array()); $this->assertContains('called', $tester->getDisplay()); $tester->run(array('--help' => true)); $this->assertContains('The foo:bar command', $tester->getDisplay()); } /** * @requires function posix_isatty */ public function testCanCheckIfTerminalIsInteractive() { $application = new CustomDefaultCommandApplication(); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'help')); $this->assertFalse($tester->getInput()->hasParameterOption(array('--no-interaction', '-n'))); $inputStream = $tester->getInput()->getStream(); $this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream)); } public function testRunLazyCommandService() { $container = new ContainerBuilder(); $container->addCompilerPass(new AddConsoleCommandPass()); $container ->register('lazy-command', LazyCommand::class) ->addTag('console.command', array('command' => 'lazy:command')) ->addTag('console.command', array('command' => 'lazy:alias')) ->addTag('console.command', array('command' => 'lazy:alias2')); $container->compile(); $application = new Application(); $application->setCommandLoader($container->get('console.command_loader')); $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'lazy:command')); $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); $tester->run(array('command' => 'lazy:alias')); $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); $tester->run(array('command' => 'lazy:alias2')); $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); $command = $application->get('lazy:command'); $this->assertSame(array('lazy:alias', 'lazy:alias2'), $command->getAliases()); } /** * @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException */ public function testGetDisabledLazyCommand() { $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); $application->get('disabled'); } public function testHasReturnsFalseForDisabledLazyCommand() { $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); $this->assertFalse($application->has('disabled')); } public function testAllExcludesDisabledLazyCommand() { $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); $this->assertArrayNotHasKey('disabled', $application->all()); } protected function getDispatcher($skipCommand = false) { $dispatcher = new EventDispatcher(); $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { $event->getOutput()->write('before.'); if ($skipCommand) { $event->disableCommand(); } }); $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { $event->getOutput()->writeln('after.'); if (!$skipCommand) { $event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED); } }); $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { $event->getOutput()->write('error.'); $event->setError(new \LogicException('error.', $event->getExitCode(), $event->getError())); }); return $dispatcher; } /** * @requires PHP 7 */ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled() { $application = new Application(); $application->setAutoExit(false); $application->setDispatcher(new EventDispatcher()); $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { new \UnknownClass(); }); $tester = new ApplicationTester($application); try { $tester->run(array('command' => 'dym')); $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); } catch (\Error $e) { $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); } } protected function tearDown() { putenv('SHELL_VERBOSITY'); unset($_ENV['SHELL_VERBOSITY']); unset($_SERVER['SHELL_VERBOSITY']); } } class CustomApplication extends Application { /** * Overwrites the default input definition. * * @return InputDefinition An InputDefinition instance */ protected function getDefaultInputDefinition() { return new InputDefinition(array(new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.'))); } /** * Gets the default helper set with the helpers that should always be available. * * @return HelperSet A HelperSet instance */ protected function getDefaultHelperSet() { return new HelperSet(array(new FormatterHelper())); } } class CustomDefaultCommandApplication extends Application { /** * Overwrites the constructor in order to set a different default command. */ public function __construct() { parent::__construct(); $command = new \FooCommand(); $this->add($command); $this->setDefaultCommand($command->getName()); } } class LazyCommand extends Command { public function execute(InputInterface $input, OutputInterface $output) { $output->writeln('lazy-command called'); } } class DisabledCommand extends Command { public function isEnabled() { return false; } } symfony-3.4.6/src/Symfony/Component/Console/Tests/Command/000077500000000000000000000000001324732107100235075ustar00rootroot00000000000000symfony-3.4.6/src/Symfony/Component/Console/Tests/Command/CommandTest.php000066400000000000000000000431451324732107100264450ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Tester\CommandTester; class CommandTest extends TestCase { protected static $fixturesPath; public static function setUpBeforeClass() { self::$fixturesPath = __DIR__.'/../Fixtures/'; require_once self::$fixturesPath.'/TestCommand.php'; } public function testConstructor() { $command = new Command('foo:bar'); $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); } /** * @expectedException \LogicException * @expectedExceptionMessage The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name. */ public function testCommandNameCannotBeEmpty() { (new Application())->add(new Command()); } public function testSetApplication() { $application = new Application(); $command = new \TestCommand(); $command->setApplication($application); $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); $this->assertEquals($application->getHelperSet(), $command->getHelperSet()); } public function testSetApplicationNull() { $command = new \TestCommand(); $command->setApplication(null); $this->assertNull($command->getHelperSet()); } public function testSetGetDefinition() { $command = new \TestCommand(); $ret = $command->setDefinition($definition = new InputDefinition()); $this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface'); $this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance'); $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $command->setDefinition(new InputDefinition()); } public function testAddArgument() { $command = new \TestCommand(); $ret = $command->addArgument('foo'); $this->assertEquals($command, $ret, '->addArgument() implements a fluent interface'); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); } public function testAddOption() { $command = new \TestCommand(); $ret = $command->addOption('foo'); $this->assertEquals($command, $ret, '->addOption() implements a fluent interface'); $this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); } public function testSetHidden() { $command = new \TestCommand(); $command->setHidden(true); $this->assertTrue($command->isHidden()); } public function testGetNamespaceGetNameSetName() { $command = new \TestCommand(); $this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name'); $command->setName('foo'); $this->assertEquals('foo', $command->getName(), '->setName() sets the command name'); $ret = $command->setName('foobar:bar'); $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); } /** * @dataProvider provideInvalidCommandNames */ public function testInvalidCommandNames($name) { if (method_exists($this, 'expectException')) { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name)); } else { $this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name)); } $command = new \TestCommand(); $command->setName($name); } public function provideInvalidCommandNames() { return array( array(''), array('foo:'), ); } public function testGetSetDescription() { $command = new \TestCommand(); $this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description'); $ret = $command->setDescription('description1'); $this->assertEquals($command, $ret, '->setDescription() implements a fluent interface'); $this->assertEquals('description1', $command->getDescription(), '->setDescription() sets the description'); } public function testGetSetHelp() { $command = new \TestCommand(); $this->assertEquals('help', $command->getHelp(), '->getHelp() returns the help'); $ret = $command->setHelp('help1'); $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); $command->setHelp(''); $this->assertEquals('', $command->getHelp(), '->getHelp() does not fall back to the description'); } public function testGetProcessedHelp() { $command = new \TestCommand(); $command->setHelp('The %command.name% command does... Example: php %command.full_name%.'); $this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly'); $this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%'); $command = new \TestCommand(); $command->setHelp(''); $this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description'); } public function testGetSetAliases() { $command = new \TestCommand(); $this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases'); $ret = $command->setAliases(array('name1')); $this->assertEquals($command, $ret, '->setAliases() implements a fluent interface'); $this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases'); } public function testSetAliasesNull() { $command = new \TestCommand(); $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException'); $command->setAliases(null); } public function testGetSynopsis() { $command = new \TestCommand(); $command->addOption('foo'); $command->addArgument('bar'); $this->assertEquals('namespace:name [--foo] [--] []', $command->getSynopsis(), '->getSynopsis() returns the synopsis'); } public function testAddGetUsages() { $command = new \TestCommand(); $command->addUsage('foo1'); $command->addUsage('foo2'); $this->assertContains('namespace:name foo1', $command->getUsages()); $this->assertContains('namespace:name foo2', $command->getUsages()); } public function testGetHelper() { $application = new Application(); $command = new \TestCommand(); $command->setApplication($application); $formatterHelper = new FormatterHelper(); $this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper'); } /** * @expectedException \LogicException * @expectedExceptionMessage Cannot retrieve helper "formatter" because there is no HelperSet defined. */ public function testGetHelperWithoutHelperSet() { $command = new \TestCommand(); $command->getHelper('formatter'); } public function testMergeApplicationDefinition() { $application1 = new Application(); $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); $application1->getDefinition()->addOptions(array(new InputOption('bar'))); $command = new \TestCommand(); $command->setApplication($application1); $command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo')))); $r = new \ReflectionObject($command); $m = $r->getMethod('mergeApplicationDefinition'); $m->setAccessible(true); $m->invoke($command); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); $this->assertTrue($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); $this->assertTrue($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options'); $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); $m->invoke($command); $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); } public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs() { $application1 = new Application(); $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); $application1->getDefinition()->addOptions(array(new InputOption('bar'))); $command = new \TestCommand(); $command->setApplication($application1); $command->setDefinition($definition = new InputDefinition(array())); $r = new \ReflectionObject($command); $m = $r->getMethod('mergeApplicationDefinition'); $m->setAccessible(true); $m->invoke($command, false); $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the command options'); $this->assertFalse($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments'); $m->invoke($command, true); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments'); $m->invoke($command); $this->assertEquals(2, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments'); } public function testRunInteractive() { $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => true)); $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); } public function testRunNonInteractive() { $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => false)); $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); } /** * @expectedException \LogicException * @expectedExceptionMessage You must override the execute() method in the concrete command class. */ public function testExecuteMethodNeedsToBeOverridden() { $command = new Command('foo'); $command->run(new StringInput(''), new NullOutput()); } /** * @expectedException \Symfony\Component\Console\Exception\InvalidOptionException * @expectedExceptionMessage The "--bar" option does not exist. */ public function testRunWithInvalidOption() { $command = new \TestCommand(); $tester = new CommandTester($command); $tester->execute(array('--bar' => true)); } public function testRunReturnsIntegerExitCode() { $command = new \TestCommand(); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); $command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock(); $command->expects($this->once()) ->method('execute') ->will($this->returnValue('2.3')); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); } public function testRunWithApplication() { $command = new \TestCommand(); $command->setApplication(new Application()); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(0, $exitCode, '->run() returns an integer exit code'); } public function testRunReturnsAlwaysInteger() { $command = new \TestCommand(); $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); } public function testRunWithProcessTitle() { $command = new \TestCommand(); $command->setApplication(new Application()); $command->setProcessTitle('foo'); $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); if (function_exists('cli_set_process_title')) { if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); } $this->assertEquals('foo', cli_get_process_title()); } } public function testSetCode() { $command = new \TestCommand(); $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { $output->writeln('from the code...'); }); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute(array()); $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); } public function getSetCodeBindToClosureTests() { return array( array(true, 'not bound to the command'), array(false, 'bound to the command'), ); } /** * @dataProvider getSetCodeBindToClosureTests */ public function testSetCodeBindToClosure($previouslyBound, $expected) { $code = createClosure(); if ($previouslyBound) { $code = $code->bindTo($this); } $command = new \TestCommand(); $command->setCode($code); $tester = new CommandTester($command); $tester->execute(array()); $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); } public function testSetCodeWithStaticClosure() { $command = new \TestCommand(); $command->setCode(self::createClosure()); $tester = new CommandTester($command); $tester->execute(array()); if (\PHP_VERSION_ID < 70000) { // Cannot bind static closures in PHP 5 $this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay()); } else { // Can bind static closures in PHP 7 $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); } } private static function createClosure() { return function (InputInterface $input, OutputInterface $output) { $output->writeln(isset($this) ? 'bound' : 'not bound'); }; } public function testSetCodeWithNonClosureCallable() { $command = new \TestCommand(); $ret = $command->setCode(array($this, 'callableMethodCommand')); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute(array()); $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); } public function callableMethodCommand(InputInterface $input, OutputInterface $output) { $output->writeln('from the code...'); } } // In order to get an unbound closure, we should create it outside a class // scope. function createClosure() { return function (InputInterface $input, OutputInterface $output) { $output->writeln($this instanceof Command ? 'bound to the command' : 'not bound to the command'); }; } symfony-3.4.6/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php000066400000000000000000000070721324732107100272550ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\ListCommand; use Symfony\Component\Console\Application; class HelpCommandTest extends TestCase { public function testExecuteForCommandAlias() { $command = new HelpCommand(); $command->setApplication(new Application()); $commandTester = new CommandTester($command); $commandTester->execute(array('command_name' => 'li'), array('decorated' => false)); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); } public function testExecuteForCommand() { $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array(), array('decorated' => false)); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); } public function testExecuteForCommandWithXmlOption() { $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array('--format' => 'xml')); $this->assertContains('getDisplay(), '->execute() returns an XML help text if --xml is passed'); } public function testExecuteForApplicationCommand() { $application = new Application(); $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list')); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); } public function testExecuteForApplicationCommandWithXmlOption() { $application = new Application(); $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list', '--format' => 'xml')); $this->assertContains('list [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('getDisplay(), '->execute() returns an XML help text if --format=xml is passed'); } } symfony-3.4.6/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php000066400000000000000000000100521324732107100272700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Application; class ListCommandTest extends TestCase { public function testExecuteListsCommands() { $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); $this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); } public function testExecuteListsCommandsWithXmlOption() { $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--format' => 'xml')); $this->assertRegExp('/