Add php-cs-fixer (#50)
* Add php-cs-fixer to dev requirements * Ignore php-cs-fixer cache file * Add style guide configuration file * Correct style of all PHP files * Add Makefile target for style fixing
This commit is contained in:
parent
ca6d8fc15b
commit
7fe89db0ae
|
|
@ -2,4 +2,5 @@ composer.phar
|
|||
vendor
|
||||
.idea/
|
||||
coverage.clover
|
||||
tests/coverage
|
||||
tests/coverage
|
||||
.php_cs.cache
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('var/cache')
|
||||
->in(__DIR__);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'declare_equal_normalize' => ['space' => 'none'],
|
||||
'is_null' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'ordered_imports' => true,
|
||||
'php_unit_construct' => true,
|
||||
'single_line_comment_style' => true,
|
||||
'yoda_style' => false,
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'blank_line_before_statement' => true,
|
||||
'cast_spaces' => true,
|
||||
'declare_strict_types' => true,
|
||||
'function_typehint_space' => true,
|
||||
'include' => true,
|
||||
'lowercase_cast' => true,
|
||||
'new_with_braces' => true,
|
||||
'no_extra_consecutive_blank_lines' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_short_echo_tag' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_types' => true,
|
||||
'short_scalar_cast' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_quote' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder($finder);
|
||||
2
Makefile
2
Makefile
|
|
@ -12,4 +12,6 @@ examples: FORCE
|
|||
$(DC_RUN_PHP) php ./examples/AlwaysOnTraceExample.php
|
||||
bash:
|
||||
$(DC_RUN_PHP) bash
|
||||
style:
|
||||
$(DC_RUN_PHP) php ./vendor/bin/php-cs-fixer fix
|
||||
FORCE:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5.16",
|
||||
"composer/xdebug-handler": "^1.3",
|
||||
"phan/phan": "^2.4"
|
||||
"phan/phan": "^2.4",
|
||||
"friendsofphp/php-cs-fixer": "^2.16"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2716ff13f408c12d4c10970cc416a6ac",
|
||||
"content-hash": "ad5181452a8f29b7c5447e07c90c91d2",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
|
|
@ -113,6 +113,74 @@
|
|||
],
|
||||
"time": "2019-11-06T16:40:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
"version": "v1.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/annotations.git",
|
||||
"reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc",
|
||||
"reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/lexer": "1.*",
|
||||
"php": "^7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/cache": "1.*",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Docblock Annotations Parser",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"annotations",
|
||||
"docblock",
|
||||
"parser"
|
||||
],
|
||||
"time": "2019-10-01T18:55:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.3.0",
|
||||
|
|
@ -169,6 +237,68 @@
|
|||
],
|
||||
"time": "2019-10-21T16:45:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6",
|
||||
"reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^6.0",
|
||||
"phpstan/phpstan": "^0.11.8",
|
||||
"phpunit/phpunit": "^8.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
|
||||
"keywords": [
|
||||
"annotations",
|
||||
"docblock",
|
||||
"lexer",
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"time": "2019-10-30T14:39:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "felixfbecker/advanced-json-rpc",
|
||||
"version": "v3.0.4",
|
||||
|
|
@ -210,6 +340,95 @@
|
|||
"description": "A more advanced JSONRPC implementation",
|
||||
"time": "2019-09-12T22:41:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v2.16.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
|
||||
"reference": "c8afb599858876e95e8ebfcd97812d383fa23f02"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02",
|
||||
"reference": "c8afb599858876e95e8ebfcd97812d383fa23f02",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer/semver": "^1.4",
|
||||
"composer/xdebug-handler": "^1.2",
|
||||
"doctrine/annotations": "^1.2",
|
||||
"ext-json": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"php": "^5.6 || ^7.0",
|
||||
"php-cs-fixer/diff": "^1.3",
|
||||
"symfony/console": "^3.4.17 || ^4.1.6 || ^5.0",
|
||||
"symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0",
|
||||
"symfony/filesystem": "^3.0 || ^4.0 || ^5.0",
|
||||
"symfony/finder": "^3.0 || ^4.0 || ^5.0",
|
||||
"symfony/options-resolver": "^3.0 || ^4.0 || ^5.0",
|
||||
"symfony/polyfill-php70": "^1.0",
|
||||
"symfony/polyfill-php72": "^1.4",
|
||||
"symfony/process": "^3.0 || ^4.0 || ^5.0",
|
||||
"symfony/stopwatch": "^3.0 || ^4.0 || ^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
|
||||
"justinrainbow/json-schema": "^5.0",
|
||||
"keradus/cli-executor": "^1.2",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"php-coveralls/php-coveralls": "^2.1",
|
||||
"php-cs-fixer/accessible-object": "^1.0",
|
||||
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1",
|
||||
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
|
||||
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
|
||||
"phpunitgoodpractices/traits": "^1.8",
|
||||
"symfony/phpunit-bridge": "^4.3 || ^5.0",
|
||||
"symfony/yaml": "^3.0 || ^4.0 || ^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
|
||||
"php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.",
|
||||
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.",
|
||||
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
|
||||
},
|
||||
"bin": [
|
||||
"php-cs-fixer"
|
||||
],
|
||||
"type": "application",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpCsFixer\\": "src/"
|
||||
},
|
||||
"classmap": [
|
||||
"tests/Test/AbstractFixerTestCase.php",
|
||||
"tests/Test/AbstractIntegrationCaseFactory.php",
|
||||
"tests/Test/AbstractIntegrationTestCase.php",
|
||||
"tests/Test/Assert/AssertTokensTrait.php",
|
||||
"tests/Test/IntegrationCase.php",
|
||||
"tests/Test/IntegrationCaseFactory.php",
|
||||
"tests/Test/IntegrationCaseFactoryInterface.php",
|
||||
"tests/Test/InternalIntegrationCaseFactory.php",
|
||||
"tests/TestCase.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Dariusz Rumiński",
|
||||
"email": "dariusz.ruminski@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A tool to automatically fix PHP code style",
|
||||
"time": "2019-11-25T22:10:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "microsoft/tolerant-php-parser",
|
||||
"version": "v0.0.18",
|
||||
|
|
@ -345,6 +564,51 @@
|
|||
"description": "Map nested JSON structures onto PHP classes",
|
||||
"time": "2019-08-15T19:41:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/random_compat.git",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*|5.*",
|
||||
"vimeo/psalm": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||
},
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||
"keywords": [
|
||||
"csprng",
|
||||
"polyfill",
|
||||
"pseudorandom",
|
||||
"random"
|
||||
],
|
||||
"time": "2018-07-02T15:55:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phan/phan",
|
||||
"version": "2.4.5",
|
||||
|
|
@ -520,6 +784,57 @@
|
|||
"description": "Library for handling version information and constraints",
|
||||
"time": "2018-07-08T19:19:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-cs-fixer/diff",
|
||||
"version": "v1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/diff.git",
|
||||
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756",
|
||||
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7.23 || ^6.4.3",
|
||||
"symfony/process": "^3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "SpacePossum"
|
||||
}
|
||||
],
|
||||
"description": "sebastian/diff v2 backport support for PHP5.6",
|
||||
"homepage": "https://github.com/PHP-CS-Fixer",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2018-02-15T16:58:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.0.0",
|
||||
|
|
@ -1867,6 +2182,287 @@
|
|||
"homepage": "https://symfony.com",
|
||||
"time": "2019-12-17T10:32:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v4.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "9e3de195e5bc301704dd6915df55892f6dfc208b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9e3de195e5bc301704dd6915df55892f6dfc208b",
|
||||
"reference": "9e3de195e5bc301704dd6915df55892f6dfc208b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/event-dispatcher-contracts": "^1.1"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<3.4"
|
||||
},
|
||||
"provide": {
|
||||
"psr/event-dispatcher-implementation": "1.0",
|
||||
"symfony/event-dispatcher-implementation": "1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "^3.4|^4.0|^5.0",
|
||||
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
|
||||
"symfony/expression-language": "^3.4|^4.0|^5.0",
|
||||
"symfony/http-foundation": "^3.4|^4.0|^5.0",
|
||||
"symfony/service-contracts": "^1.1|^2",
|
||||
"symfony/stopwatch": "^3.4|^4.0|^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-10T21:54:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher-contracts",
|
||||
"version": "v1.1.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
|
||||
"reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18",
|
||||
"reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/event-dispatcher": "",
|
||||
"symfony/event-dispatcher-implementation": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Contracts\\EventDispatcher\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Generic abstractions related to dispatching event",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"abstractions",
|
||||
"contracts",
|
||||
"decoupling",
|
||||
"interfaces",
|
||||
"interoperability",
|
||||
"standards"
|
||||
],
|
||||
"time": "2019-09-17T09:54:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v5.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
"reference": "3afadc0f57cd74f86379d073e694b0f2cda2a88c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/3afadc0f57cd74f86379d073e694b0f2cda2a88c",
|
||||
"reference": "3afadc0f57cd74f86379d073e694b0f2cda2a88c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Filesystem\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-21T08:40:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v5.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/4176e7cb846fe08f32518b7e0ed8462e2db8d9bb",
|
||||
"reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Finder\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-04T14:08:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v5.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "b1ab86ce52b0c0abe031367a173005a025e30e04"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/b1ab86ce52b0c0abe031367a173005a025e30e04",
|
||||
"reference": "b1ab86ce52b0c0abe031367a173005a025e30e04",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\OptionsResolver\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony OptionsResolver Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"options"
|
||||
],
|
||||
"time": "2020-01-04T14:08:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.13.1",
|
||||
|
|
@ -1984,6 +2580,120 @@
|
|||
],
|
||||
"time": "2019-11-27T14:18:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php70",
|
||||
"version": "v1.13.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php70.git",
|
||||
"reference": "af23c7bb26a73b850840823662dda371484926c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4",
|
||||
"reference": "af23c7bb26a73b850840823662dda371484926c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"paragonie/random_compat": "~1.0|~2.0|~9.99",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php70\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2019-11-27T13:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php72",
|
||||
"version": "v1.13.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php72.git",
|
||||
"reference": "66fea50f6cb37a35eea048d75a7d99a45b586038"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038",
|
||||
"reference": "66fea50f6cb37a35eea048d75a7d99a45b586038",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php72\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2019-11-27T13:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php73",
|
||||
"version": "v1.13.1",
|
||||
|
|
@ -2042,6 +2752,55 @@
|
|||
],
|
||||
"time": "2019-11-27T16:25:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v5.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1",
|
||||
"reference": "f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Process\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-09T09:53:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v1.1.8",
|
||||
|
|
@ -2100,6 +2859,56 @@
|
|||
],
|
||||
"time": "2019-10-14T12:27:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v5.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/stopwatch.git",
|
||||
"reference": "5d9add8034135b9a5f7b101d1e42c797e7f053e4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/5d9add8034135b9a5f7b101d1e42c797e7f053e4",
|
||||
"reference": "5d9add8034135b9a5f7b101d1e42c797e7f053e4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"symfony/service-contracts": "^1.0|^2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Stopwatch\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-04T14:08:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.1.3",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use OpenTelemetry\Trace\Sampler\AlwaysOffSampler;
|
||||
|
|
@ -19,11 +21,11 @@ if ($sampler) {
|
|||
'username' => 'otuser',
|
||||
]);
|
||||
$span->addEvent('generated_session', [
|
||||
'id' => md5(microtime(true))
|
||||
'id' => md5(microtime(true)),
|
||||
]);
|
||||
|
||||
$span->end(); // pass status as an optional argument
|
||||
print_r($span); // print the span as a resulting output
|
||||
} else {
|
||||
echo "Sampling is not enabled";
|
||||
echo 'Sampling is not enabled';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use OpenTelemetry\Exporter\ZipkinExporter;
|
||||
use OpenTelemetry\Trace\Sampler\AlwaysOnSampler;
|
||||
use OpenTelemetry\Trace\SpanProcessor\SimpleSpanProcessor;
|
||||
use OpenTelemetry\Trace\TracerFactory;
|
||||
use OpenTelemetry\Trace\Sampler\AlwaysOnSampler;
|
||||
|
||||
$sampler = AlwaysOnSampler::shouldSample();
|
||||
|
||||
|
|
@ -18,24 +20,24 @@ if ($sampler) {
|
|||
[new SimpleSpanProcessor($zipkinExporter)]
|
||||
))
|
||||
->getTracer('io.opentelemetry.contrib.php');
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
// start a span, register some events
|
||||
$span = $tracer->createSpan('session.generate.span'. $i);
|
||||
$tracer->setActiveSpan($span);
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
// start a span, register some events
|
||||
$span = $tracer->createSpan('session.generate.span' . $i);
|
||||
$tracer->setActiveSpan($span);
|
||||
|
||||
$span->setAttributes(['remote_ip' => '1.2.3.4']);
|
||||
$span->setAttribute('country', 'USA');
|
||||
$span->setAttributes(['remote_ip' => '1.2.3.4']);
|
||||
$span->setAttribute('country', 'USA');
|
||||
|
||||
$span->addEvent('found_login'. $i, [
|
||||
$span->addEvent('found_login' . $i, [
|
||||
'id' => $i,
|
||||
'username' => 'otuser' . $i,
|
||||
]);
|
||||
$span->addEvent('generated_session', [
|
||||
'id' => md5(microtime(true))
|
||||
$span->addEvent('generated_session', [
|
||||
'id' => md5(microtime(true)),
|
||||
]);
|
||||
|
||||
$tracer->endActiveSpan();
|
||||
}
|
||||
$tracer->endActiveSpan();
|
||||
}
|
||||
} else {
|
||||
echo "Sampling is not enabled";
|
||||
echo 'Sampling is not enabled';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ class SpanContext
|
|||
return $this->spanId;
|
||||
}
|
||||
|
||||
/* TODO : Finish this function */
|
||||
// TODO : Finish this function
|
||||
public function IsValid() : bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* TODO : Finish this function */
|
||||
// TODO : Finish this function
|
||||
public function IsRemote() : bool
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -56,13 +56,11 @@ class ZipkinExporter implements ExporterInterface
|
|||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-Type: application/json',
|
||||
'content' => $json
|
||||
]
|
||||
'content' => $json,
|
||||
],
|
||||
];
|
||||
$context = stream_context_create($contextOptions);
|
||||
file_get_contents($this->getEndpointUrl(), false, $context);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
return ExporterInterface::FAILED_RETRYABLE;
|
||||
}
|
||||
|
|
@ -86,11 +84,11 @@ class ZipkinExporter implements ExporterInterface
|
|||
: null,
|
||||
'localEndpoint' => [
|
||||
'serviceName' => $this->name,
|
||||
'port' => $this->getEndpoint()['port'] ?? 0
|
||||
'port' => $this->getEndpoint()['port'] ?? 0,
|
||||
],
|
||||
'name' => $span->getName(),
|
||||
'timestamp' => (integer) round($span->getStart()*1000000),
|
||||
'duration' => (integer) round($span->getEnd()*1000000) - round($span->getStart()*1000000),
|
||||
'timestamp' => (int) round($span->getStart()*1000000),
|
||||
'duration' => (int) round($span->getEnd()*1000000) - round($span->getStart()*1000000),
|
||||
];
|
||||
|
||||
foreach ($span->getAttributes() as $k => $v) {
|
||||
|
|
@ -143,13 +141,14 @@ class ZipkinExporter implements ExporterInterface
|
|||
}
|
||||
|
||||
$this->endpoint = $endpoint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getEndpointUrl(): string
|
||||
{
|
||||
return sprintf(
|
||||
"%s://%s:%s%s",
|
||||
'%s://%s:%s%s',
|
||||
$this->endpoint['scheme'],
|
||||
$this->endpoint['host'],
|
||||
$this->endpoint['port'],
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Event
|
|||
|
||||
public function __construct(string $name, iterable $attributes = [], $timestamp = null)
|
||||
{
|
||||
if (is_null($timestamp)) {
|
||||
if (null === $timestamp) {
|
||||
$timestamp = microtime(true);
|
||||
}
|
||||
$this->name = $name;
|
||||
|
|
@ -25,12 +25,14 @@ class Event
|
|||
if (!array_key_exists($key, $this->attributes)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
public function setAttribute(string $key, $value) : self
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -45,6 +47,7 @@ class Event
|
|||
foreach ($attributes as $k => $v) {
|
||||
$this->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -57,4 +60,4 @@ class Event
|
|||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace\Sampler;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace\Sampler;
|
||||
|
||||
/**
|
||||
|
|
@ -25,4 +28,4 @@ class AlwaysOnSampler implements SamplerInterface
|
|||
{
|
||||
return self::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace\Sampler;
|
||||
|
||||
/**
|
||||
|
|
@ -22,4 +25,4 @@ interface SamplerInterface
|
|||
* @return string
|
||||
*/
|
||||
public function getDescription(): string;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace;
|
||||
|
|
@ -64,13 +65,12 @@ class Span
|
|||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function end(int $statusCode = Status::OK, ?string $statusDescription = null, float $timestamp = null): self
|
||||
{
|
||||
$this->end = $timestamp ?? microtime(true);
|
||||
$this->statusCode = $statusCode;
|
||||
$this->statusDescription = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ class Span
|
|||
// -> This had an update this past month: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-tracing.md#isrecording
|
||||
public function isRecording(): bool
|
||||
{
|
||||
return is_null($this->end);
|
||||
return null === $this->end;
|
||||
}
|
||||
|
||||
public function getDuration(): ?float
|
||||
|
|
@ -101,6 +101,7 @@ class Span
|
|||
if (!$this->end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->end - $this->start;
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +113,7 @@ class Span
|
|||
public function updateName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +122,7 @@ class Span
|
|||
if (!array_key_exists($key, $this->attributes)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +133,7 @@ class Span
|
|||
}
|
||||
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +150,7 @@ class Span
|
|||
foreach ($attributes as $k => $v) {
|
||||
$this->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +162,7 @@ class Span
|
|||
$event = new Event($name, $attributes, $timestamp);
|
||||
// todo: check that these are all Attributes -> What do we want to check about these? Just a 'property_exist' check on this?
|
||||
$this->events[] = $event;
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +184,7 @@ class Span
|
|||
private function throwIfNotRecording()
|
||||
{
|
||||
if (!$this->isRecording()) {
|
||||
throw new Exception("Span is readonly");
|
||||
throw new Exception('Span is readonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace\SpanProcessor;
|
||||
|
||||
use OpenTelemetry\Exporter\ExporterInterface;
|
||||
|
|
@ -34,4 +36,4 @@ class SimpleSpanProcessor implements SpanProcessorInterface
|
|||
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-tracing.md#sampling
|
||||
$this->exporter->export([$span]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace\SpanProcessor;
|
||||
|
||||
use OpenTelemetry\Trace\Span;
|
||||
|
|
@ -23,4 +25,4 @@ interface SpanProcessorInterface
|
|||
/* The spec mentions a shutdown() function. We don't see this as necessary;
|
||||
* if an Exporter needs to clean up, it can use a destructor.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class Status
|
|||
|
||||
private $code;
|
||||
private $description;
|
||||
static private $ok;
|
||||
private static $ok;
|
||||
|
||||
public function __construct(int $code, string $description = null)
|
||||
{
|
||||
|
|
@ -54,19 +54,22 @@ class Status
|
|||
if (!$description && array_key_exists($code, self::DESCRIPTION)) {
|
||||
$description = self::DESCRIPTION[$code];
|
||||
}
|
||||
if (!is_null($description)) {
|
||||
if (null !== $description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
}
|
||||
|
||||
public static function new(int $code, string $description = null) {
|
||||
public static function new(int $code, string $description = null)
|
||||
{
|
||||
if ($code === self::OK && ($description === null || $description == self::DESCRIPTION[self::OK])) {
|
||||
return self::$ok;
|
||||
}
|
||||
|
||||
return new Status($code, $description);
|
||||
}
|
||||
|
||||
public static function initOk() {
|
||||
public static function initOk()
|
||||
{
|
||||
if (!self::$ok) {
|
||||
self::$ok = new Status(self::OK);
|
||||
}
|
||||
|
|
@ -88,4 +91,4 @@ class Status
|
|||
}
|
||||
}
|
||||
|
||||
Status::initOk();
|
||||
Status::initOk();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Tracer
|
|||
* Tracer constructor.
|
||||
*
|
||||
* @param SpanProcessorInterface[] $spanProcessors
|
||||
* @param SpanContext|NULL $context
|
||||
* @param SpanContext|null $context
|
||||
*/
|
||||
public function __construct(iterable $spanProcessors = [], SpanContext $context = null)
|
||||
{
|
||||
|
|
@ -35,12 +35,14 @@ class Tracer
|
|||
while (count($this->tail) && $this->active->getEnd()) {
|
||||
$this->active = array_pop($this->tail);
|
||||
}
|
||||
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActiveSpan(Span $span): Span
|
||||
{
|
||||
$this->tail[] = $this->active;
|
||||
|
||||
return $this->active = $span;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +95,7 @@ class Tracer
|
|||
int $statusCode = Status::OK,
|
||||
?string $statusDescription = null,
|
||||
float $timestamp = null
|
||||
){
|
||||
) {
|
||||
if ($this->getActiveSpan()->isRecording()) {
|
||||
foreach ($this->spanProcessors as $spanProcessor) {
|
||||
$spanProcessor->onEnd($this->getActiveSpan());
|
||||
|
|
@ -111,6 +113,7 @@ class Tracer
|
|||
}
|
||||
$span = new Span($name, $context, $parent);
|
||||
$this->spans[] = $span;
|
||||
|
||||
return $span;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Trace;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
|
@ -34,9 +36,9 @@ class TracerFactory
|
|||
if (!$spanProcessor instanceof SpanProcessorInterface) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
"Span Processors should be of type %s, but object of type %s provided",
|
||||
'Span Processors should be of type %s, but object of type %s provided',
|
||||
SpanProcessorInterface::class,
|
||||
gettype($spanProcessor) == "object" ? get_class($spanProcessor) : gettype($spanProcessor)
|
||||
gettype($spanProcessor) == 'object' ? get_class($spanProcessor) : gettype($spanProcessor)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -61,14 +63,14 @@ class TracerFactory
|
|||
return self::$instance = $instance;
|
||||
}
|
||||
|
||||
public function getTracer(string $name, string $version = ""): Tracer
|
||||
public function getTracer(string $name, string $version = ''): Tracer
|
||||
{
|
||||
|
||||
if ($this->tracers[$name] instanceof Tracer) {
|
||||
return $this->tracers[$name];
|
||||
}
|
||||
|
||||
$spanContext = SpanContext::generate();
|
||||
|
||||
return $this->tracers[$name] = new Tracer($this->spanProcessors, $spanContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ namespace OpenTelemetry;
|
|||
interface TransportInterface
|
||||
{
|
||||
public function write(array $data) : bool;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace OpenTelemetry\Tests\Integration;
|
||||
|
||||
use OpenTelemetry\Context\SpanContext;
|
||||
use OpenTelemetry\Exporter\BasisExporter;
|
||||
use OpenTelemetry\Exporter\ZipkinExporter;
|
||||
use OpenTelemetry\Context\SpanContext;
|
||||
use OpenTelemetry\Trace\Status;
|
||||
use OpenTelemetry\Trace\Tracer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -42,7 +42,7 @@ class TracingTest extends TestCase
|
|||
|
||||
public function testSpanNameUpdate()
|
||||
{
|
||||
$database = (new Tracer)->createSpan('database');
|
||||
$database = (new Tracer())->createSpan('database');
|
||||
$this->assertSame($database->getName(), 'database');
|
||||
$database->updateName('tarantool');
|
||||
$this->assertSame($database->getName(), 'tarantool');
|
||||
|
|
@ -152,17 +152,17 @@ class TracingTest extends TestCase
|
|||
$span->setAttribute('b', 4);
|
||||
$this->assertSame(array_keys($span->getAttributes()), ['b', 'a']);
|
||||
|
||||
$this->expectExceptionMessage("Span is readonly");
|
||||
$this->expectExceptionMessage('Span is readonly');
|
||||
$span->end();
|
||||
$span->setAttribute('b', 5);
|
||||
}
|
||||
|
||||
public function testEventRegistration()
|
||||
{
|
||||
$span = (new Tracer)->createSpan('database');
|
||||
$span = (new Tracer())->createSpan('database');
|
||||
$event = $span->addEvent('select', [
|
||||
'space' => 'guard.session',
|
||||
'id' => 67235
|
||||
'id' => 67235,
|
||||
]);
|
||||
$this->assertSame($event->getName(), 'select');
|
||||
$this->assertSame($event->getAttributes(), [
|
||||
|
|
@ -181,7 +181,7 @@ class TracingTest extends TestCase
|
|||
|
||||
$this->assertCount(2, $span->getEvents());
|
||||
|
||||
$this->expectExceptionMessage("Span is readonly");
|
||||
$this->expectExceptionMessage('Span is readonly');
|
||||
$span->end();
|
||||
$span->addEvent('update');
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ class TracingTest extends TestCase
|
|||
|
||||
public function testParentSpanContext()
|
||||
{
|
||||
$tracer = new Tracer;
|
||||
$tracer = new Tracer();
|
||||
$global = $tracer->getActiveSpan();
|
||||
$request = $tracer->createSpan('request');
|
||||
$this->assertSame($request->getParentContext()->getSpanId(), $global->getContext()->getSpanId());
|
||||
|
|
@ -285,4 +285,4 @@ class TracingTest extends TestCase
|
|||
$this->assertSame($annotation['value'], $event->getName());
|
||||
$this->assertSame($annotation['timestamp'], 1000000 * $event->getTimestamp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Exporter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
|
@ -13,13 +15,12 @@ class ZipkinExporterTest extends TestCase
|
|||
*/
|
||||
public function shouldParseAnValidDsn()
|
||||
{
|
||||
$exporter = new ZipkinExporter('test.zipkin', "scheme://host:1234/path");
|
||||
$exporter = new ZipkinExporter('test.zipkin', 'scheme://host:1234/path');
|
||||
|
||||
$this->assertArrayHasKey('scheme', $exporter->getEndpoint());
|
||||
$this->assertArrayHasKey('host', $exporter->getEndpoint());
|
||||
$this->assertArrayHasKey('port', $exporter->getEndpoint());
|
||||
$this->assertArrayHasKey('path', $exporter->getEndpoint());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,4 +46,4 @@ class ZipkinExporterTest extends TestCase
|
|||
'invalid host' => ['scheme:///end:1234/path'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Trace\SpanProcessor;
|
||||
|
||||
use OpenTelemetry\Exporter\ExporterInterface;
|
||||
|
|
@ -21,4 +23,4 @@ class SimpleSpanProcessorTest extends TestCase
|
|||
self::createMock(Span::class)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Trace;
|
||||
|
||||
use Error;
|
||||
|
|
@ -56,12 +58,12 @@ class TracerFactoryTest extends TestCase
|
|||
*/
|
||||
public function shouldInstantiateWithoutErrorIfConfigurationIsOk()
|
||||
{
|
||||
$factory = TracerFactory::getInstance([
|
||||
$factory = TracerFactory::getInstance([
|
||||
$this->createMock(SpanProcessorInterface::class),
|
||||
$this->createMock(SpanProcessorInterface::class),
|
||||
$this->createMock(SpanProcessorInterface::class)
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(TracerFactory::class, $factory);
|
||||
$this->assertInstanceOf(TracerFactory::class, $factory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,17 +80,17 @@ class TracerFactoryTest extends TestCase
|
|||
{
|
||||
return [
|
||||
'array of numbers' => [
|
||||
'spanProcessors' => [1, -1, 0.1, -0.1, 0]
|
||||
'spanProcessors' => [1, -1, 0.1, -0.1, 0],
|
||||
],
|
||||
'array of strings' => [
|
||||
'spanProcessors' => ['aaa', 'bbb', '']
|
||||
'spanProcessors' => ['aaa', 'bbb', ''],
|
||||
],
|
||||
'array of standardObjects' => [
|
||||
'spanProcessors' => [new StdClass(), new StdClass()]
|
||||
'spanProcessors' => [new StdClass(), new StdClass()],
|
||||
],
|
||||
'array of boolean' => [
|
||||
'spanProcessors' => [true, false, null]
|
||||
]
|
||||
'spanProcessors' => [true, false, null],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Trace;
|
||||
|
||||
use OpenTelemetry\Trace\SpanProcessor\SpanProcessorInterface;
|
||||
|
|
@ -35,4 +37,4 @@ class TracerTest extends TestCase
|
|||
$tracer->createSpan('test.span');
|
||||
$tracer->endActiveSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Tracing\Sampler;
|
||||
|
||||
use OpenTelemetry\Trace\Sampler\AlwaysOffSampler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AlwaysOffSamplerTest extends TestCase
|
||||
{
|
||||
public function testAlwaysOffSampler()
|
||||
|
|
@ -10,4 +14,4 @@ class AlwaysOffSamplerTest extends TestCase
|
|||
$sampler = new AlwaysOffSampler();
|
||||
$this->assertFalse($sampler->shouldSample());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenTelemetry\Tests\Unit\Tracing\Sampler;
|
||||
|
||||
use OpenTelemetry\Trace\Sampler\AlwaysOnSampler;
|
||||
|
|
|
|||
Loading…
Reference in New Issue