Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2012: Remove PHP 7-only types from signatures #2021

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,30 @@ executors:
- <<: *IMAGE_DOCKER_REQUEST_REPLAYER

jobs:
"Lint PHP 5":
parameters:
resource_class:
type: string
default: small
<<: *BARE_DOCKER_MACHINE
steps:
- restore_cache:
keys:
- source-v1-{{ .Branch }}-{{ .Revision }}
- <<: *STEP_CHECKOUT
- <<: *STEP_ATTACH_WORKSPACE
- run:
command: |
docker run --rm -v "$HOME/datadog:/src" -i php:5.4-cli bash \<<'CMD'
set -eu
cd /src/bridge
for file in *.php; do
if [ "$file" != "_generated_integrations.php" ]; then
php -l "$file"
fi
done
CMD

"Lint files":
working_directory: ~/datadog
docker:
Expand Down Expand Up @@ -3514,6 +3538,8 @@ workflows:
docker_image: "datadog/dd-trace-ci:php-8.0-shared-ext"
- "Lint files":
requires: [ 'Prepare Code' ]
- "Lint PHP 5":
requires: [ 'Prepare Code' ]
- static_analysis:
requires: [ 'Prepare Code' ]
name: "Static Analysis 71"
Expand Down
14 changes: 5 additions & 9 deletions src/Integrations/Util/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,13 @@ public static function sanitizedQueryString()
);
}

private static function normalizeString(string $str)
private static function normalizeString($str)
{
return preg_replace('/[^a-zA-Z0-9\-\_)]+/', '_', $str);
}

private static function generateFilteredPostFields(
string $postKey,
$postVal,
array $whitelist,
bool $isPrefixed
): array {
private static function generateFilteredPostFields($postKey, $postVal, array $whitelist, $isPrefixed)
{
if (is_array($postVal)) {
$filteredPostFields = [];
foreach ($postVal as $key => $val) {
Expand Down Expand Up @@ -252,13 +248,13 @@ private static function generateFilteredPostFields(
}
}

private static function cleanRequestBody(array $requestBody, string $allowedParams): array
private static function cleanRequestBody(array $requestBody, $allowedParams)
{
$whitelist = self::decodeConfigSet($allowedParams);
return self::generateFilteredPostFields('', $requestBody, $whitelist, false);
}

public static function sanitizePostFields(array $postFields): array
public static function sanitizePostFields(array $postFields)
{
return self::cleanRequestBody(
$postFields,
Expand Down