diff --git a/.gitattributes b/.gitattributes index 7fc6b668..10f4cebc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ -examples/ export-ignore -test/ export-ignore +tests/ export-ignore var/ export-ignore .* export-ignore Makefile export-ignore diff --git a/.gitignore b/.gitignore index 48e8e05b..06b9bba8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ package.xml /vendor .idea .php_cs.cache +.phpunit.result.cache docs/_build var +tests/clover.xml diff --git a/.php_cs b/.php_cs deleted file mode 100644 index b7416a83..00000000 --- a/.php_cs +++ /dev/null @@ -1,79 +0,0 @@ -setRiskyAllowed(true); -$config->setRules([ - '@PSR2' => true, - 'array_syntax' => [ - 'syntax' => 'short', - ], - 'binary_operator_spaces' => [ - 'align_double_arrow' => false, - 'align_equals' => false, - ], - 'blank_line_after_namespace' => true, - 'blank_line_after_opening_tag' => true, - 'blank_line_before_statement' => ['statements' => ['return']], - 'concat_space' => ['spacing' => 'one'], - 'function_typehint_space' => true, - 'lowercase_cast' => true, - 'method_separation' => true, - 'native_function_casing' => true, - 'new_with_braces' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => [ - 'tokens' => [ - 'curly_brace_block', - 'extra', - 'parenthesis_brace_block', - 'square_brace_block', - 'throw', - 'use', - ], - ], - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_short_bool_cast' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unneeded_control_parentheses' => true, - 'no_unused_imports' => true, - 'no_whitespace_before_comma_in_array' => true, - 'no_whitespace_in_blank_line' => true, - 'normalize_index_brace' => true, - 'not_operator_with_successor_space' => true, - 'object_operator_without_whitespace' => true, - 'ordered_imports' => true, - 'php_unit_construct' => true, - 'php_unit_dedicate_assert' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_trim' => true, - 'pre_increment' => true, - 'psr4' => true, - 'random_api_migration' => true, - 'self_accessor' => true, - 'short_scalar_cast' => true, - 'single_blank_line_before_namespace' => true, - 'single_class_element_per_statement' => true, - 'single_quote' => true, - 'space_after_semicolon' => true, - 'standardize_not_equals' => true, - 'ternary_operator_spaces' => true, - 'trailing_comma_in_multiline_array' => true, - 'trim_array_spaces' => true, - 'unary_operator_spaces' => true, - 'whitespace_after_comma_in_array' => true, -]); - -$finder = PhpCsFixer\Finder::create(); -$finder->in([ - 'src', - 'test', -]); - -$config->setFinder($finder); - -return $config; diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 00000000..8da7956b --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,36 @@ +setRules([ + '@PSR2' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + 'array_syntax' => ['syntax' => 'short'], + 'concat_space' => ['spacing' => 'one'], + 'ordered_imports' => [ + 'imports_order' => ['class', 'function', 'const'], + ], + 'declare_strict_types' => true, + 'psr0' => true, + 'psr4' => true, + 'random_api_migration' => true, + 'yoda_style' => true, + 'self_accessor' => false, + 'phpdoc_no_useless_inheritdoc' => false, + 'phpdoc_to_comment' => false, + 'phpdoc_align' => [ + 'tags' => ['param', 'return', 'throws', 'type', 'var'], + ], + 'phpdoc_line_span' => [ + 'const' => 'multi', + 'method' => 'multi', + 'property' => 'multi', + ], + ]) + ->setRiskyAllowed(true) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__) + ->exclude(['var']) + ) +; diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a643ac2..a72c8901 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ - Support the XML format for the bundle configuration (#401) - PHP 8 support (#399, thanks to @Yozhef) - Retrieve the request from the `RequestStack` when using the `RequestIntegration` integration (#361) - +- Reorganize the folder structure and change CS standard (#405) + ## 3.5.3 (2020-10-13) - Refactors and fixes class aliases for more robustness (#315 #359, thanks to @guilliamxavier) diff --git a/composer.json b/composer.json index e7631e82..dff85cdf 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ }, "autoload-dev": { "psr-4": { - "Sentry\\SentryBundle\\Test\\": "test" + "Sentry\\SentryBundle\\Tests\\": "tests/" } }, "scripts": { diff --git a/examples/symfony-3/.gitignore b/examples/symfony-3/.gitignore deleted file mode 100644 index 93821ad1..00000000 --- a/examples/symfony-3/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/app/config/parameters.yml -/build/ -/phpunit.xml -/var/* -!/var/cache -/var/cache/* -!var/cache/.gitkeep -!/var/logs -/var/logs/* -!var/logs/.gitkeep -!/var/sessions -/var/sessions/* -!var/sessions/.gitkeep -!var/SymfonyRequirements.php -/vendor/ -/web/bundles/ diff --git a/examples/symfony-3/LICENSE b/examples/symfony-3/LICENSE deleted file mode 100644 index 12a74531..00000000 --- a/examples/symfony-3/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2016 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. diff --git a/examples/symfony-3/Makefile b/examples/symfony-3/Makefile deleted file mode 100644 index b486573c..00000000 --- a/examples/symfony-3/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -symlink-sdk: - mkdir -p vendor/sentry - rm -rf vendor/sentry/sentry-symfony - cd vendor/sentry && ln -sf ../../../.. sentry-symfony - - rm -rf vendor/sentry/sentry - cd vendor/sentry && ln -sf ../../../../../sentry-php sentry diff --git a/examples/symfony-3/README.md b/examples/symfony-3/README.md deleted file mode 100644 index 0efff28b..00000000 --- a/examples/symfony-3/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Running this example: - -``` -# Run webserver -php bin/console server:run -``` diff --git a/examples/symfony-3/app/.htaccess b/examples/symfony-3/app/.htaccess deleted file mode 100644 index fb1de45b..00000000 --- a/examples/symfony-3/app/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ - - Require all denied - - - Order deny,allow - Deny from all - diff --git a/examples/symfony-3/app/AppCache.php b/examples/symfony-3/app/AppCache.php deleted file mode 100644 index 639ec2cd..00000000 --- a/examples/symfony-3/app/AppCache.php +++ /dev/null @@ -1,7 +0,0 @@ -getEnvironment(), ['dev', 'test'], true)) { - $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); - $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); - $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); - $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); - } - - return $bundles; - } - - public function getRootDir() - { - return __DIR__; - } - - public function getCacheDir() - { - return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); - } - - public function getLogDir() - { - return dirname(__DIR__).'/var/logs'; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); - } -} diff --git a/examples/symfony-3/app/Resources/views/base.html.twig b/examples/symfony-3/app/Resources/views/base.html.twig deleted file mode 100644 index bafd28d3..00000000 --- a/examples/symfony-3/app/Resources/views/base.html.twig +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {% block title %}Welcome!{% endblock %} - {% block stylesheets %}{% endblock %} - - - - {% block body %}{% endblock %} - {% block javascripts %}{% endblock %} - - diff --git a/examples/symfony-3/app/Resources/views/default/index.html.twig b/examples/symfony-3/app/Resources/views/default/index.html.twig deleted file mode 100644 index 7319df7f..00000000 --- a/examples/symfony-3/app/Resources/views/default/index.html.twig +++ /dev/null @@ -1,76 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block body %} -
-
-
-

Welcome to Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}

-
- -
-

- - - Your application is now ready. You can start working on it at: - {{ base_dir }}/ -

-
- - - -
-
-{% endblock %} - -{% block stylesheets %} - -{% endblock %} diff --git a/examples/symfony-3/app/autoload.php b/examples/symfony-3/app/autoload.php deleted file mode 100644 index fa582ecd..00000000 --- a/examples/symfony-3/app/autoload.php +++ /dev/null @@ -1,13 +0,0 @@ -getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); -$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; - -if ($debug) { - Debug::enable(); -} - -$kernel = new AppKernel($env, $debug); -$application = new Application($kernel); -$application->run($input); diff --git a/examples/symfony-3/bin/symfony_requirements b/examples/symfony-3/bin/symfony_requirements deleted file mode 100755 index 5bfa4497..00000000 --- a/examples/symfony-3/bin/symfony_requirements +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env php -getPhpIniConfigPath(); - -echo_title('Symfony Requirements Checker'); - -echo '> PHP is using the following php.ini file:'.PHP_EOL; -if ($iniPath) { - echo_style('green', ' '.$iniPath); -} else { - echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!'); -} - -echo PHP_EOL.PHP_EOL; - -echo '> Checking Symfony requirements:'.PHP_EOL.' '; - -$messages = array(); -foreach ($symfonyRequirements->getRequirements() as $req) { - /** @var $req Requirement */ - if ($helpText = get_error_message($req, $lineSize)) { - echo_style('red', 'E'); - $messages['error'][] = $helpText; - } else { - echo_style('green', '.'); - } -} - -$checkPassed = empty($messages['error']); - -foreach ($symfonyRequirements->getRecommendations() as $req) { - if ($helpText = get_error_message($req, $lineSize)) { - echo_style('yellow', 'W'); - $messages['warning'][] = $helpText; - } else { - echo_style('green', '.'); - } -} - -if ($checkPassed) { - echo_block('success', 'OK', 'Your system is ready to run Symfony projects'); -} else { - echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects'); - - echo_title('Fix the following mandatory requirements', 'red'); - - foreach ($messages['error'] as $helpText) { - echo ' * '.$helpText.PHP_EOL; - } -} - -if (!empty($messages['warning'])) { - echo_title('Optional recommendations to improve your setup', 'yellow'); - - foreach ($messages['warning'] as $helpText) { - echo ' * '.$helpText.PHP_EOL; - } -} - -echo PHP_EOL; -echo_style('title', 'Note'); -echo ' The command console could use a different php.ini file'.PHP_EOL; -echo_style('title', '~~~~'); -echo ' than the one used with your web server. To be on the'.PHP_EOL; -echo ' safe side, please check the requirements from your web'.PHP_EOL; -echo ' server using the '; -echo_style('yellow', 'web/config.php'); -echo ' script.'.PHP_EOL; -echo PHP_EOL; - -exit($checkPassed ? 0 : 1); - -function get_error_message(Requirement $requirement, $lineSize) -{ - if ($requirement->isFulfilled()) { - return; - } - - $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL; - $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL; - - return $errorMessage; -} - -function echo_title($title, $style = null) -{ - $style = $style ?: 'title'; - - echo PHP_EOL; - echo_style($style, $title.PHP_EOL); - echo_style($style, str_repeat('~', strlen($title)).PHP_EOL); - echo PHP_EOL; -} - -function echo_style($style, $message) -{ - // ANSI color codes - $styles = array( - 'reset' => "\033[0m", - 'red' => "\033[31m", - 'green' => "\033[32m", - 'yellow' => "\033[33m", - 'error' => "\033[37;41m", - 'success' => "\033[37;42m", - 'title' => "\033[34m", - ); - $supports = has_color_support(); - - echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : ''); -} - -function echo_block($style, $title, $message) -{ - $message = ' '.trim($message).' '; - $width = strlen($message); - - echo PHP_EOL.PHP_EOL; - - echo_style($style, str_repeat(' ', $width).PHP_EOL); - echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL); - echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL); - echo_style($style, str_repeat(' ', $width).PHP_EOL); -} - -function has_color_support() -{ - static $support; - - if (null === $support) { - if (DIRECTORY_SEPARATOR == '\\') { - $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); - } else { - $support = function_exists('posix_isatty') && @posix_isatty(STDOUT); - } - } - - return $support; -} diff --git a/examples/symfony-3/composer.json b/examples/symfony-3/composer.json deleted file mode 100644 index 7d766ce6..00000000 --- a/examples/symfony-3/composer.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "name": "symfony/framework-standard-edition", - "license": "MIT", - "type": "project", - "description": "The \"Symfony Standard Edition\" distribution", - "autoload": { - "psr-4": { "": "src/" }, - "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] - }, - "autoload-dev": { - "psr-4": { "Tests\\": "tests/" } - }, - "require": { - "php": ">=5.5.9", - "symfony/symfony": "3.0.*", - "doctrine/orm": "^2.5", - "doctrine/doctrine-bundle": "^1.6", - "doctrine/doctrine-cache-bundle": "^1.2", - "symfony/swiftmailer-bundle": "^2.3", - "symfony/monolog-bundle": "^2.8", - "sensio/distribution-bundle": "^5.0", - "sensio/framework-extra-bundle": "^3.0.2", - "incenteev/composer-parameter-handler": "^2.0", - "sentry/sentry": "dev-master", - "sentry/sentry-symfony": "dev-master" - }, - "require-dev": { - "sensio/generator-bundle": "^3.0", - "symfony/phpunit-bridge": "^3.0" - }, - "scripts": { - "post-install-cmd": [ - "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" - ], - "post-update-cmd": [ - "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" - ] - }, - "config": { - "platform": { - "php": "5.5.9" - } - }, - "extra": { - "symfony-app-dir": "app", - "symfony-bin-dir": "bin", - "symfony-var-dir": "var", - "symfony-web-dir": "web", - "symfony-tests-dir": "tests", - "symfony-assets-install": "relative", - "incenteev-parameters": { - "file": "app/config/parameters.yml" - }, - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "repositories": [ - { - "type": "vcs", - "url": "../../" - }, - { - "type": "vcs", - "url": "../../../sentry-php" - } - ] -} diff --git a/examples/symfony-3/phpunit.xml.dist b/examples/symfony-3/phpunit.xml.dist deleted file mode 100644 index b115bb39..00000000 --- a/examples/symfony-3/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - tests - - - - - - src - - src/*Bundle/Resources - src/*/*Bundle/Resources - src/*/Bundle/*Bundle/Resources - - - - diff --git a/examples/symfony-3/src/.htaccess b/examples/symfony-3/src/.htaccess deleted file mode 100644 index fb1de45b..00000000 --- a/examples/symfony-3/src/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ - - Require all denied - - - Order deny,allow - Deny from all - diff --git a/examples/symfony-3/src/AppBundle/AppBundle.php b/examples/symfony-3/src/AppBundle/AppBundle.php deleted file mode 100644 index 05123b67..00000000 --- a/examples/symfony-3/src/AppBundle/AppBundle.php +++ /dev/null @@ -1,9 +0,0 @@ -request('GET', '/'); - - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text()); - } -} diff --git a/examples/symfony-3/var/SymfonyRequirements.php b/examples/symfony-3/var/SymfonyRequirements.php deleted file mode 100644 index 841338f4..00000000 --- a/examples/symfony-3/var/SymfonyRequirements.php +++ /dev/null @@ -1,774 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/* - * Users of PHP 5.2 should be able to run the requirements checks. - * This is why the file and all classes must be compatible with PHP 5.2+ - * (e.g. not using namespaces and closures). - * - * ************** CAUTION ************** - * - * DO NOT EDIT THIS FILE as it will be overridden by Composer as part of - * the installation/update process. The original file resides in the - * SensioDistributionBundle. - * - * ************** CAUTION ************** - */ - -/** - * Represents a single PHP requirement, e.g. an installed extension. - * It can be a mandatory requirement or an optional recommendation. - * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. - * - * @author Tobias Schultze - */ -class Requirement -{ - private $fulfilled; - private $testMessage; - private $helpText; - private $helpHtml; - private $optional; - - /** - * Constructor that initializes the requirement. - * - * @param bool $fulfilled Whether the requirement is fulfilled - * @param string $testMessage The message for testing the requirement - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement - */ - public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) - { - $this->fulfilled = (bool) $fulfilled; - $this->testMessage = (string) $testMessage; - $this->helpHtml = (string) $helpHtml; - $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; - $this->optional = (bool) $optional; - } - - /** - * Returns whether the requirement is fulfilled. - * - * @return bool true if fulfilled, otherwise false - */ - public function isFulfilled() - { - return $this->fulfilled; - } - - /** - * Returns the message for testing the requirement. - * - * @return string The test message - */ - public function getTestMessage() - { - return $this->testMessage; - } - - /** - * Returns the help text for resolving the problem. - * - * @return string The help text - */ - public function getHelpText() - { - return $this->helpText; - } - - /** - * Returns the help text formatted in HTML. - * - * @return string The HTML help - */ - public function getHelpHtml() - { - return $this->helpHtml; - } - - /** - * Returns whether this is only an optional recommendation and not a mandatory requirement. - * - * @return bool true if optional, false if mandatory - */ - public function isOptional() - { - return $this->optional; - } -} - -/** - * Represents a PHP requirement in form of a php.ini configuration. - * - * @author Tobias Schultze - */ -class PhpIniRequirement extends Requirement -{ - /** - * Constructor that initializes the requirement. - * - * @param string $cfgName The configuration name used for ini_get() - * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) - * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement - */ - public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) - { - $cfgValue = ini_get($cfgName); - - if (is_callable($evaluation)) { - if (null === $testMessage || null === $helpHtml) { - throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); - } - - $fulfilled = call_user_func($evaluation, $cfgValue); - } else { - if (null === $testMessage) { - $testMessage = sprintf('%s %s be %s in php.ini', - $cfgName, - $optional ? 'should' : 'must', - $evaluation ? 'enabled' : 'disabled' - ); - } - - if (null === $helpHtml) { - $helpHtml = sprintf('Set %s to %s in php.ini*.', - $cfgName, - $evaluation ? 'on' : 'off' - ); - } - - $fulfilled = $evaluation == $cfgValue; - } - - parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); - } -} - -/** - * A RequirementCollection represents a set of Requirement instances. - * - * @author Tobias Schultze - */ -class RequirementCollection implements IteratorAggregate -{ - private $requirements = array(); - - /** - * Gets the current RequirementCollection as an Iterator. - * - * @return Traversable A Traversable interface - */ - public function getIterator() - { - return new ArrayIterator($this->requirements); - } - - /** - * Adds a Requirement. - * - * @param Requirement $requirement A Requirement instance - */ - public function add(Requirement $requirement) - { - $this->requirements[] = $requirement; - } - - /** - * Adds a mandatory requirement. - * - * @param bool $fulfilled Whether the requirement is fulfilled - * @param string $testMessage The message for testing the requirement - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) - { - $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); - } - - /** - * Adds an optional recommendation. - * - * @param bool $fulfilled Whether the recommendation is fulfilled - * @param string $testMessage The message for testing the recommendation - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) - { - $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); - } - - /** - * Adds a mandatory requirement in form of a php.ini configuration. - * - * @param string $cfgName The configuration name used for ini_get() - * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) - { - $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); - } - - /** - * Adds an optional recommendation in form of a php.ini configuration. - * - * @param string $cfgName The configuration name used for ini_get() - * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) - { - $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); - } - - /** - * Adds a requirement collection to the current set of requirements. - * - * @param RequirementCollection $collection A RequirementCollection instance - */ - public function addCollection(RequirementCollection $collection) - { - $this->requirements = array_merge($this->requirements, $collection->all()); - } - - /** - * Returns both requirements and recommendations. - * - * @return array Array of Requirement instances - */ - public function all() - { - return $this->requirements; - } - - /** - * Returns all mandatory requirements. - * - * @return array Array of Requirement instances - */ - public function getRequirements() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns the mandatory requirements that were not met. - * - * @return array Array of Requirement instances - */ - public function getFailedRequirements() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && !$req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns all optional recommendations. - * - * @return array Array of Requirement instances - */ - public function getRecommendations() - { - $array = array(); - foreach ($this->requirements as $req) { - if ($req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns the recommendations that were not met. - * - * @return array Array of Requirement instances - */ - public function getFailedRecommendations() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && $req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns whether a php.ini configuration is not correct. - * - * @return bool php.ini configuration problem? - */ - public function hasPhpIniConfigIssue() - { - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { - return true; - } - } - - return false; - } - - /** - * Returns the PHP configuration file (php.ini) path. - * - * @return string|false php.ini file path - */ - public function getPhpIniConfigPath() - { - return get_cfg_var('cfg_file_path'); - } -} - -/** - * This class specifies all requirements and optional recommendations that - * are necessary to run the Symfony Standard Edition. - * - * @author Tobias Schultze - * @author Fabien Potencier - */ -class SymfonyRequirements extends RequirementCollection -{ - const REQUIRED_PHP_VERSION = '5.3.3'; - - /** - * Constructor that initializes the requirements. - */ - public function __construct() - { - /* mandatory requirements follow */ - - $installedPhpVersion = phpversion(); - - $this->addRequirement( - version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), - sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), - sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. - Before using Symfony, upgrade your PHP installation, preferably to the latest version.', - $installedPhpVersion, self::REQUIRED_PHP_VERSION), - sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) - ); - - $this->addRequirement( - version_compare($installedPhpVersion, '5.3.16', '!='), - 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', - 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' - ); - - $this->addRequirement( - is_dir(__DIR__.'/../vendor/composer'), - 'Vendor libraries must be installed', - 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. '. - 'Then run "php composer.phar install" to install them.' - ); - - $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; - - $this->addRequirement( - is_writable($cacheDir), - 'app/cache/ or var/cache/ directory must be writable', - 'Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.' - ); - - $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; - - $this->addRequirement( - is_writable($logsDir), - 'app/logs/ or var/logs/ directory must be writable', - 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' - ); - - if (version_compare($installedPhpVersion, '7.0.0', '<')) { - $this->addPhpIniRequirement( - 'date.timezone', true, false, - 'date.timezone setting must be set', - 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' - ); - } - - if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { - $timezones = array(); - foreach (DateTimeZone::listAbbreviations() as $abbreviations) { - foreach ($abbreviations as $abbreviation) { - $timezones[$abbreviation['timezone_id']] = true; - } - } - - $this->addRequirement( - isset($timezones[@date_default_timezone_get()]), - sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), - 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' - ); - } - - $this->addRequirement( - function_exists('iconv'), - 'iconv() must be available', - 'Install and enable the iconv extension.' - ); - - $this->addRequirement( - function_exists('json_encode'), - 'json_encode() must be available', - 'Install and enable the JSON extension.' - ); - - $this->addRequirement( - function_exists('session_start'), - 'session_start() must be available', - 'Install and enable the session extension.' - ); - - $this->addRequirement( - function_exists('ctype_alpha'), - 'ctype_alpha() must be available', - 'Install and enable the ctype extension.' - ); - - $this->addRequirement( - function_exists('token_get_all'), - 'token_get_all() must be available', - 'Install and enable the Tokenizer extension.' - ); - - $this->addRequirement( - function_exists('simplexml_import_dom'), - 'simplexml_import_dom() must be available', - 'Install and enable the SimpleXML extension.' - ); - - if (function_exists('apc_store') && ini_get('apc.enabled')) { - if (version_compare($installedPhpVersion, '5.4.0', '>=')) { - $this->addRequirement( - version_compare(phpversion('apc'), '3.1.13', '>='), - 'APC version must be at least 3.1.13 when using PHP 5.4', - 'Upgrade your APC extension (3.1.13+).' - ); - } else { - $this->addRequirement( - version_compare(phpversion('apc'), '3.0.17', '>='), - 'APC version must be at least 3.0.17', - 'Upgrade your APC extension (3.0.17+).' - ); - } - } - - $this->addPhpIniRequirement('detect_unicode', false); - - if (extension_loaded('suhosin')) { - $this->addPhpIniRequirement( - 'suhosin.executor.include.whitelist', - create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), - false, - 'suhosin.executor.include.whitelist must be configured correctly in php.ini', - 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' - ); - } - - if (extension_loaded('xdebug')) { - $this->addPhpIniRequirement( - 'xdebug.show_exception_trace', false, true - ); - - $this->addPhpIniRequirement( - 'xdebug.scream', false, true - ); - - $this->addPhpIniRecommendation( - 'xdebug.max_nesting_level', - create_function('$cfgValue', 'return $cfgValue > 100;'), - true, - 'xdebug.max_nesting_level should be above 100 in php.ini', - 'Set "xdebug.max_nesting_level" to e.g. "250" in php.ini* to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' - ); - } - - $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; - - $this->addRequirement( - null !== $pcreVersion, - 'PCRE extension must be available', - 'Install the PCRE extension (version 8.0+).' - ); - - if (extension_loaded('mbstring')) { - $this->addPhpIniRequirement( - 'mbstring.func_overload', - create_function('$cfgValue', 'return (int) $cfgValue === 0;'), - true, - 'string functions should not be overloaded', - 'Set "mbstring.func_overload" to 0 in php.ini* to disable function overloading by the mbstring extension.' - ); - } - - /* optional recommendations follow */ - - if (file_exists(__DIR__.'/../vendor/composer')) { - require_once __DIR__.'/../vendor/autoload.php'; - - try { - $r = new ReflectionClass('Sensio\Bundle\DistributionBundle\SensioDistributionBundle'); - - $contents = file_get_contents(dirname($r->getFileName()).'/Resources/skeleton/app/SymfonyRequirements.php'); - } catch (ReflectionException $e) { - $contents = ''; - } - $this->addRecommendation( - file_get_contents(__FILE__) === $contents, - 'Requirements file should be up-to-date', - 'Your requirements file is outdated. Run composer install and re-check your configuration.' - ); - } - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.4', '>='), - 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', - 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.8', '>='), - 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', - 'Install PHP 5.3.8 or newer if your project uses annotations.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.4.0', '!='), - 'You should not use PHP 5.4.0 due to the PHP bug #61453', - 'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.4.11', '>='), - 'When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)', - 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' - ); - - $this->addRecommendation( - (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) - || - version_compare($installedPhpVersion, '5.4.8', '>='), - 'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909', - 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' - ); - - if (null !== $pcreVersion) { - $this->addRecommendation( - $pcreVersion >= 8.0, - sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), - 'PCRE 8.0+ is preconfigured in PHP since 5.3.2 but you are using an outdated version of it. Symfony probably works anyway but it is recommended to upgrade your PCRE extension.' - ); - } - - $this->addRecommendation( - class_exists('DomDocument'), - 'PHP-DOM and PHP-XML modules should be installed', - 'Install and enable the PHP-DOM and the PHP-XML modules.' - ); - - $this->addRecommendation( - function_exists('mb_strlen'), - 'mb_strlen() should be available', - 'Install and enable the mbstring extension.' - ); - - $this->addRecommendation( - function_exists('iconv'), - 'iconv() should be available', - 'Install and enable the iconv extension.' - ); - - $this->addRecommendation( - function_exists('utf8_decode'), - 'utf8_decode() should be available', - 'Install and enable the XML extension.' - ); - - $this->addRecommendation( - function_exists('filter_var'), - 'filter_var() should be available', - 'Install and enable the filter extension.' - ); - - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->addRecommendation( - function_exists('posix_isatty'), - 'posix_isatty() should be available', - 'Install and enable the php_posix extension (used to colorize the CLI output).' - ); - } - - $this->addRecommendation( - extension_loaded('intl'), - 'intl extension should be available', - 'Install and enable the intl extension (used for validators).' - ); - - if (extension_loaded('intl')) { - // in some WAMP server installations, new Collator() returns null - $this->addRecommendation( - null !== new Collator('fr_FR'), - 'intl extension should be correctly configured', - 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' - ); - - // check for compatible ICU versions (only done when you have the intl extension) - if (defined('INTL_ICU_VERSION')) { - $version = INTL_ICU_VERSION; - } else { - $reflector = new ReflectionExtension('intl'); - - ob_start(); - $reflector->info(); - $output = strip_tags(ob_get_clean()); - - preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); - $version = $matches[1]; - } - - $this->addRecommendation( - version_compare($version, '4.0', '>='), - 'intl ICU version should be at least 4+', - 'Upgrade your intl extension with a newer ICU version (4+).' - ); - - if (class_exists('Symfony\Component\Intl\Intl')) { - $this->addRecommendation( - \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), - sprintf('intl ICU version installed on your system (%s) should match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), - 'In most cases you should be fine, but please verify there is no inconsistencies between data provided by Symfony and the intl extension. See https://github.com/symfony/symfony/issues/15007 for an example of inconsistencies you might run into.' - ); - } - - $this->addPhpIniRecommendation( - 'intl.error_level', - create_function('$cfgValue', 'return (int) $cfgValue === 0;'), - true, - 'intl.error_level should be 0 in php.ini', - 'Set "intl.error_level" to "0" in php.ini* to inhibit the messages when an error occurs in ICU functions.' - ); - } - - $accelerator = - (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) - || - (extension_loaded('apc') && ini_get('apc.enabled')) - || - (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) - || - (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) - || - (extension_loaded('xcache') && ini_get('xcache.cacher')) - || - (extension_loaded('wincache') && ini_get('wincache.ocenabled')) - ; - - $this->addRecommendation( - $accelerator, - 'a PHP accelerator should be installed', - 'Install and/or enable a PHP accelerator (highly recommended).' - ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $this->addRecommendation( - $this->getRealpathCacheSize() > 1000, - 'realpath_cache_size should be above 1024 in php.ini', - 'Set "realpath_cache_size" to e.g. "1024" in php.ini* to improve performance on windows.' - ); - } - - $this->addPhpIniRecommendation('short_open_tag', false); - - $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); - - $this->addPhpIniRecommendation('register_globals', false, true); - - $this->addPhpIniRecommendation('session.auto_start', false); - - $this->addRecommendation( - class_exists('PDO'), - 'PDO should be installed', - 'Install PDO (mandatory for Doctrine).' - ); - - if (class_exists('PDO')) { - $drivers = PDO::getAvailableDrivers(); - $this->addRecommendation( - count($drivers) > 0, - sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), - 'Install PDO drivers (mandatory for Doctrine).' - ); - } - } - - /** - * Loads realpath_cache_size from php.ini and converts it to int. - * - * (e.g. 16k is converted to 16384 int) - * - * @return int - */ - protected function getRealpathCacheSize() - { - $size = ini_get('realpath_cache_size'); - $size = trim($size); - $unit = strtolower(substr($size, -1, 1)); - switch ($unit) { - case 'g': - return $size * 1024 * 1024 * 1024; - case 'm': - return $size * 1024 * 1024; - case 'k': - return $size * 1024; - default: - return (int) $size; - } - } -} diff --git a/examples/symfony-3/var/cache/.gitkeep b/examples/symfony-3/var/cache/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/symfony-3/var/logs/.gitkeep b/examples/symfony-3/var/logs/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/symfony-3/var/sessions/.gitkeep b/examples/symfony-3/var/sessions/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/symfony-3/web/.htaccess b/examples/symfony-3/web/.htaccess deleted file mode 100644 index 4dc72516..00000000 --- a/examples/symfony-3/web/.htaccess +++ /dev/null @@ -1,68 +0,0 @@ -# Use the front controller as index file. It serves as a fallback solution when -# every other rewrite/redirect fails (e.g. in an aliased environment without -# mod_rewrite). Additionally, this reduces the matching process for the -# start page (path "/") because otherwise Apache will apply the rewriting rules -# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). -DirectoryIndex app.php - -# By default, Apache does not evaluate symbolic links if you did not enable this -# feature in your server configuration. Uncomment the following line if you -# install assets as symlinks or if you experience problems related to symlinks -# when compiling LESS/Sass/CoffeScript assets. -# Options FollowSymlinks - -# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve -# to the front controller "/app.php" but be rewritten to "/app.php/app". - - Options -MultiViews - - - - RewriteEngine On - - # Determine the RewriteBase automatically and set it as environment variable. - # If you are using Apache aliases to do mass virtual hosting or installed the - # project in a subdirectory, the base path will be prepended to allow proper - # resolution of the app.php file and to redirect to the correct URI. It will - # work in environments without path prefix as well, providing a safe, one-size - # fits all solution. But as you do not need it in this case, you can comment - # the following 2 lines to eliminate the overhead. - RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ - RewriteRule ^(.*) - [E=BASE:%1] - - # Sets the HTTP_AUTHORIZATION header removed by Apache - RewriteCond %{HTTP:Authorization} . - RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - - # Redirect to URI without front controller to prevent duplicate content - # (with and without `/app.php`). Only do this redirect on the initial - # rewrite by Apache and not on subsequent cycles. Otherwise we would get an - # endless redirect loop (request -> rewrite to front controller -> - # redirect -> request -> ...). - # So in case you get a "too many redirects" error or you always get redirected - # to the start page because your Apache does not expose the REDIRECT_STATUS - # environment variable, you have 2 choices: - # - disable this feature by commenting the following 2 lines or - # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the - # following RewriteCond (best solution) - RewriteCond %{ENV:REDIRECT_STATUS} ^$ - RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] - - # If the requested filename exists, simply serve it. - # We only want to let Apache serve files and not directories. - RewriteCond %{REQUEST_FILENAME} -f - RewriteRule ^ - [L] - - # Rewrite all other queries to the front controller. - RewriteRule ^ %{ENV:BASE}/app.php [L] - - - - - # When mod_rewrite is not available, we instruct a temporary redirect of - # the start page to the front controller explicitly so that the website - # and the generated links can still be used. - RedirectMatch 302 ^/$ /app.php/ - # RedirectTemp cannot be used instead - - diff --git a/examples/symfony-3/web/app.php b/examples/symfony-3/web/app.php deleted file mode 100644 index 5c5ee03b..00000000 --- a/examples/symfony-3/web/app.php +++ /dev/null @@ -1,30 +0,0 @@ -unregister(); -$apcLoader->register(true); -*/ - -$kernel = new AppKernel('prod', false); -$kernel->loadClassCache(); -//$kernel = new AppCache($kernel); - -// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter -//Request::enableHttpMethodParameterOverride(); -$request = Request::createFromGlobals(); -$response = $kernel->handle($request); -$response->send(); -$kernel->terminate($request, $response); diff --git a/examples/symfony-3/web/app_dev.php b/examples/symfony-3/web/app_dev.php deleted file mode 100644 index 8456754d..00000000 --- a/examples/symfony-3/web/app_dev.php +++ /dev/null @@ -1,32 +0,0 @@ -loadClassCache(); -$request = Request::createFromGlobals(); -$response = $kernel->handle($request); -$response->send(); -$kernel->terminate($request, $response); diff --git a/examples/symfony-3/web/apple-touch-icon.png b/examples/symfony-3/web/apple-touch-icon.png deleted file mode 100644 index 11f17e6d..00000000 Binary files a/examples/symfony-3/web/apple-touch-icon.png and /dev/null differ diff --git a/examples/symfony-3/web/config.php b/examples/symfony-3/web/config.php deleted file mode 100644 index 21535bf0..00000000 --- a/examples/symfony-3/web/config.php +++ /dev/null @@ -1,205 +0,0 @@ -getFailedRequirements(); -$minorProblems = $symfonyRequirements->getFailedRecommendations(); - -?> - - - - - - Symfony Configuration Checker - - - - - -
-
- - - -
- -
-
-
-

Configuration Checker

-

- This script analyzes your system to check whether is - ready to run Symfony applications. -

- - -

Major problems

-

Major problems have been detected and must be fixed before continuing:

-
    - -
  1. getHelpHtml() ?>
  2. - -
- - - -

Recommendations

-

- Additionally, toTo enhance your Symfony experience, - it’s recommended that you fix the following: -

-
    - -
  1. getHelpHtml() ?>
  2. - -
- - - hasPhpIniConfigIssue()): ?> -

