Skip to content

Commit

Permalink
Added local phpstan config file, started rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Schläpfer committed Sep 30, 2023
1 parent 4dd79b6 commit eb02e40
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 71 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "project",
"require": {
"php": "^8.0|^8.2",
"pve2-api-client/pve2-api-client": "^1.0.2"
"pve2-api-client/pve2-api-client": "^1.0.2",
"symfony/finder": "^6.3"
},
"funding": [
{
Expand Down
15 changes: 15 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
level: 1
bootstrapFiles:
- ../../load.php
paths:
- ./src
excludePaths:
analyse:
- ./src/vendor
scanDirectories:
- ../../
- ./src/vendor
ignoreErrors:
- '#^Function __trans not found\.$#'
- '#^Variable \$proxmox might not be defined\.#'
67 changes: 33 additions & 34 deletions src/Api/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Admin extends \Api_Abstract
/**
* Get list of servers
*
* @return array
* @return array<mixed>
*/
public function server_get_list($data)
public function server_get_list()
{
// Retrieve all servers from the database
$servers = $this->di['db']->find('service_proxmox_server');
Expand Down Expand Up @@ -98,11 +98,11 @@ public function server_get_list($data)
}

/**
* Get list of storage
* Get list of storages
*
* @return array
* @return array<mixed>
*/
public function storage_get_list($data)
public function storage_get_list()
{
$storages = $this->di['db']->find('service_proxmox_storage');
$storages_grouped = array();
Expand Down Expand Up @@ -186,8 +186,7 @@ public function storage_get_list($data)
*
* @return array
*/

public function storageclass_get_list($data)
public function storageclass_get_list()
{
$storageclasses = $this->di['db']->find('service_proxmox_storageclass');
return $storageclasses;
Expand All @@ -198,7 +197,7 @@ public function storageclass_get_list($data)
*
* @return array
*/
public function storage_controller_get_list($data)
public function storage_controller_get_list()
{
// Return Array of storage controllers:
// lsi | lsi53c810 | virtio-scsi-pci | virtio-scsi-single | megasas | pvscsi
Expand All @@ -218,9 +217,9 @@ public function storage_controller_get_list($data)
/** *
* Get list of Active Services
*
* @return array
* @return array<mixed>
*/
public function service_proxmox_get_list($data)
public function service_proxmox_get_list()
{
$services = $this->di['db']->find('service_proxmox');
return $services;
Expand All @@ -229,7 +228,7 @@ public function service_proxmox_get_list($data)
/**
* Create a new storageclass
*
* @return array
* @return array<mixed>
*/
public function storageclass_create($data)
{
Expand All @@ -242,7 +241,7 @@ public function storageclass_create($data)
/**
* Retrieve a single storageclass
*
* @return array
* @return array<mixed>
*/
public function storageclass_get($data)
{
Expand Down Expand Up @@ -296,7 +295,7 @@ public function qemu_templates_on_server($data)
/**
* Get list of OS types
*
* @return array
* @return array<mixed>
*/

public function os_get_list()
Expand All @@ -322,7 +321,7 @@ public function os_get_list()
/**
* Get list of BIOS types
*
* @return array
* @return array<mixed>
*/
public function bios_get_list()
{
Expand All @@ -336,7 +335,7 @@ public function bios_get_list()
/**
* Get list of VNC types
*
* @return array
* @return array<mixed>
*/
public function lxc_appliance_get_list()
{
Expand Down Expand Up @@ -457,7 +456,7 @@ public function server_create($data)
* Get server details
*
* @param int $id - server id
* @return array
* @return array<mixed>
*
* @throws \Box_Exception
*/
Expand Down Expand Up @@ -610,7 +609,7 @@ public function server_get_from_order($data)
* Receive Hardware Data from proxmox server
*
* @param int $server_id
* @return array
* @return array<mixed>
*/
public function get_hardware_data($server_id)
{
Expand Down Expand Up @@ -765,7 +764,7 @@ public function test_access($data)
/**
* Get all available templates from any proxmox server
*
* @return array
* @return array<mixed>
* @throws \Box_Exception
*/
public function pull_lxc_appliances()
Expand Down Expand Up @@ -812,7 +811,7 @@ public function pull_lxc_appliances()
*
* @param int $id - storage id
*
* @return array
* @return array<mixed>
* @throws \Box_Exception
*/
public function storage_get($data)
Expand All @@ -834,7 +833,7 @@ public function storage_get($data)
'free' => $storage->free,
'percent_used' => ($storage->size == 0 || $storage->used == 0 || $storage->free == 0) ? 0 : round($storage->used / $storage->size * 100, 2),
// add list of storage classes
'storageclasses' => $this->storageclass_get_list($data),
'storageclasses' => $this->storageclass_get_list(),
'server_name' => $server->name,
);

Expand All @@ -847,7 +846,7 @@ public function storage_get($data)
* TODO: Implement & Fix functionality
* @param int $id - server id
*
* @return array
* @return array<mixed>
* @throws \Box_Exception
*/
public function storage_update($data)
Expand Down Expand Up @@ -956,7 +955,7 @@ public function product_update($data)
/**
* Get list of vm templates
*
* @return array
* @return array<mixed>
*/
public function service_get_vmtemplates()
{
Expand All @@ -967,7 +966,7 @@ public function service_get_vmtemplates()
/**
* Get list of qemu templates
*
* @return array
* @return array<mixed>
*/
public function service_get_qemutemplates()
{
Expand All @@ -978,7 +977,7 @@ public function service_get_qemutemplates()
/**
* Get list of lxc templates
*
* @return array
* @return array<mixed>
*/
public function service_get_lxctemplates()
{
Expand All @@ -989,7 +988,7 @@ public function service_get_lxctemplates()
/**
* Get list of ip ranges
*
* @return array
* @return array<mixed>
*/
public function service_get_ip_ranges()
{
Expand All @@ -1010,7 +1009,7 @@ public function service_get_ip_adresses()
/**
* Get list of vlans
*
* @return array
* @return array<mixed>
*/
public function service_get_vlans()
{
Expand All @@ -1021,7 +1020,7 @@ public function service_get_vlans()
/**
* Get list of tags by type
*
* @return array
* @return array<mixed>
*/
public function service_get_tags($data)
{
Expand All @@ -1038,7 +1037,7 @@ public function service_add_tag($data)
/**
* Get list of tags by storage id
*
* @return array
* @return array<mixed>
*/
public function service_get_tags_by_storage($data)
{
Expand All @@ -1050,7 +1049,7 @@ public function service_get_tags_by_storage($data)
/**
* Get a vm configuration templates
*
* @return array
* @return array<mixed>
*/
public function vm_config_template_get($data)
{
Expand Down Expand Up @@ -1081,7 +1080,7 @@ public function vm_config_template_get($data)
/**
* Function to get storages for vm config template
*
* @return array
* @return array<mixed>
*/

public function vm_config_template_get_storages($data)
Expand All @@ -1101,7 +1100,7 @@ public function vm_config_template_get_storages($data)
/**
* Get list of lxc configuration templates
*
* @return array
* @return array<mixed>
*/
public function lxc_config_template_get($data)
{
Expand Down Expand Up @@ -1131,7 +1130,7 @@ public function lxc_config_template_get($data)
/**
* Get ip range
*
* @return array
* @return array<mixed>
*/
public function ip_range_get($data)
{
Expand Down Expand Up @@ -1472,7 +1471,7 @@ public function ip_range_update($data)
* Delete ip range
*
* @param int $id
* @return array
* @return array<mixed>
*/
public function ip_range_delete($id)
{
Expand Down Expand Up @@ -1591,7 +1590,7 @@ public function proxmox_backup_config($data)
/**
* List existing Backups
*
* @return array
* @return array<mixed>
*/
public function proxmox_list_backups()
{
Expand Down
Loading

0 comments on commit eb02e40

Please sign in to comment.