Skip to content

Commit

Permalink
Merge branch 'main' into renovate/major-github-artifact-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Jan 23, 2025
2 parents 3c0f77a + 65587de commit 07ac54f
Show file tree
Hide file tree
Showing 814 changed files with 61,995 additions and 7,013 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
vendor/
bazel-*
MODULE.bazel.lock
MODULE.bazel

# PHP
.php_cs.cache
Expand Down
85 changes: 85 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,90 @@
# Changelog

## [1.18.0](https://github.com/googleapis/gapic-generator-php/compare/v1.17.0...v1.18.0) (2024-12-06)


### Features

* Add compatibility for PHP 8.4 ([#736](https://github.com/googleapis/gapic-generator-php/issues/736)) ([0d7b5eb](https://github.com/googleapis/gapic-generator-php/commit/0d7b5ebb54a3bc805647fa1a9feb5a46a8acec91))
* Add documentation for the Logger option inside the options array ([#731](https://github.com/googleapis/gapic-generator-php/issues/731)) ([4a2bdb1](https://github.com/googleapis/gapic-generator-php/commit/4a2bdb19c7894c9cd3f3a10d11ebaaef8b781c46))

## [1.17.0](https://github.com/googleapis/gapic-generator-php/compare/v1.16.1...v1.17.0) (2024-10-30)


### Features

* Generic type for docs in async magic methods ([#732](https://github.com/googleapis/gapic-generator-php/issues/732)) ([68c88ed](https://github.com/googleapis/gapic-generator-php/commit/68c88eddcef45e100d357218e7f141d4f3b92a4d))

## [1.16.1](https://github.com/googleapis/gapic-generator-php/compare/v1.16.0...v1.16.1) (2024-08-08)


### Bug Fixes

* Revert two optional to required fields for dialogflow ([#723](https://github.com/googleapis/gapic-generator-php/issues/723)) ([307d871](https://github.com/googleapis/gapic-generator-php/commit/307d871d55240dfb99ca837a4993f4db574fa1f8))

## [1.16.0](https://github.com/googleapis/gapic-generator-php/compare/v1.15.0...v1.16.0) (2024-06-04)


### Features

* Add emulator support for Bigtable and Spanner clients ([#719](https://github.com/googleapis/gapic-generator-php/issues/719)) ([83b772b](https://github.com/googleapis/gapic-generator-php/commit/83b772b63ca454542ef4a3f07590e082f18abab8))
* Add null coalescing assign ([#720](https://github.com/googleapis/gapic-generator-php/issues/720)) ([46f8670](https://github.com/googleapis/gapic-generator-php/commit/46f86705ea170345ea77cdfc65492733e343806d))

## [1.15.0](https://github.com/googleapis/gapic-generator-php/compare/v1.14.0...v1.15.0) (2024-05-30)


### Features

* New surface custom LROs ([#712](https://github.com/googleapis/gapic-generator-php/issues/712)) ([0afff0f](https://github.com/googleapis/gapic-generator-php/commit/0afff0f74e88e5097a2be33e6004b0367ecc7b6d))
* New surface LROs for new surface clients ([#714](https://github.com/googleapis/gapic-generator-php/issues/714)) ([908d92f](https://github.com/googleapis/gapic-generator-php/commit/908d92f3ef8c0f26cffc65e8b5eb9987eba813a8))

## [1.14.0](https://github.com/googleapis/gapic-generator-php/compare/v1.13.0...v1.14.0) (2024-04-29)


### Features

* Add support for the API version header ([#706](https://github.com/googleapis/gapic-generator-php/issues/706)) ([28a3161](https://github.com/googleapis/gapic-generator-php/commit/28a31618bf50d192ce81cf8bfd5be3200152d481))

## [1.13.0](https://github.com/googleapis/gapic-generator-php/compare/v1.12.1...v1.13.0) (2024-04-25)


### Features

* Add support for grpc-only gapic clients ([#707](https://github.com/googleapis/gapic-generator-php/issues/707)) ([5783c98](https://github.com/googleapis/gapic-generator-php/commit/5783c98c13215969eb35696b17d55a00ed711b1b))

## [1.12.1](https://github.com/googleapis/gapic-generator-php/compare/v1.12.0...v1.12.1) (2024-04-15)


### Bug Fixes

* Patch optional to required changes in BigQueryDataTransfer ([#703](https://github.com/googleapis/gapic-generator-php/issues/703)) ([ccfc769](https://github.com/googleapis/gapic-generator-php/commit/ccfc769d89442d411ffa1c62f8c0f340a4407ded))

## [1.12.0](https://github.com/googleapis/gapic-generator-php/compare/v1.11.0...v1.12.0) (2024-04-12)


### Features

* Add patches for bigtable required to optional changes ([#702](https://github.com/googleapis/gapic-generator-php/issues/702)) ([207191c](https://github.com/googleapis/gapic-generator-php/commit/207191c1f3a07a24338b47735c39bf31a01794ee))


### Bug Fixes

* Add license and generated code headers to generated resource files ([#696](https://github.com/googleapis/gapic-generator-php/issues/696)) ([8409511](https://github.com/googleapis/gapic-generator-php/commit/8409511b8acc296f502694e26e1b0b8a5e52a262))

## [1.11.0](https://github.com/googleapis/gapic-generator-php/compare/v1.10.0...v1.11.0) (2024-02-28)


### Features

* Support configuring emulators from environment variable ([#687](https://github.com/googleapis/gapic-generator-php/issues/687)) ([5409e38](https://github.com/googleapis/gapic-generator-php/commit/5409e389714a511253608288de4028787611e58b))
* UUID auto-generation for fields listed for auto population in service.yaml ([#686](https://github.com/googleapis/gapic-generator-php/issues/686)) ([57bef7c](https://github.com/googleapis/gapic-generator-php/commit/57bef7c61582708f5daae6559b9e66810bfbef69))


### Bug Fixes

* Correct method for supportedTransports ([#692](https://github.com/googleapis/gapic-generator-php/issues/692)) ([e7e08da](https://github.com/googleapis/gapic-generator-php/commit/e7e08da23a4a7b013f94ab65e0855e2f26ebe946))
* Remove PhpFactory::create from PhpClassComparer ([#688](https://github.com/googleapis/gapic-generator-php/issues/688)) ([106d3ee](https://github.com/googleapis/gapic-generator-php/commit/106d3ee4038d708d8e2b3e3caa6f899180401a72))

## [1.10.0](https://github.com/googleapis/gapic-generator-php/compare/v1.9.2...v1.10.0) (2023-12-14)


Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# like protobuf will build.
http_archive(
name = "bazel_skylib",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)

Expand Down
8 changes: 4 additions & 4 deletions bazel_example/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ grpc_extra_deps()

http_archive(
name = "rules_proto",
sha256 = "f5ae0e582238fcd4ea3d0146a3f5f3db9517f8fe24491eab3c105ace53aad1bb",
strip_prefix = "rules_proto-f9b0b880d1e10e18daeeb168cef9d0f8316fdcb5",
sha256 = "2b0f9c9314edcf7e0937f6b68124494c58643df763fd59e37fb5dc742e0202d4",
strip_prefix = "rules_proto-557db790e7a71993ff85bf523099dfd25060ae2f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/f9b0b880d1e10e18daeeb168cef9d0f8316fdcb5.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/f9b0b880d1e10e18daeeb168cef9d0f8316fdcb5.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/557db790e7a71993ff85bf523099dfd25060ae2f.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/557db790e7a71993ff85bf523099dfd25060ae2f.tar.gz",
],
)

Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
"autoload-dev": {
"psr-4": {
"Testing\\Basic\\": "tests/Unit/ProtoTests/Basic/out/src",
"Testing\\BasicAutoPopulation\\": "tests/Unit/ProtoTests/BasicAutoPopulation/out/src",
"Testing\\BasicBidiStreaming\\": "tests/Unit/ProtoTests/BasicBidiStreaming/out/src",
"Testing\\BasicClientStreaming\\": "tests/Unit/ProtoTests/BasicClientStreaming/out/src",
"Testing\\BasicDiregapic\\": "tests/Unit/ProtoTests/BasicDiregapic/out/src",
"Testing\\BasicGrpcOnly\\": "tests/Unit/ProtoTests/BasicGrpcOnly/out/src",
"Testing\\BasicLro\\": "tests/Unit/ProtoTests/BasicLro/out/src",
"Testing\\BasicOneof\\": "tests/Unit/ProtoTests/BasicOneof/out/src",
"Testing\\BasicOneofNew\\": "tests/Unit/ProtoTests/BasicOneofNew/out/src",
"Testing\\BasicPaginated\\": "tests/Unit/ProtoTests/BasicPaginated/out/src",
"Testing\\BasicServerStreaming\\": "tests/Unit/ProtoTests/BasicServerStreaming/out/src",
"Testing\\CustomLro\\": "tests/Unit/ProtoTests/CustomLro/out/src",
"Testing\\CustomLroNew\\": "tests/Unit/ProtoTests/CustomLroNew/out/src",
"Testing\\Deprecated\\": "tests/Unit/ProtoTests/DeprecatedService/out/src",
"Testing\\DisableSnippets\\": "tests/Unit/ProtoTests/DisableSnippets/out/src",
"Testing\\GrpcServiceConfig\\": "tests/Unit/ProtoTests/GrpcServiceConfig/out/src",
Expand All @@ -38,12 +41,17 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"google/gax": "^1.19.1"
"google/gax": "^1.34"
},
"scripts": {
"update-all-tests": [
"Google\\Generator\\Tests\\Unit\\ProtoTests\\GoldenUpdateMain::updateAll",
"bash tests/scripts/run_bazel_updates.sh --expunge"
]
},
"config": {
"platform": {
"php": "8.1"
}
}
}
2 changes: 1 addition & 1 deletion googleapis
Submodule googleapis updated 7546 files
4 changes: 2 additions & 2 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def gapic_generator_php_repositories():
maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-b44c45ca32db478554a3b8e2e04d317ed2f466f4",
strip_prefix = "googleapis-ebe079453350f4cd5afea5091522cf97e25f01a1",
urls = [
"https://github.com/googleapis/googleapis/archive/b44c45ca32db478554a3b8e2e04d317ed2f466f4.zip",
"https://github.com/googleapis/googleapis/archive/ebe079453350f4cd5afea5091522cf97e25f01a1.zip",
],
)
10 changes: 5 additions & 5 deletions rules_php_gapic/php_gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def php_gapic_srcjar(
rest_numeric_enums = False,
generate_snippets = True,
# Supported values validated and specified in src/Utils/MigrationMode.php.
migration_mode = "PRE_MIGRATION_SURFACE_ONLY",
migration_mode = "PRE_MIGRATION_SURFACE_ONLY",
generator_binary = Label("//rules_php_gapic:php_gapic_generator_binary"),
**kwargs):
plugin_file_args = {}
Expand All @@ -69,10 +69,10 @@ def php_gapic_srcjar(
# Transport.
if transport == None:
transport = "grpc+rest"
if transport == "grpc":
fail("Error: gRPC-only PHP GAPIC libraries are not yet supported")
if transport != "grpc+rest" and transport != "rest":
fail("Error: Only 'grpc+rest' or 'rest' transports are supported")
if transport != "grpc+rest" and transport != "rest" and transport != "grpc":
fail("Error: Only 'grpc+rest', 'rest' or `grpc` transports are supported")
if transport == "grpc" and migration_mode != "NEW_SURFACE_ONLY":
fail("Error: 'grpc' transport is only supported with 'NEW_SURFACE_ONLY' migration mode")

# Set plugin arguments.
plugin_args = ["metadata"] # Generate the gapic_metadata.json file.
Expand Down
42 changes: 39 additions & 3 deletions src/Ast/AST.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ abstract class AST
/** @var string Constant to reference `E_USER_ERROR`. */
public const E_USER_ERROR = "\0E_USER_ERROR";

/** @var string Constant to reference `parse_url`. */
public const PARSE_URL = "\0parse_url";

/** @var string Constant to reference `str_replace`. */
public const STRING_REPLACE = "\0str_replace";

/** @var string Constant to reference `empty`. */
public const EMPTY = "\0empty";

/** @var string Constant to reference `getenv`. */
public const GET_ENV = "\0getenv";

protected static function deref($obj): string
{
return $obj === static::SELF || $obj instanceof ResolvedType ? '::' : '->';
Expand Down Expand Up @@ -416,7 +428,7 @@ public function toCode(): string
if ($this->oneLine) {
$itemsStr = $items->skipLast(1)->map(fn ($x) => "{$x}, ")->join();
$itemsStr = $itemsStr . "{$items->last()}";
return "[{$itemsStr}]";
return "[{$itemsStr}]";
}
$itemsStr = $items->map(fn ($x) => "{$x},\n")->join();
$firstNl = count($items) === 0 ? '' : "\n";
Expand Down Expand Up @@ -761,10 +773,10 @@ public function toCode(): string

/**
* Create a '??' expression.
*
*
* @param Expression $expr The expression to check \isset and !\is_null, as well as the value to return if true.
* @param Expression $false The expresion to return if $expr is not set or is null.
*
*
* @return Expression
*/
public static function nullCoalescing(Expression $expr, Expression $false): Expression
Expand All @@ -783,6 +795,30 @@ public function toCode(): string
};
}

/**
* Create a '??=' (noal-coalescing assignment) expression.
*
* @param AST $to Assign a value to this.
* @param mixed $from Assign from this.
*
* @return Expression
*/
public static function nullCoalescingAssign(AST $to, $from): Expression
{
return new class($to, $from) extends Expression {
public function __construct($to, $from)
{
$this->to = $to;
$this->from = $from;
}
public function toCode(): string
{
return static::toPhp($this->to) .
' ??= ' . static::toPhp($this->from);
}
};
}

/**
* Create a while statement. This method returns a callable into which the loop code is passed.
*
Expand Down
8 changes: 4 additions & 4 deletions src/Ast/PhpFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function withUses(Set $uses)
return $this->clone(fn ($clone) => $clone->uses = $uses);
}

public function withApacheLicense(int $year)
public function withApacheLicense(int $year): PhpFile
{
$license = <<<EOF
/*
Expand All @@ -64,7 +64,7 @@ public function withApacheLicense(int $year)
return $this->clone(fn ($clone) => $clone->headerLines = $clone->headerLines->concat($license));
}

public function withGeneratedCodeWarning()
public function withGeneratedCodeWarning(): PhpFile
{
$warning = <<<'EOF'
/*
Expand All @@ -77,7 +77,7 @@ public function withGeneratedCodeWarning()
return $this->clone(fn ($clone) => $clone->headerLines = $clone->headerLines->concat($warning));
}

public function withGeneratedFromProtoCodeWarning(string $filePath, bool $isGa)
public function withGeneratedFromProtoCodeWarning(string $filePath, bool $isGa): PhpFile
{
$warning = <<<EOF
/*
Expand All @@ -94,7 +94,7 @@ public function withGeneratedFromProtoCodeWarning(string $filePath, bool $isGa)
return $this->clone(fn ($clone) => $clone->headerLines = $clone->headerLines->concat($warning));
}

public function withBlock($block)
public function withBlock($block): PhpFile
{
if ($this->class) {
throw new \RuntimeException('Cannot add a code block when the file already has a class configured.');
Expand Down
23 changes: 23 additions & 0 deletions src/Ast/PhpProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@

namespace Google\Generator\Ast;

use Google\Generator\Utils\ResolvedType;

/** A property within a class. */
final class PhpProperty extends PhpClassMember
{
private ?ResolvedType $type;

public function __construct(string $name)
{
$this->name = $name;
$this->value = null;
$this->type = null;
}

/**
Expand All @@ -39,6 +44,18 @@ public function withValue(Expression $value): PhpProperty
return $this->clone(fn ($clone) => $clone->value = $value);
}

/**
* Adds a type declaration to the property
*
* @param ResolvedType $type The type of the property
*
* @return PhpProperty
*/
public function withType(ResolvedType $type): PhpProperty
{
return $this->clone(fn ($clone) => $clone->type = $type);
}

public function getName(): string
{
return $this->name;
Expand All @@ -49,7 +66,13 @@ public function toCode(): string
return
$this->phpDocToCode() .
$this->accessToCode() .
$this->typeToCode() .
'$' . $this->name .
(is_null($this->value) ? ';' : ' = ' . static::toPhp($this->value) . ';');
}

private function typeToCode(): string
{
return $this->type ? $this->type->toCode() . ' ' : '';
}
}
Loading

0 comments on commit 07ac54f

Please sign in to comment.