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

feat: Add tooling to generate stubs for the Public PHP API #2933

Merged
merged 23 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
12 changes: 9 additions & 3 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3882,10 +3882,10 @@ jobs:
phpize
php run-tests.php -p $(which php) -d datadog.remote_config_enabled=false --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" tests/ext/profiling

"cbindgen up-to-date":
"generated files up-to-date":
working_directory: ~/datadog
docker:
- image: datadog/dd-trace-ci:buster
- image: datadog/dd-trace-ci:php-8.3_buster
steps:
- restore_cache:
keys:
Expand All @@ -3900,6 +3900,12 @@ jobs:
set -eu
make cbindgen
git diff --exit-code components-rs
- run:
name: Regenerate PHP stubs and compare them
command: |
set -eu
make generate_stubs
git diff --exit-code src/ddtrace_php_api.stubs.php
- run:
name: Ensure no non-bundled rust git dependencies are used
command: |
Expand Down Expand Up @@ -5738,7 +5744,7 @@ workflows:
name: "Static Analysis 80"
docker_image: datadog/dd-trace-ci:php-8.0_buster
scenario: opentracing10
- "cbindgen up-to-date"
- "generated files up-to-date"
- "Post-Install Hook":
requires: [ 'Prepare Code' ]

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ $(PACKAGES_BUILD_DIR):
bundle.tar.gz: $(PACKAGES_BUILD_DIR)
bash ./tooling/bin/generate-final-artifact.sh \
$(VERSION) \
$(PACKAGES_BUILD_DIR)
$(PACKAGES_BUILD_DIR) \
$(PROJECT_ROOT)

$(PACKAGES_BUILD_DIR)/datadog-setup.php: $(PACKAGES_BUILD_DIR)
bash ./tooling/bin/generate-installers.sh \
Expand Down Expand Up @@ -512,6 +513,11 @@ generate:
@composer -dtooling/generation generate
@composer -dtooling/generation verify

# Generates the stubs file for the public API
generate_stubs:
@composer -dtooling/stubs update
@composer -dtooling/stubs generate

# Find all generated core dumps, sorted by date descending
cores:
find . -path "./*/vendor" -prune -false -o \( -type f -regex ".*\/core\.?[0-9]*" \) -printf "%T@ %Tc %p\n" | sort -n -r
Expand Down
6 changes: 3 additions & 3 deletions ext/ddtrace.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ExceptionSpanEvent extends SpanEvent {
* @param array $attributes Optional attributes for the event.
*/
public function __construct(\Throwable $exception, array $attributes = []) {}

/**
* @var \Throwable
*/
Expand Down Expand Up @@ -798,7 +798,7 @@ function has_listeners(): bool {}
* @param string|resource|null $body the body of the request (a string or a seekable resource)
* @return array|null an array with the keys 'status', 'headers' and 'body', or null
*/
function notify_start(\DDTrace\RootSpanData $span, array $data, ?mixed $body = null): ?array {}
function notify_start(\DDTrace\RootSpanData $span, array $data, mixed $body = null): ?array {}

/**
* Notifies the user request listeners of the imminence of a commit, and allows for the replacement of the response.
Expand All @@ -808,7 +808,7 @@ function notify_start(\DDTrace\RootSpanData $span, array $data, ?mixed $body = n
* @param string|resource|null $body the body of the response (a string or a seekable resource)
* @return array|null an array with the keys 'status', 'headers' and 'body', or null
*/
function notify_commit(\DDTrace\RootSpanData $span, int $status, array $headers, ?mixed $body = null): ?array {}
function notify_commit(\DDTrace\RootSpanData $span, int $status, array $headers, mixed $body = null): ?array {}

/**
* Sets a function to be called when blocking a request midway.
Expand Down
6 changes: 3 additions & 3 deletions ext/ddtrace_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: fa4bda312fa3b405b09e09c6bc81a05d2a8e3372 */
* Stub hash: 5eb7dd922aab52cab793bd947871d8ee8ee0c284 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_trace_method, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, className, IS_STRING, 0)
Expand Down Expand Up @@ -163,14 +163,14 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_UserRequest_notify_start, 0, 2, IS_ARRAY, 1)
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\RootSpanData, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, body, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, body, IS_MIXED, 0, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_UserRequest_notify_commit, 0, 3, IS_ARRAY, 1)
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\RootSpanData, 0)
ZEND_ARG_TYPE_INFO(0, status, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, headers, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, body, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, body, IS_MIXED, 0, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_UserRequest_set_blocking_function, 0, 2, IS_VOID, 0)
Expand Down
Loading
Loading