Skip to content
Open
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
5 changes: 1 addition & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.github export-ignore
dev export-ignore
tests export-ignore
codecov.yml export-ignore
ruleset.xml export-ignore
.travis.yml export-ignore
/*.dist export-ignore
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,13 @@ be found for Mac or Windows.
3. Run tests.

```sh
> composer test
> vendor/bin/phpunit
```

4. Updating dependencies after changing `composer.json`:
4. Run static analysis tools

```sh
> composer update
`
```

5. Formatting source:

```sh
> composer cs-lint
> composer cs-fix
> phpstan -c phpstan.neon.dist
```

## License
Expand Down
3 changes: 0 additions & 3 deletions codecov.yml

This file was deleted.

8 changes: 0 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,9 @@
},
"autoload-dev": {
"psr-4": {
"Google\\ApiCore\\Dev\\": "dev/src",
"Google\\ApiCore\\Tests\\": "tests",
"GPBMetadata\\Google\\": "metadata/Google",
"Google\\Showcase\\": "tests/Conformance/src",
"GPBMetadata\\Google\\Showcase\\": "tests/Conformance/metadata"
}
},
"scripts": {
"regenerate-test-protos": "dev/sh/regenerate-test-protos.sh",
"test": "./vendor/bin/phpunit",
"cs-lint": "vendor/bin/php-tools cs-fixer googleapis/gax-php --ref $(git rev-parse --abbrev-ref HEAD) --flags \"\\-n --dry-run\"",
"cs-fix": "vendor/bin/php-tools cs-fixer googleapis/gax-php --ref $(git rev-parse --abbrev-ref HEAD) --flags \"\\-n\""
}
}
57 changes: 0 additions & 57 deletions dev/sh/build-protobuf-docs.sh

This file was deleted.

15 changes: 0 additions & 15 deletions dev/sh/regenerate-test-protos.sh

This file was deleted.

14 changes: 0 additions & 14 deletions dev/sh/test-composer-conflict.sh

This file was deleted.

59 changes: 0 additions & 59 deletions dev/src/Docs/doctum-protobuf-config.php

This file was deleted.

Binary file modified metadata/ApiCore/Testing/Mocks.php
Binary file not shown.
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true">
<php>
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="tests/Unit/testdata/json-key-file.json"/>
</php>
<coverage>
<include>
<directory suffix=".php">src/ApiCore</directory>
Expand Down
3 changes: 1 addition & 2 deletions src/ClientOptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ private function buildClientOptions(array|ClientOptions $options)
$options['logger'] = ApplicationDefaultCredentials::getDefaultLogger();
}

if (
$options['logger'] !== null
if ($options['logger'] !== null
&& $options['logger'] !== false
&& !$options['logger'] instanceof LoggerInterface
) {
Expand Down
2 changes: 1 addition & 1 deletion src/OperationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class OperationResponse
* OperationResponse constructor.
*
* @param string $operationName
* @param object $operationsClient
* @param object|null $operationsClient
* @param array $options {
* Optional. Options for configuring the operation response object.
*
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceTemplate/AbsoluteResourceTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
class AbsoluteResourceTemplate implements ResourceTemplateInterface
{
private RelativeResourceTemplate $resourceTemplate;
/** @var string|bool */
/** @var string */
private $verb;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ResourceTemplate/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Segment
private ?string $value;
private ?string $key;
private ?RelativeResourceTemplate $template;
private ?string $stringRepr;
private ?string $separator;
private string $stringRepr;
private string $separator;

