Skip to content

Commit

Permalink
Remove trait and fix bc
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Pepper <[email protected]>
  • Loading branch information
kimpepper committed Nov 8, 2024
1 parent a863ae7 commit 12209dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.0",
"ext-json": ">=1.3.7",
"ext-curl": "*",
"ezimuel/ringphp": "^1.2.2",
Expand Down
8 changes: 3 additions & 5 deletions src/OpenSearch/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@
use OpenSearch\Namespaces\NamespaceBuilderInterface;
use OpenSearch\Serializers\SerializerInterface;
use OpenSearch\Serializers\SmartSerializer;
use OpenSearch\Traits\DeprecatedPropertyTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use ReflectionClass;

class ClientBuilder
{

use DeprecatedPropertyTrait;

public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader'];

/**
Expand Down Expand Up @@ -185,10 +181,12 @@ public function getTransport(): Transport

/**
* Can supply second param to Client::__construct() when invoking manually or with dependency injection
*
* @deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::getEndpointFactory() instead.
*/
public function getEndpoint(): callable
{
return $this->endpoint;
return fn ($c) => $this->endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c);
}

/**
Expand Down
13 changes: 7 additions & 6 deletions src/OpenSearch/Namespaces/AbstractNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@
use OpenSearch\EndpointFactoryInterface;
use OpenSearch\Endpoints\AbstractEndpoint;
use OpenSearch\LegacyEndpointFactory;
use OpenSearch\Traits\DeprecatedPropertyTrait;
use OpenSearch\Transport;

abstract class AbstractNamespace
{

use DeprecatedPropertyTrait;

/**
* @var \OpenSearch\Transport
*/
Expand All @@ -41,17 +37,22 @@ abstract class AbstractNamespace

/**
* @var callable
*
* @deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory property instead.
*/
protected $endpoints;

public function __construct(Transport $transport, callable|EndpointFactoryInterface $endpointFactory)
{
$this->transport = $transport;
if (is_callable($endpointFactory)) {
@trigger_error('Passing a callable to AbstractNamespace is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED);
$this->endpoints = $endpointFactory;
@trigger_error('Passing a callable as $endpointFactory param to ' . __METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED);
$endpoints = $endpointFactory;
$endpointFactory = new LegacyEndpointFactory($endpointFactory);
} else {
$endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c);
}
$this->endpoints = $endpoints;
$this->endpointFactory = $endpointFactory;
}

Expand Down
25 changes: 0 additions & 25 deletions src/OpenSearch/Traits/DeprecatedPropertyTrait.php

This file was deleted.

4 changes: 2 additions & 2 deletions util/template/client-class
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Client
$endpoints = $endpointFactory;
$endpointFactory = new LegacyEndpointFactory($endpointFactory);
} else {
$endpoints = $endpointFactory->getEndpoint(...);
$endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c);
}
$this->endpoints = $endpoints;
$this->endpointFactory = $endpointFactory;
Expand All @@ -95,7 +95,7 @@ class Client
public function __get(string $name): mixed
{
if ($name === 'endpoints') {
@trigger_error('The $callable property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED);
@trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED);
return $this->endpoints;
}
return null;
Expand Down

0 comments on commit 12209dd

Please sign in to comment.