* - getPhpIniConfigPath()): ?> - Changes to the php.ini file must be done in "getPhpIniConfigPath() ?>". - - To change settings, create a "php.ini". - -

- - - -

All checks passed successfully. Your system is ready to run Symfony applications.

- - - -
-
-
-
Symfony Standard Edition
-
- - diff --git a/examples/symfony-3/web/favicon.ico b/examples/symfony-3/web/favicon.ico deleted file mode 100644 index 479f7f50..00000000 Binary files a/examples/symfony-3/web/favicon.ico and /dev/null differ diff --git a/examples/symfony-3/web/robots.txt b/examples/symfony-3/web/robots.txt deleted file mode 100644 index 4665fcae..00000000 --- a/examples/symfony-3/web/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -# www.robotstxt.org/ -# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 - -User-agent: * -Disallow: diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b8bb9faf..dbeee1a2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -33,90 +33,90 @@ parameters: - message: "#^Class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Client not found\\.$#" count: 1 - path: test/End2End/End2EndTest.php + path: tests/End2End/End2EndTest.php - message: "#^Comparison operation \"\\<\" between 50201 and 40300 is always false\\.$#" count: 1 - path: test/End2End/End2EndTest.php + path: tests/End2End/End2EndTest.php - - message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ErrorListenerTest\\:\\:testHandleExceptionEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" + message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\ErrorListenerTest\\:\\:testHandleExceptionEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" count: 1 - path: test/EventListener/ErrorListenerTest.php + path: tests/EventListener/ErrorListenerTest.php - message: "#^Call to method getException\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" count: 1 - path: test/EventListener/ErrorListenerTest.php + path: tests/EventListener/ErrorListenerTest.php - message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\ErrorListener\\:\\:handleExceptionEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ExceptionEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ExceptionEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent given\\.$#" count: 1 - path: test/EventListener/ErrorListenerTest.php + path: tests/EventListener/ErrorListenerTest.php - message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#" count: 1 - path: test/EventListener/ErrorListenerTest.php + path: tests/EventListener/ErrorListenerTest.php - message: "#^If condition is always false\\.$#" count: 1 - path: test/EventListener/MessengerListenerTest.php + path: tests/EventListener/MessengerListenerTest.php - message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageFailedEvent constructor invoked with 4 parameters, 3 required\\.$#" count: 1 - path: test/EventListener/MessengerListenerTest.php + path: tests/EventListener/MessengerListenerTest.php - - message: "#^Parameter \\$requestEvent of method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#" + message: "#^Parameter \\$requestEvent of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#" count: 1 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#" count: 1 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#" count: 6 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - - message: "#^Parameter \\$controllerEvent of method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelControllerEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent\\.$#" + message: "#^Parameter \\$controllerEvent of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelControllerEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent\\.$#" count: 1 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelControllerEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ControllerEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ControllerEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent given\\.$#" count: 1 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent not found\\.$#" count: 3 - path: test/EventListener/RequestListenerTest.php + path: tests/EventListener/RequestListenerTest.php - - message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\SubRequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#" + message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\SubRequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#" count: 1 - path: test/EventListener/SubRequestListenerTest.php + path: tests/EventListener/SubRequestListenerTest.php - message: "#^Call to method isMasterRequest\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#" count: 1 - path: test/EventListener/SubRequestListenerTest.php + path: tests/EventListener/SubRequestListenerTest.php - message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#" count: 1 - path: test/EventListener/SubRequestListenerTest.php + path: tests/EventListener/SubRequestListenerTest.php - message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#" count: 2 - path: test/EventListener/SubRequestListenerTest.php + path: tests/EventListener/SubRequestListenerTest.php diff --git a/phpstan.neon b/phpstan.neon index 0970ebbb..2fb21049 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,9 +4,9 @@ includes: parameters: level: 7 paths: - - src/ - - test/ + - src + - tests excludes_analyse: - - test/End2End/App + - tests/End2End/App dynamicConstantNames: - Symfony\Component\HttpKernel\Kernel::VERSION diff --git a/phpunit.xml b/phpunit.xml index 6eafa5f5..2cecad4b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,11 +1,10 @@ - @@ -13,15 +12,21 @@ - ./test + tests + + + src + + + - ./src + src - ./src/aliases.php + src/aliases.php diff --git a/src/Command/SentryTestCommand.php b/src/Command/SentryTestCommand.php index 522702be..809b14b1 100644 --- a/src/Command/SentryTestCommand.php +++ b/src/Command/SentryTestCommand.php @@ -1,5 +1,7 @@ getClient(); - if (! $client) { + if (!$client) { $output->writeln('No client found'); $output->writeln('Your DSN is probably missing, check your configuration'); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 57a78db4..9ab83623 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,7 +23,7 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder = new TreeBuilder('sentry'); /** @var ArrayNodeDefinition $rootNode */ - $rootNode = \method_exists(TreeBuilder::class, 'getRootNode') + $rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('sentry'); @@ -32,7 +32,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('dsn') ->beforeNormalization() ->ifTrue(static function ($value): bool { - return empty($value) || (is_string($value) && '' === trim($value)); + return empty($value) || (\is_string($value) && '' === trim($value)); }) ->thenUnset() ->end() diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index eca4267c..ba8b0d3e 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -76,7 +76,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi $options['dsn'] = $config['dsn']; } - if (! $container->hasParameter('kernel.build_dir')) { + if (!$container->hasParameter('kernel.build_dir')) { $options['in_app_exclude'] = array_filter($options['in_app_exclude'], static function (string $value): bool { return '%kernel.build_dir%' !== $value; }); @@ -136,7 +136,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi */ private function registerErrorListenerConfiguration(ContainerBuilder $container, array $config): void { - if (! $config['register_error_listener']) { + if (!$config['register_error_listener']) { $container->removeDefinition(ErrorListener::class); } } @@ -146,7 +146,7 @@ private function registerErrorListenerConfiguration(ContainerBuilder $container, */ private function registerMessengerListenerConfiguration(ContainerBuilder $container, array $config): void { - if (! $config['enabled']) { + if (!$config['enabled']) { $container->removeDefinition(MessengerListener::class); return; @@ -162,13 +162,13 @@ private function registerMonologHandlerConfiguration(ContainerBuilder $container { $errorHandlerConfig = $config['error_handler']; - if (! $errorHandlerConfig['enabled']) { + if (!$errorHandlerConfig['enabled']) { $container->removeDefinition(Handler::class); return; } - if (! class_exists(MonologLogger::class)) { + if (!class_exists(MonologLogger::class)) { throw new LogicException(sprintf('To use the "%s" class you need to require the "symfony/monolog-bundle" package.', Handler::class)); } @@ -178,7 +178,7 @@ private function registerMonologHandlerConfiguration(ContainerBuilder $container } /** - * @param string[] $integrations + * @param string[] $integrations * @param array $config * * @return array @@ -202,7 +202,7 @@ private function configureIntegrationsOption(array $integrations, array $config) */ private function configureErrorListenerIntegration(array $integrations, bool $registerErrorListener): array { - if ($registerErrorListener && ! $this->isIntegrationEnabled(IgnoreErrorsIntegration::class, $integrations)) { + if ($registerErrorListener && !$this->isIntegrationEnabled(IgnoreErrorsIntegration::class, $integrations)) { // Prepend this integration to the beginning of the array so that // we can save some performance by skipping the rest of the integrations // if the error must be ignored @@ -219,7 +219,7 @@ private function configureErrorListenerIntegration(array $integrations, bool $re */ private function configureRequestIntegration(array $integrations, bool $useDefaultIntegrations): array { - if ($useDefaultIntegrations && ! $this->isIntegrationEnabled(RequestIntegration::class, $integrations)) { + if ($useDefaultIntegrations && !$this->isIntegrationEnabled(RequestIntegration::class, $integrations)) { $integrations[] = new Definition(RequestIntegration::class, [new Reference(RequestFetcherInterface::class)]); } @@ -228,7 +228,7 @@ private function configureRequestIntegration(array $integrations, bool $useDefau /** * @param class-string $integrationClass - * @param array $integrations + * @param array $integrations */ private function isIntegrationEnabled(string $integrationClass, array $integrations): bool { diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index cc93323b..aa31d486 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -53,8 +53,8 @@ public static function parse(string $value): int private static function convertErrorConstants(string $value): string { $output = preg_replace_callback('/(E_[A-Z_]+)/', static function (array $matches) { - if (defined($matches[1])) { - return constant($matches[1]); + if (\defined($matches[1])) { + return \constant($matches[1]); } return $matches[0]; diff --git a/src/EventListener/ConsoleCommandListener.php b/src/EventListener/ConsoleCommandListener.php index 8de20639..4fecba07 100644 --- a/src/EventListener/ConsoleCommandListener.php +++ b/src/EventListener/ConsoleCommandListener.php @@ -1,5 +1,7 @@ captureSoftFails && $event->willRetry()) { + if (!$this->captureSoftFails && $event->willRetry()) { return; } diff --git a/src/EventListener/RequestListener.php b/src/EventListener/RequestListener.php index 35b17fbc..5a5b085b 100644 --- a/src/EventListener/RequestListener.php +++ b/src/EventListener/RequestListener.php @@ -1,5 +1,7 @@ isMasterRequest()) { + if (!$event->isMasterRequest()) { return; } @@ -73,18 +75,18 @@ public function handleKernelRequestEvent(RequestListenerRequestEvent $event): vo */ public function handleKernelControllerEvent(RequestListenerControllerEvent $event): void { - if (! $event->isMasterRequest()) { + if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); - if (! $request->attributes->has('_route')) { + if (!$request->attributes->has('_route')) { return; } $this->hub->configureScope(static function (Scope $scope) use ($request): void { - $scope->setTag('route', $request->attributes->get('_route')); + $scope->setTag('route', (string) $request->attributes->get('_route')); }); } @@ -97,11 +99,11 @@ private function getUsername($user): ?string return $user->getUsername(); } - if (is_string($user)) { + if (\is_string($user)) { return $user; } - if (is_object($user) && method_exists($user, '__toString')) { + if (\is_object($user) && method_exists($user, '__toString')) { return (string) $user; } diff --git a/src/EventListener/SubRequestListener.php b/src/EventListener/SubRequestListener.php index 2973839d..0ba6f685 100644 --- a/src/EventListener/SubRequestListener.php +++ b/src/EventListener/SubRequestListener.php @@ -1,5 +1,7 @@ =')) { - if (! class_exists(ErrorListenerExceptionEvent::class, false)) { + if (!class_exists(ErrorListenerExceptionEvent::class, false)) { class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class); } - if (! class_exists(RequestListenerRequestEvent::class, false)) { + if (!class_exists(RequestListenerRequestEvent::class, false)) { class_alias(RequestEvent::class, RequestListenerRequestEvent::class); } - if (! class_exists(RequestListenerControllerEvent::class, false)) { + if (!class_exists(RequestListenerControllerEvent::class, false)) { class_alias(ControllerEvent::class, RequestListenerControllerEvent::class); } - if (! class_exists(SubRequestListenerRequestEvent::class, false)) { + if (!class_exists(SubRequestListenerRequestEvent::class, false)) { class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class); } } else { - if (! class_exists(ErrorListenerExceptionEvent::class, false)) { + if (!class_exists(ErrorListenerExceptionEvent::class, false)) { class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class); } - if (! class_exists(RequestListenerRequestEvent::class, false)) { + if (!class_exists(RequestListenerRequestEvent::class, false)) { class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class); } - if (! class_exists(RequestListenerControllerEvent::class, false)) { + if (!class_exists(RequestListenerControllerEvent::class, false)) { class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class); } - if (! class_exists(SubRequestListenerRequestEvent::class, false)) { + if (!class_exists(SubRequestListenerRequestEvent::class, false)) { class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class); } } diff --git a/test/End2End/App/messenger.yml b/test/End2End/App/messenger.yml deleted file mode 100644 index 2b205570..00000000 --- a/test/End2End/App/messenger.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - _defaults: - autoconfigure: true - - Sentry\SentryBundle\Test\End2End\App\Messenger\StaticInMemoryTransportFactory: - class: \Sentry\SentryBundle\Test\End2End\App\Messenger\StaticInMemoryTransportFactory - - Sentry\SentryBundle\Test\End2End\App\Messenger\FooMessageHandler: - class: \Sentry\SentryBundle\Test\End2End\App\Messenger\FooMessageHandler - - Sentry\SentryBundle\Test\End2End\App\Controller\MessengerController: - autowire: true - tags: - - controller.service_arguments - -framework: - messenger: - transports: - async: - dsn: 'static://' - retry_strategy: - max_retries: 1 - routing: - '*': async - -sentry: - messenger: - capture_soft_fails: false diff --git a/test/End2End/App/routing.yml b/test/End2End/App/routing.yml deleted file mode 100644 index c152c7a0..00000000 --- a/test/End2End/App/routing.yml +++ /dev/null @@ -1,31 +0,0 @@ -exception: - path: /exception - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::exception' } - -fatal: - path: /fatal - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::fatal' } - -200: - path: /200 - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::index' } - -secured200: - path: /secured/200 - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::index' } - -subrequest: - path: /subrequest - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::subrequest' } - -notice: - path: /notice - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MainController::notice' } - -dispatch: - path: /dispatch-message - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MessengerController::dispatchMessage' } - -dispatch_unrecoverable: - path: /dispatch-unrecoverable-message - defaults: { _controller: 'Sentry\SentryBundle\Test\End2End\App\Controller\MessengerController::dispatchUnrecoverableMessage' } diff --git a/test/BaseTestCase.php b/tests/BaseTestCase.php similarity index 87% rename from test/BaseTestCase.php rename to tests/BaseTestCase.php index 4368ba48..37937e02 100644 --- a/test/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -1,6 +1,8 @@ assertStringContainsString('DSN correctly configured', $output); $this->assertStringContainsString('Sending test message', $output); $this->assertStringContainsString('Message sent', $output); - $this->assertStringContainsString($lastEventId, $output); + $this->assertStringContainsString((string) $lastEventId, $output); $this->assertSame(0, $commandTester->getStatusCode()); } diff --git a/test/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php similarity index 99% rename from test/DependencyInjection/ConfigurationTest.php rename to tests/DependencyInjection/ConfigurationTest.php index c95c4fb8..3141100b 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Sentry\SentryBundle\Test\DependencyInjection; +namespace Sentry\SentryBundle\Tests\DependencyInjection; use Jean85\PrettyVersions; use Monolog\Logger; diff --git a/test/DependencyInjection/Fixtures/php/console_command_listener_overridden_priority.php b/tests/DependencyInjection/Fixtures/php/console_command_listener_overridden_priority.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/console_command_listener_overridden_priority.php rename to tests/DependencyInjection/Fixtures/php/console_command_listener_overridden_priority.php diff --git a/test/DependencyInjection/Fixtures/php/empty_dsn.php b/tests/DependencyInjection/Fixtures/php/empty_dsn.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/empty_dsn.php rename to tests/DependencyInjection/Fixtures/php/empty_dsn.php diff --git a/test/DependencyInjection/Fixtures/php/error_listener_disabled.php b/tests/DependencyInjection/Fixtures/php/error_listener_disabled.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/error_listener_disabled.php rename to tests/DependencyInjection/Fixtures/php/error_listener_disabled.php diff --git a/test/DependencyInjection/Fixtures/php/error_listener_overridden_priority.php b/tests/DependencyInjection/Fixtures/php/error_listener_overridden_priority.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/error_listener_overridden_priority.php rename to tests/DependencyInjection/Fixtures/php/error_listener_overridden_priority.php diff --git a/test/DependencyInjection/Fixtures/php/error_types.php b/tests/DependencyInjection/Fixtures/php/error_types.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/error_types.php rename to tests/DependencyInjection/Fixtures/php/error_types.php diff --git a/test/DependencyInjection/Fixtures/php/full.php b/tests/DependencyInjection/Fixtures/php/full.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/full.php rename to tests/DependencyInjection/Fixtures/php/full.php diff --git a/test/DependencyInjection/Fixtures/php/ignore_errors_integration_overridden.php b/tests/DependencyInjection/Fixtures/php/ignore_errors_integration_overridden.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/ignore_errors_integration_overridden.php rename to tests/DependencyInjection/Fixtures/php/ignore_errors_integration_overridden.php diff --git a/test/DependencyInjection/Fixtures/php/messenger_listener_disabled.php b/tests/DependencyInjection/Fixtures/php/messenger_listener_disabled.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/messenger_listener_disabled.php rename to tests/DependencyInjection/Fixtures/php/messenger_listener_disabled.php diff --git a/test/DependencyInjection/Fixtures/php/messenger_listener_overridden_priority.php b/tests/DependencyInjection/Fixtures/php/messenger_listener_overridden_priority.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/messenger_listener_overridden_priority.php rename to tests/DependencyInjection/Fixtures/php/messenger_listener_overridden_priority.php diff --git a/test/DependencyInjection/Fixtures/php/monolog_handler.php b/tests/DependencyInjection/Fixtures/php/monolog_handler.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/monolog_handler.php rename to tests/DependencyInjection/Fixtures/php/monolog_handler.php diff --git a/test/DependencyInjection/Fixtures/php/monolog_handler_disabled.php b/tests/DependencyInjection/Fixtures/php/monolog_handler_disabled.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/monolog_handler_disabled.php rename to tests/DependencyInjection/Fixtures/php/monolog_handler_disabled.php diff --git a/test/DependencyInjection/Fixtures/php/request_listener_overridden_priority.php b/tests/DependencyInjection/Fixtures/php/request_listener_overridden_priority.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/request_listener_overridden_priority.php rename to tests/DependencyInjection/Fixtures/php/request_listener_overridden_priority.php diff --git a/test/DependencyInjection/Fixtures/php/sub_request_listener_overridden_priority.php b/tests/DependencyInjection/Fixtures/php/sub_request_listener_overridden_priority.php similarity index 100% rename from test/DependencyInjection/Fixtures/php/sub_request_listener_overridden_priority.php rename to tests/DependencyInjection/Fixtures/php/sub_request_listener_overridden_priority.php diff --git a/test/DependencyInjection/Fixtures/xml/console_command_listener_overridden_priority.xml b/tests/DependencyInjection/Fixtures/xml/console_command_listener_overridden_priority.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/console_command_listener_overridden_priority.xml rename to tests/DependencyInjection/Fixtures/xml/console_command_listener_overridden_priority.xml diff --git a/test/DependencyInjection/Fixtures/xml/empty_dsn.xml b/tests/DependencyInjection/Fixtures/xml/empty_dsn.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/empty_dsn.xml rename to tests/DependencyInjection/Fixtures/xml/empty_dsn.xml diff --git a/test/DependencyInjection/Fixtures/xml/error_listener_disabled.xml b/tests/DependencyInjection/Fixtures/xml/error_listener_disabled.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/error_listener_disabled.xml rename to tests/DependencyInjection/Fixtures/xml/error_listener_disabled.xml diff --git a/test/DependencyInjection/Fixtures/xml/error_listener_overridden_priority.xml b/tests/DependencyInjection/Fixtures/xml/error_listener_overridden_priority.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/error_listener_overridden_priority.xml rename to tests/DependencyInjection/Fixtures/xml/error_listener_overridden_priority.xml diff --git a/test/DependencyInjection/Fixtures/xml/error_types.xml b/tests/DependencyInjection/Fixtures/xml/error_types.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/error_types.xml rename to tests/DependencyInjection/Fixtures/xml/error_types.xml diff --git a/test/DependencyInjection/Fixtures/xml/full.xml b/tests/DependencyInjection/Fixtures/xml/full.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/full.xml rename to tests/DependencyInjection/Fixtures/xml/full.xml diff --git a/test/DependencyInjection/Fixtures/xml/ignore_errors_integration_overridden.xml b/tests/DependencyInjection/Fixtures/xml/ignore_errors_integration_overridden.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/ignore_errors_integration_overridden.xml rename to tests/DependencyInjection/Fixtures/xml/ignore_errors_integration_overridden.xml diff --git a/test/DependencyInjection/Fixtures/xml/messenger_listener_disabled.xml b/tests/DependencyInjection/Fixtures/xml/messenger_listener_disabled.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/messenger_listener_disabled.xml rename to tests/DependencyInjection/Fixtures/xml/messenger_listener_disabled.xml diff --git a/test/DependencyInjection/Fixtures/xml/messenger_listener_overridden_priority.xml b/tests/DependencyInjection/Fixtures/xml/messenger_listener_overridden_priority.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/messenger_listener_overridden_priority.xml rename to tests/DependencyInjection/Fixtures/xml/messenger_listener_overridden_priority.xml diff --git a/test/DependencyInjection/Fixtures/xml/monolog_handler.xml b/tests/DependencyInjection/Fixtures/xml/monolog_handler.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/monolog_handler.xml rename to tests/DependencyInjection/Fixtures/xml/monolog_handler.xml diff --git a/test/DependencyInjection/Fixtures/xml/monolog_handler_disabled.xml b/tests/DependencyInjection/Fixtures/xml/monolog_handler_disabled.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/monolog_handler_disabled.xml rename to tests/DependencyInjection/Fixtures/xml/monolog_handler_disabled.xml diff --git a/test/DependencyInjection/Fixtures/xml/request_listener_overridden_priority.xml b/tests/DependencyInjection/Fixtures/xml/request_listener_overridden_priority.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/request_listener_overridden_priority.xml rename to tests/DependencyInjection/Fixtures/xml/request_listener_overridden_priority.xml diff --git a/test/DependencyInjection/Fixtures/xml/sub_request_listener_overridden_priority.xml b/tests/DependencyInjection/Fixtures/xml/sub_request_listener_overridden_priority.xml similarity index 100% rename from test/DependencyInjection/Fixtures/xml/sub_request_listener_overridden_priority.xml rename to tests/DependencyInjection/Fixtures/xml/sub_request_listener_overridden_priority.xml diff --git a/test/DependencyInjection/Fixtures/yml/console_command_listener_overridden_priority.yml b/tests/DependencyInjection/Fixtures/yml/console_command_listener_overridden_priority.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/console_command_listener_overridden_priority.yml rename to tests/DependencyInjection/Fixtures/yml/console_command_listener_overridden_priority.yml diff --git a/test/DependencyInjection/Fixtures/yml/empty_dsn.yml b/tests/DependencyInjection/Fixtures/yml/empty_dsn.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/empty_dsn.yml rename to tests/DependencyInjection/Fixtures/yml/empty_dsn.yml diff --git a/test/DependencyInjection/Fixtures/yml/error_listener_disabled.yml b/tests/DependencyInjection/Fixtures/yml/error_listener_disabled.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/error_listener_disabled.yml rename to tests/DependencyInjection/Fixtures/yml/error_listener_disabled.yml diff --git a/test/DependencyInjection/Fixtures/yml/error_listener_overridden_priority.yml b/tests/DependencyInjection/Fixtures/yml/error_listener_overridden_priority.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/error_listener_overridden_priority.yml rename to tests/DependencyInjection/Fixtures/yml/error_listener_overridden_priority.yml diff --git a/test/DependencyInjection/Fixtures/yml/error_types.yml b/tests/DependencyInjection/Fixtures/yml/error_types.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/error_types.yml rename to tests/DependencyInjection/Fixtures/yml/error_types.yml diff --git a/test/DependencyInjection/Fixtures/yml/full.yml b/tests/DependencyInjection/Fixtures/yml/full.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/full.yml rename to tests/DependencyInjection/Fixtures/yml/full.yml diff --git a/test/DependencyInjection/Fixtures/yml/ignore_errors_integration_overridden.yml b/tests/DependencyInjection/Fixtures/yml/ignore_errors_integration_overridden.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/ignore_errors_integration_overridden.yml rename to tests/DependencyInjection/Fixtures/yml/ignore_errors_integration_overridden.yml diff --git a/test/DependencyInjection/Fixtures/yml/messenger_listener_disabled.yml b/tests/DependencyInjection/Fixtures/yml/messenger_listener_disabled.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/messenger_listener_disabled.yml rename to tests/DependencyInjection/Fixtures/yml/messenger_listener_disabled.yml diff --git a/test/DependencyInjection/Fixtures/yml/messenger_listener_overridden_priority.yml b/tests/DependencyInjection/Fixtures/yml/messenger_listener_overridden_priority.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/messenger_listener_overridden_priority.yml rename to tests/DependencyInjection/Fixtures/yml/messenger_listener_overridden_priority.yml diff --git a/test/DependencyInjection/Fixtures/yml/monolog_handler.yml b/tests/DependencyInjection/Fixtures/yml/monolog_handler.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/monolog_handler.yml rename to tests/DependencyInjection/Fixtures/yml/monolog_handler.yml diff --git a/test/DependencyInjection/Fixtures/yml/monolog_handler_disabled.yml b/tests/DependencyInjection/Fixtures/yml/monolog_handler_disabled.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/monolog_handler_disabled.yml rename to tests/DependencyInjection/Fixtures/yml/monolog_handler_disabled.yml diff --git a/test/DependencyInjection/Fixtures/yml/request_listener_overridden_priority.yml b/tests/DependencyInjection/Fixtures/yml/request_listener_overridden_priority.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/request_listener_overridden_priority.yml rename to tests/DependencyInjection/Fixtures/yml/request_listener_overridden_priority.yml diff --git a/test/DependencyInjection/Fixtures/yml/sub_request_listener_overridden_priority.yml b/tests/DependencyInjection/Fixtures/yml/sub_request_listener_overridden_priority.yml similarity index 100% rename from test/DependencyInjection/Fixtures/yml/sub_request_listener_overridden_priority.yml rename to tests/DependencyInjection/Fixtures/yml/sub_request_listener_overridden_priority.yml diff --git a/test/DependencyInjection/PhpSentryExtensionTest.php b/tests/DependencyInjection/PhpSentryExtensionTest.php similarity index 89% rename from test/DependencyInjection/PhpSentryExtensionTest.php rename to tests/DependencyInjection/PhpSentryExtensionTest.php index e0880ece..c9031f27 100644 --- a/test/DependencyInjection/PhpSentryExtensionTest.php +++ b/tests/DependencyInjection/PhpSentryExtensionTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Sentry\SentryBundle\Test\DependencyInjection; +namespace Sentry\SentryBundle\Tests\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/test/DependencyInjection/SentryExtensionTest.php b/tests/DependencyInjection/SentryExtensionTest.php similarity index 98% rename from test/DependencyInjection/SentryExtensionTest.php rename to tests/DependencyInjection/SentryExtensionTest.php index ad9f5e93..946ae9df 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/tests/DependencyInjection/SentryExtensionTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Sentry\SentryBundle\Test\DependencyInjection; +namespace Sentry\SentryBundle\Tests\DependencyInjection; use Jean85\PrettyVersions; use Monolog\Logger as MonologLogger; @@ -134,7 +134,7 @@ public function consoleCommandListenerDataProvider(): \Generator */ public function testMessengerListener(string $fixture, int $tagPriority): void { - if (! interface_exists(MessageBusInterface::class)) { + if (!interface_exists(MessageBusInterface::class)) { $this->markTestSkipped('This test requires the "symfony/messenger" Composer package to be installed.'); } @@ -405,7 +405,7 @@ private function createContainerFromFixture(string $fixtureFile): ContainerBuild /** * @param array $methodCall - * @param mixed[] $arguments + * @param mixed[] $arguments */ private function assertDefinitionMethodCallAt(array $methodCall, string $method, array $arguments): void { diff --git a/test/DependencyInjection/XmlSentryExtensionTest.php b/tests/DependencyInjection/XmlSentryExtensionTest.php similarity index 89% rename from test/DependencyInjection/XmlSentryExtensionTest.php rename to tests/DependencyInjection/XmlSentryExtensionTest.php index f95d2ffc..e54808e2 100644 --- a/test/DependencyInjection/XmlSentryExtensionTest.php +++ b/tests/DependencyInjection/XmlSentryExtensionTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Sentry\SentryBundle\Test\DependencyInjection; +namespace Sentry\SentryBundle\Tests\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/test/DependencyInjection/YamlSentryExtensionTest.php b/tests/DependencyInjection/YamlSentryExtensionTest.php similarity index 90% rename from test/DependencyInjection/YamlSentryExtensionTest.php rename to tests/DependencyInjection/YamlSentryExtensionTest.php index 3004a0cc..eacf41b0 100644 --- a/test/DependencyInjection/YamlSentryExtensionTest.php +++ b/tests/DependencyInjection/YamlSentryExtensionTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Sentry\SentryBundle\Test\DependencyInjection; +namespace Sentry\SentryBundle\Tests\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/test/End2End/App/Controller/MainController.php b/tests/End2End/App/Controller/MainController.php similarity index 85% rename from test/End2End/App/Controller/MainController.php rename to tests/End2End/App/Controller/MainController.php index 500cccd1..c108fe8c 100644 --- a/test/End2End/App/Controller/MainController.php +++ b/tests/End2End/App/Controller/MainController.php @@ -1,6 +1,8 @@ requestStack->getCurrentRequest(); - assert($request instanceof Request); + \assert($request instanceof Request); $path['_controller'] = __CLASS__ . '::index'; $subRequest = $request->duplicate([], null, $path); diff --git a/test/End2End/App/Controller/MessengerController.php b/tests/End2End/App/Controller/MessengerController.php similarity index 75% rename from test/End2End/App/Controller/MessengerController.php rename to tests/End2End/App/Controller/MessengerController.php index b7fb69b9..46afffec 100644 --- a/test/End2End/App/Controller/MessengerController.php +++ b/tests/End2End/App/Controller/MessengerController.php @@ -1,14 +1,18 @@ shouldRetry()) { - throw new class() extends \Exception implements UnrecoverableExceptionInterface { - }; + if (!$message->shouldRetry()) { + throw new class() extends \Exception implements UnrecoverableExceptionInterface { }; } - throw new \Exception('This is an intentional failure while handling a message of class ' . get_class($message)); + throw new \Exception('This is an intentional failure while handling a message of class ' . \get_class($message)); } } diff --git a/test/End2End/App/Messenger/StaticInMemoryTransport.php b/tests/End2End/App/Messenger/StaticInMemoryTransport.php similarity index 87% rename from test/End2End/App/Messenger/StaticInMemoryTransport.php rename to tests/End2End/App/Messenger/StaticInMemoryTransport.php index 8c9a4a6c..710da041 100644 --- a/test/End2End/App/Messenger/StaticInMemoryTransport.php +++ b/tests/End2End/App/Messenger/StaticInMemoryTransport.php @@ -1,6 +1,8 @@ assertInstanceOf(Response::class, $response); $this->assertSame(404, $response->getStatusCode()); } catch (\Throwable $exception) { - if (! $exception instanceof NotFoundHttpException) { + if (!$exception instanceof NotFoundHttpException) { throw $exception; } @@ -118,7 +120,7 @@ public function testGet500(): void $this->assertSame(500, $response->getStatusCode()); $this->assertStringContainsString('intentional error', $response->getContent() ?: ''); } catch (\Throwable $exception) { - if (! $exception instanceof \RuntimeException) { + if (!$exception instanceof \RuntimeException) { throw $exception; } @@ -253,7 +255,7 @@ private function assertLastEventIdIsNull(KernelBrowser $client): void private function skipIfMessengerIsMissing(): void { - if (! interface_exists(MessageBusInterface::class) || Kernel::VERSION_ID < 40300) { + if (!interface_exists(MessageBusInterface::class) || Kernel::VERSION_ID < 40300) { $this->markTestSkipped('Messenger missing'); } } diff --git a/test/End2End/StubTransportFactory.php b/tests/End2End/StubTransportFactory.php similarity index 95% rename from test/End2End/StubTransportFactory.php rename to tests/End2End/StubTransportFactory.php index 961db399..3daa0bfd 100644 --- a/test/End2End/StubTransportFactory.php +++ b/tests/End2End/StubTransportFactory.php @@ -1,6 +1,8 @@ supportsMessenger()) { + if (!$this->supportsMessenger()) { $this->markTestSkipped('Messenger not supported in this environment.'); } - $this->hub->expects($this->exactly(count($exceptions))) + $this->hub->expects($this->exactly(\count($exceptions))) ->method('captureException') ->withConsecutive(...array_map(static function (\Throwable $exception): array { return [$exception]; @@ -62,7 +64,7 @@ public function testHandleWorkerMessageFailedEvent(array $exceptions, WorkerMess */ public function handleWorkerMessageFailedEventDataProvider(): \Generator { - if (! $this->supportsMessenger()) { + if (!$this->supportsMessenger()) { return; } @@ -92,7 +94,7 @@ public function handleWorkerMessageFailedEventDataProvider(): \Generator */ public function testHandleWorkerMessageFailedEventWithCaptureSoftFailsFlag(bool $captureSoftFails, bool $retry, bool $shouldCallFlush): void { - if (! $this->supportsMessenger()) { + if (!$this->supportsMessenger()) { $this->markTestSkipped('Messenger not supported in this environment.'); } @@ -142,7 +144,7 @@ public function handleWorkerMessageFailedEventWithCaptureSoftFailsFlagDataProvid public function testHandleWorkerMessageHandledEvent(): void { - if (! $this->supportsMessenger()) { + if (!$this->supportsMessenger()) { $this->markTestSkipped('Messenger not supported in this environment.'); } diff --git a/test/EventListener/RequestListenerTest.php b/tests/EventListener/RequestListenerTest.php similarity index 99% rename from test/EventListener/RequestListenerTest.php rename to tests/EventListener/RequestListenerTest.php index 8ed13045..92914053 100644 --- a/test/EventListener/RequestListenerTest.php +++ b/tests/EventListener/RequestListenerTest.php @@ -1,6 +1,8 @@ $expectedTags + * @param array $expectedTags */ public function testHandleKernelControllerEvent($controllerEvent, array $expectedTags): void { diff --git a/test/EventListener/SubRequestListenerTest.php b/tests/EventListener/SubRequestListenerTest.php similarity index 97% rename from test/EventListener/SubRequestListenerTest.php rename to tests/EventListener/SubRequestListenerTest.php index 2c742566..b941f9c9 100644 --- a/test/EventListener/SubRequestListenerTest.php +++ b/tests/EventListener/SubRequestListenerTest.php @@ -1,6 +1,8 @@