-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from codex-team/hawk-2.0
Hawk 2.0
- Loading branch information
Showing
25 changed files
with
1,351 additions
and
719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ composer.lock | |
vendor/ | ||
.idea/ | ||
.DS_Store | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
return PhpCsFixer\Config::create() | ||
->setUsingCache(false) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'binary_operator_spaces' => ['align_double_arrow' => true], | ||
'blank_line_before_return' => true, | ||
'cast_spaces' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'declare_equal_normalize' => true, | ||
'line_ending' => false, | ||
'method_argument_space' => true, | ||
'method_separation' => true, | ||
'no_blank_lines_before_namespace' => false, | ||
'no_empty_statement' => true, | ||
'no_leading_import_slash' => true, | ||
'no_leading_namespace_whitespace' => true, | ||
'no_multiline_whitespace_around_double_arrow' => true, | ||
'no_multiline_whitespace_before_semicolons' => true, | ||
'no_trailing_comma_in_list_call' => true, | ||
'no_trailing_comma_in_singleline_array' => true, | ||
'no_unused_imports' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_add_missing_param_annotation' => true, | ||
'phpdoc_align' => true, | ||
'phpdoc_indent' => true, | ||
'phpdoc_no_empty_return' => false, | ||
'phpdoc_order' => false, | ||
'phpdoc_separation' => true, | ||
'phpdoc_scalar' => true, | ||
'return_type_declaration' => true, | ||
'short_scalar_cast' => true, | ||
'single_import_per_statement' => false, | ||
'single_quote' => true, | ||
'ternary_operator_spaces' => true, | ||
'trim_array_spaces' => true, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
{ | ||
"name": "codex-team/hawk.php", | ||
"description": "PHP errors Catcher module for Hawk.so", | ||
"keywords": ["hawk", "php", "error", "catcher", "monolog"], | ||
"type": "library", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"require": { | ||
"ext-curl": "*", | ||
"php": ">=5.3" | ||
"ext-json": "*", | ||
"php": "^7.1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.2", | ||
"friendsofphp/php-cs-fixer": "^2.15", | ||
"symfony/var-dumper": "^5.2" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/Hawk.php" | ||
], | ||
"psr-4": {"Hawk\\": "src/"} | ||
"psr-4": { | ||
"Hawk\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Hawk\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpunit --testdox", | ||
"csfix": "vendor/bin/php-cs-fixer fix --config=.php_cs --verbose" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* To run this example script | ||
* | ||
* 1. Update integrationToken | ||
* 2. Ignore url to use production collector | ||
* 3. Install composer deps: composer install | ||
* 4. Run the script: php -e example.php | ||
*/ | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
\Hawk\Catcher::init([ | ||
'integrationToken' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcm9qZWN0SWQiOiI2MDY2ZWI5N2U3NTU2ZDAwMjM2M2UyNjYiLCJpYXQiOjE2MTczNTc3MTl9.OpelHPPvS_TB8wUqCHRzcO3-Cp1VNL0UzlFuMfR35tk', | ||
'release' => '12345', | ||
'url' => 'http://localhost:3000/' | ||
]); | ||
|
||
$a = 1 / 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutOutputDuringTests="true" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Hawk PHP catcher suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hawk\Addons; | ||
|
||
/** | ||
* Interface Addon | ||
* | ||
* @package Hawk\Addons | ||
*/ | ||
interface AddonInterface | ||
{ | ||
/** | ||
* Returns addon extra data | ||
* | ||
* @return array | ||
*/ | ||
public function resolve(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hawk\Addons; | ||
|
||
/** | ||
* Class Headers | ||
* | ||
* @package Hawk\Addons | ||
*/ | ||
class Headers implements AddonInterface | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private $fields = [ | ||
'DOCUMENT_ROOT', | ||
'REMOTE_ADDR', | ||
'REMOTE_PORT', | ||
'SERVER_PROTOCOL', | ||
'SERVER_NAME', | ||
'SERVER_PORT', | ||
'HTTP_CONNECTION', | ||
'HTTP_CACHE_CONTROL', | ||
'HTTP_USER_AGENT', | ||
'HTTP_ACCEPT', | ||
'QUERY_STRING' | ||
]; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function resolve(): array | ||
{ | ||
$result = []; | ||
foreach ($this->fields as $field) { | ||
$result[$field] = $_SERVER[$field] ?? ''; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hawk\Addons; | ||
|
||
/** | ||
* Class Os | ||
* | ||
* @package Hawk\Addons | ||
*/ | ||
class Os implements AddonInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function resolve(): array | ||
{ | ||
return [ | ||
'name' => php_uname('s'), | ||
'version' => php_uname('r'), | ||
'build' => php_uname('v'), | ||
'kernel_version' => php_uname('a'), | ||
]; | ||
} | ||
} |
Oops, something went wrong.