Skip to content

Commit

Permalink
fix: Php lint issues (#411)
Browse files Browse the repository at this point in the history
<!--
We appreciate the effort for this pull request but before that please
make sure you read the contribution guidelines, then fill out the blanks
below.

Please format the PR title appropriately based on the type of change:
  <type>[!]: <description>
Where <type> is one of: docs, chore, feat, fix, test, misc.
Add a '!' after the type for breaking changes (e.g. feat!: new breaking
feature).

**All third-party contributors acknowledge that any contributions they
provide will be made under the same open-source license that the
open-source project is provided under.**

Please enter each Issue number you are resolving in your PR after one of
the following words [Fixes, Closes, Resolves]. This will auto-link these
issues and close them when this PR is merged!
e.g.
Fixes #1
Closes #2
-->

# Fixes #

- Fix sonar lint issues for php generated example files 
- Fix php template files and generated path string from phpAPIBuilder

### Checklist
- [x] I acknowledge that all my contributions will be made under the
project's license
- [ ] Run `make test-docker`
- [ ] Verify affected language:
- [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our
[OpenAPI specification](https://github.com/twilio/twilio-oai) using the
[build_twilio_go.py](./examples/build_twilio_go.py) using `python
examples/build_twilio_go.py path/to/twilio-oai/spec/yaml
path/to/twilio-go` and inspect the diff
    - [ ] Run `make test` in `twilio-go`
    - [ ] Create a pull request in `twilio-go`
    - [ ] Provide a link below to the pull request
- [ ] I have made a material change to the repo (functionality, testing,
spelling, grammar)
- [ ] I have read the [Contribution
Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md)
and my PR follows them
- [ ] I have titled the PR appropriately
- [ ] I have updated my branch with the main branch
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added the necessary documentation about the functionality
in the appropriate .md file
- [ ] I have added inline documentation to the code I modified

If you have questions, please create a GitHub Issue in this repository.
  • Loading branch information
charan678 committed Jan 24, 2023
1 parent 78d623d commit fee7ea3
Show file tree
Hide file tree
Showing 62 changed files with 1,430 additions and 648 deletions.
29 changes: 19 additions & 10 deletions examples/php/src/Twilio/Rest/Api/V2010.php
Expand Up @@ -30,7 +30,8 @@
* @method \Twilio\Rest\Api\V2010\AccountContext accounts(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\CallContext calls(string $testInteger)
*/
class V2010 extends Version {
class V2010 extends Version
{
protected $_accounts;
protected $_account = null;
protected $_calls = null;
Expand All @@ -40,12 +41,14 @@ class V2010 extends Version {
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain) {
public function __construct(Domain $domain)
{
parent::__construct($domain);
$this->version = '2010-04-01';
}

protected function getAccounts(): AccountList {
protected function getAccounts(): AccountList
{
if (!$this->_accounts) {
$this->_accounts = new AccountList($this);
}
Expand All @@ -55,7 +58,8 @@ protected function getAccounts(): AccountList {
/**
* @return AccountContext Account provided as the authenticating account
*/
protected function getAccount(): AccountContext {
protected function getAccount(): AccountContext
{
if (!$this->_account) {
$this->_account = new AccountContext(
$this,
Expand All @@ -71,11 +75,13 @@ protected function getAccount(): AccountContext {
* @param AccountContext|AccountInstance $account account to use as the primary
* account
*/
public function setAccount($account): void {
public function setAccount($account): void
{
$this->_account = $account;
}

protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList {
protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList
{
return $this->account->calls;
}

Expand All @@ -86,7 +92,8 @@ protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList {
* @return \Twilio\ListResource The requested resource
* @throws TwilioException For unknown resource
*/
public function __get(string $name) {
public function __get(string $name)
{
$method = 'get' . \ucfirst($name);
if (\method_exists($this, $method)) {
return $this->$method();
Expand All @@ -103,7 +110,8 @@ public function __get(string $name) {
* @return InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext {
public function __call(string $name, array $arguments): InstanceContext
{
$property = $this->$name;
if (\method_exists($property, 'getContext')) {
return \call_user_func_array(array($property, 'getContext'), $arguments);
Expand All @@ -117,7 +125,8 @@ public function __call(string $name, array $arguments): InstanceContext {
*
* @return string Machine friendly representation
*/
public function __toString(): string {
public function __toString(): string
{
return '[Twilio.Api.V2010]';
}
}
}
Expand Up @@ -29,57 +29,77 @@
use Twilio\Serialize;


class FeedbackCallSummaryContext extends InstanceContext {
class FeedbackCallSummaryContext extends InstanceContext
{
/**
* Initialize the FeedbackCallSummaryContext
*
* @param Version $version Version that contains the resource
* @param string $accountSid
* @param string $sid
* @param string $accountSid
* @param string $sid
*/
public function __construct(Version $version, $accountSid , $sid ) {
public function __construct(
Version $version,
$accountSid,
$sid
)
{
parent::__construct($version);

// Path Solution
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid, ];
$this->solution = [
'accountSid' =>
$accountSid,
'sid' =>
$sid,
];

$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Calls/Feedback/Summary/' . \rawurlencode($sid) . '.json';
$this->uri = '/Accounts/' . \rawurlencode($accountSid)
.'/Calls/Feedback/Summary/' . \rawurlencode($sid)
.'.json';
}

/**
* Update the FeedbackCallSummaryInstance
*
* @param \DateTime $endDate
* @param \DateTime $startDate
* @param \DateTime $endDate
* @param \DateTime $startDate
* @param array|Options $options Optional Arguments
* @return FeedbackCallSummaryInstance Updated FeedbackCallSummaryInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance {
public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance
{

$options = new Values($options);

$data = Values::of([
'EndDate' => Serialize::iso8601Date($endDate),
'StartDate' => Serialize::iso8601Date($startDate),
'AccountSid' => $options['accountSid'],
'EndDate' =>
Serialize::iso8601Date($endDate),
'StartDate' =>
Serialize::iso8601Date($startDate),
'AccountSid' =>
$options['accountSid'],
]);

$payload = $this->version->update('POST', $this->uri, [], $data);

return new FeedbackCallSummaryInstance(
$this->version,
$payload
, $this->solution['accountSid']
, $this->solution['sid']
$payload,
$this->solution['accountSid'],
$this->solution['sid'],
);
}


/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
Expand Down
Expand Up @@ -47,16 +47,18 @@
* @property string[] $testArrayOfObjects
* @property string[] $testArrayOfEnum
*/
class FeedbackCallSummaryInstance extends InstanceResource {
class FeedbackCallSummaryInstance extends InstanceResource
{
/**
* Initialize the FeedbackCallSummaryInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid
* @param string $sid
* @param string $accountSid
* @param string $sid
*/
public function __construct(Version $version, array $payload, string $accountSid, string $sid = null) {
public function __construct(Version $version, array $payload, string $accountSid, string $sid = null)
{
parent::__construct($version);

// Marshaled Properties
Expand Down Expand Up @@ -88,7 +90,8 @@ public function __construct(Version $version, array $payload, string $accountSid
*
* @return FeedbackCallSummaryContext Context for this FeedbackCallSummaryInstance
*/
protected function proxy(): FeedbackCallSummaryContext {
protected function proxy(): FeedbackCallSummaryContext
{
if (!$this->context) {
$this->context = new FeedbackCallSummaryContext(
$this->version,
Expand All @@ -103,13 +106,15 @@ protected function proxy(): FeedbackCallSummaryContext {
/**
* Update the FeedbackCallSummaryInstance
*
* @param \DateTime $endDate
* @param \DateTime $startDate
* @param \DateTime $endDate
* @param \DateTime $startDate
* @param array|Options $options Optional Arguments
* @return FeedbackCallSummaryInstance Updated FeedbackCallSummaryInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance {
public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance
{

return $this->proxy()->update($endDate, $startDate, $options);
}

Expand All @@ -120,7 +125,8 @@ public function update(\DateTime $endDate, \DateTime $startDate, array $options
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $name) {
public function __get(string $name)
{
if (\array_key_exists($name, $this->properties)) {
return $this->properties[$name];
}
Expand All @@ -138,7 +144,8 @@ public function __get(string $name) {
*
* @return string Machine friendly representation
*/
public function __toString(): string {
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
Expand Down
Expand Up @@ -28,35 +28,53 @@
use Twilio\Serialize;


class FeedbackCallSummaryList extends ListResource {
class FeedbackCallSummaryList extends ListResource
{
/**
* Construct the FeedbackCallSummaryList
*
* @param Version $version Version that contains the resource
* @param string $accountSid
* @param string $accountSid
*/
public function __construct(Version $version, string $accountSid ) {
public function __construct(
Version $version,
string $accountSid
)
{
parent::__construct($version);

// Path Solution
$this->solution = ['accountSid' => $accountSid, ];
$this->solution = [
'accountSid' =>
$accountSid,

];
}

/**
* Constructs a FeedbackCallSummaryContext
*
* @param string $sid
* @param string $sid
*/
public function getContext(string $sid): FeedbackCallSummaryContext {
return new FeedbackCallSummaryContext($this->version, $this->solution['accountSid'], $sid);
public function getContext(
string $sid

): FeedbackCallSummaryContext
{
return new FeedbackCallSummaryContext(
$this->version,
$this->solution['accountSid'],
$sid
);
}

/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
public function __toString(): string
{
return '[Twilio.Api.V2010.FeedbackCallSummaryList]';
}
}
Expand Up @@ -26,30 +26,45 @@
use Twilio\Deserialize;
use Twilio\Serialize;

abstract class FeedbackCallSummaryOptions {
abstract class FeedbackCallSummaryOptions
{
/**
* @param string $accountSid
* @param string $accountSid
* @return UpdateFeedbackCallSummaryOptions Options builder
*/
public static function update(string $accountSid = Values::NONE): UpdateFeedbackCallSummaryOptions {
return new UpdateFeedbackCallSummaryOptions($accountSid);
public static function update(

string $accountSid = Values::NONE

): UpdateFeedbackCallSummaryOptions
{
return new UpdateFeedbackCallSummaryOptions(
$accountSid
);
}

}

class UpdateFeedbackCallSummaryOptions extends Options {
class UpdateFeedbackCallSummaryOptions extends Options
{
/**
* @param string $accountSid
* @param string $accountSid
*/
public function __construct(string $accountSid = Values::NONE) {
public function __construct(

string $accountSid = Values::NONE

)
{
$this->options['accountSid'] = $accountSid;
}

/**
* @param string $accountSid
* @param string $accountSid
* @return $this Fluent Builder
*/
public function setAccountSid(string $accountSid): self {
public function setAccountSid(string $accountSid): self
{
$this->options['accountSid'] = $accountSid;
return $this;
}
Expand All @@ -59,7 +74,8 @@ public function setAccountSid(string $accountSid): self {
*
* @return string Machine friendly representation
*/
public function __toString(): string {
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.UpdateFeedbackCallSummaryOptions ' . $options . ']';
}
Expand Down

0 comments on commit fee7ea3

Please sign in to comment.