/**
* Segment constructor.
Expand Down
30 changes: 25 additions & 5 deletions src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
use Google\Protobuf\DescriptorPool;
use Google\Protobuf\FieldDescriptor;
use Google\Protobuf\Internal\Message;
use Google\Rpc\BadRequest;
use Google\Rpc\DebugInfo;
use Google\Rpc\ErrorInfo;
use Google\Rpc\Help;
use Google\Rpc\LocalizedMessage;
use Google\Rpc\PreconditionFailure;
use Google\Rpc\QuotaFailure;
use Google\Rpc\RequestInfo;
use Google\Rpc\ResourceInfo;
use Google\Rpc\RetryInfo;
use Google\Rpc\Status;
use RuntimeException;

/**
Expand Down Expand Up @@ -180,7 +191,7 @@ public static function decodeMetadata(array $metadata, ?array &$errors = null)
$result = [];
// If metadata contains a "status" bin, use that instead
if (isset($metadata['grpc-status-details-bin'])) {
$status = new \Google\Rpc\Status();
$status = new Status();
$status->mergeFromString($metadata['grpc-status-details-bin'][0]);
foreach ($status->getDetails() as $any) {
if (isset(KnownTypes::TYPE_URLS[$any->getTypeUrl()])) {
Expand Down Expand Up @@ -212,7 +223,18 @@ public static function decodeMetadata(array $metadata, ?array &$errors = null)
if (self::hasBinaryHeaderSuffix($key)) {
if (isset(KnownTypes::BIN_TYPES[$key])) {
$class = KnownTypes::BIN_TYPES[$key];
/** @var Message $message */
/**
* @var BadRequest
* | DebugInfo
* | ErrorInfo
* | Help
* | LocalizedMessage
* | PreconditionFailure
* | QuotaFailure
* | RequestInfo
* | ResourceInfo
* | RetryInfo $message
*/
$message = new $class();
try {
$message->mergeFromString($value);
Expand Down Expand Up @@ -470,12 +492,10 @@ private function checkFieldRepeated(FieldDescriptor $field): bool
if (method_exists($field, 'isRepeated')) {
return $field->isRepeated();
}

if (method_exists($field, 'getLabel')) {
return $field->getLabel() === GPBLabel::REPEATED;
}

throw new \Exception('No field repeated method avaialble');
throw new \LogicException('unable to check field repeated');
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Testing/MockRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/Testing/MockRequestBody.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/Testing/MockResponse.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Transport/Rest/JsonStreamDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(StreamInterface $stream, string $decodeType, array $
public function decode()
{
try {
foreach ($this->_decode() as $response) {
foreach ($this->doDecode() as $response) {
yield $response;
}
} catch (RuntimeException $re) {
Expand All @@ -112,7 +112,7 @@ public function decode()
/**
* @return \Generator
*/
private function _decode()
private function doDecode()
{
$decodeType = $this->decodeType;
$str = false;
Expand Down
4 changes: 2 additions & 2 deletions src/Transport/Rest/RestServerStreamingCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RestServerStreamingCall implements ServerStreamingCallInterface
private array $decoderOptions;

private RequestInterface $originalRequest;
private ?JsonStreamDecoder $decoder;
private JsonStreamDecoder $decoder;
private string $decodeType;
private ?ResponseInterface $response;
private stdClass $status;
Expand Down Expand Up @@ -181,7 +181,7 @@ public function getPeer()
*/
public function cancel()
{
if (!is_null($this->decoder)) {
if (isset($this->decoder)) {
$this->decoder->close();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/RestTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function startServerStreamingCall(Call $call, array $options)
$request = $this->requestBuilder->build(
$call->getMethod(),
$call->getMessage()
// Exclude headers here because they will be added in _serverStreamRequest().
// Exclude headers here because they will be added in doServerStreamRequest().
);

$decoderOptions = [];
Expand All @@ -209,7 +209,7 @@ public function startServerStreamingCall(Call $call, array $options)
}

return new ServerStream(
$this->_serverStreamRequest(
$this->doServerStreamRequest(
$this->httpHandler,
$request,
$headers,
Expand All @@ -233,7 +233,7 @@ public function startServerStreamingCall(Call $call, array $options)
*
* @return RestServerStreamingCall
*/
private function _serverStreamRequest(
private function doServerStreamRequest(
$httpHandler,
$request,
$headers,
Expand Down
Loading
Loading