Skip to content

Commit

Permalink
Add lint commands + fix lint errors (#554)
Browse files Browse the repository at this point in the history
- Add build + clean commands to makefile
- Refine ci gha check
- Bump squizlabs/php_codesniffer to 3.11.2
  • Loading branch information
token-cjg authored Jan 16, 2025
1 parent b76cbbb commit 2dbb1e8
Show file tree
Hide file tree
Showing 86 changed files with 237 additions and 222 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ jobs:
run: docker build . --file Dockerfile --tag zendesk_api_client_php-app

- name: Run Composer install
run: docker run --rm --volume "$(pwd):/app" zendesk_api_client_php-app composer install
run: docker run --rm --volume "$(pwd):/app" zendesk_api_client_php-app make build

- name: Run lint
run: docker run --rm --volume "$(pwd):/app" zendesk_api_client_php-app make lint

- name: Run tests
run: docker run --rm --volume "$(pwd):/app" zendesk_api_client_php-app vendor/bin/phpunit --testsuite "Zendesk API Unit Test Suites"
run: docker run --rm --volume "$(pwd):/app" zendesk_api_client_php-app make test
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM php:8.2-cli
# OS requirements for PHP
RUN apt-get update && apt-get install -y git unzip

# Safe requirements to allow Makefile tasks to run
RUN git config --global --add safe.directory /app

# PHP requirements
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /app
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.PHONY: test all
.PHONY: build test lint

build:
composer install

test:
composer test:unit

all: test
lint:
composer lint
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
},
"require-dev": {
"phpunit/phpunit": "11.5.0",
"squizlabs/php_codesniffer": "2.*",
"squizlabs/php_codesniffer": "3.*",
"phpmd/phpmd": "@stable",
"fakerphp/faker": "^1.24.1",
"psy/psysh": "@stable"
},
"autoload": {
"psr-0": {
"Zendesk\\API\\": "src/",
"Zendesk\\Console\\": "src/"
"Zendesk\\Console\\": "src/",
"Zendesk\\Fixtures\\": "src/"
}
},
},
"scripts": {
"test:unit": "vendor/bin/phpunit --testsuite 'Zendesk API Unit Test Suites'",
"test:live": "vendor/bin/phpunit --testsuite 'Zendesk API Live Test Suites'"
"test:live": "vendor/bin/phpunit --testsuite 'Zendesk API Live Test Suites'",
"lint": "vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=PSR12 --extensions=php --ignore=vendor/ .",
"lint:fix": "vendor/bin/phpcbf --runtime-set ignore_warnings_on_exit 1 --standard=PSR12 --extensions=php --ignore=vendor/ ."
}
}
71 changes: 27 additions & 44 deletions composer.lock

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

2 changes: 1 addition & 1 deletion samples/attachments/uploadFileAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
print_r($attachment);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/attachments/uploadStreamAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
print_r($attachment);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
1 change: 1 addition & 0 deletions samples/groups/createGroup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");

use Zendesk\API\HttpClient as ZendeskAPI;
Expand Down
1 change: 1 addition & 0 deletions samples/groups/getGroups.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");

use Zendesk\API\HttpClient as ZendeskAPI;
Expand Down
3 changes: 1 addition & 2 deletions samples/helpcenter/createArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@
print_r($article);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}

2 changes: 1 addition & 1 deletion samples/helpcenter/createSections.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
print_r($section);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/helpcenter/findArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
print_r($articles);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/helpcenter/findArticlesBySectionId.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
print_r($articles);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/helpcenter/findCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
print_r($categories);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/helpcenter/findSections.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
print_r($sections);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
1 change: 1 addition & 0 deletions samples/organizations/createOrganization.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");
use Zendesk\API\HttpClient as ZendeskAPI;

Expand Down
2 changes: 1 addition & 1 deletion samples/sell/getContacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
print_r($contacts);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
1 change: 1 addition & 0 deletions samples/ticket_fields/createDropdownOption.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");
use Zendesk\API\HttpClient as ZendeskAPI;

Expand Down
1 change: 1 addition & 0 deletions samples/ticket_fields/editDropdownOption.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");
use Zendesk\API\HttpClient as ZendeskAPI;

Expand Down
11 changes: 6 additions & 5 deletions samples/ticket_fields/replaceDropdownOptions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");
use Zendesk\API\HttpClient as ZendeskAPI;

Expand All @@ -11,14 +12,14 @@
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
$result = $client->ticketFields()->update(51931448, ["custom_field_options"=> [
$result = $client->ticketFields()->update(51931448, ["custom_field_options" => [
[
"name"=> "Apple Pie",
"value"=> "apple_pie"
"name" => "Apple Pie",
"value" => "apple_pie"
],
[
"name"=> "Pecan Pie",
"value"=> "pecan_pie"
"name" => "Pecan Pie",
"value" => "pecan_pie"
]
]
]);
Expand Down
2 changes: 1 addition & 1 deletion samples/tickets/createTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
print_r($newTicket);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
4 changes: 2 additions & 2 deletions samples/tickets/createTicketWithAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$subdomain = "subdomain";
$username = "[email protected]";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$attachment = getcwd().'/sample.jpg';
$attachment = getcwd() . '/sample.jpg';

$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
Expand Down Expand Up @@ -46,5 +46,5 @@
print_r($newTicket);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/deleteTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
$deleteTicket = $client->tickets()->delete($id);
echo "Ticket ($id) has been removed";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/getTicketComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
print_r($tickets);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/getTicketMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
print_r($metrics);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/getTickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
print_r($tickets);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
4 changes: 2 additions & 2 deletions samples/tickets/searchTickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

try {
// Search the current customer
$params = ['query' =>'[email protected]'];
$params = ['query' => '[email protected]'];
$search = $client->users()->search($params);

if (empty($search->users)) {
Expand All @@ -34,5 +34,5 @@
}
}
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/updateTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
print_r($updateTicket);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
2 changes: 1 addition & 1 deletion samples/tickets/viewTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
print_r($tickets->ticket);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
echo $e->getMessage() . '</br>';
}
1 change: 1 addition & 0 deletions samples/users/createUser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

include("../../vendor/autoload.php");

use Zendesk\API\HttpClient as ZendeskAPI;
Expand Down
Loading

0 comments on commit 2dbb1e8

Please sign in to comment.