PHPStan fixes (#13038)

* PHPStan fixes
mostly type fixes
semi-risky changes in availability map widget, tested a bit

* fix style

* Style fix

* restore spaces stupid editor removed

* fix the rest

* device model back

* remove ignores

* introduce variable
This commit is contained in:
Tony Murray
2021-07-13 16:35:43 -05:00
committed by GitHub
parent c563efd284
commit 58ca5994a1
61 changed files with 323 additions and 441 deletions

View File

@@ -27,12 +27,12 @@ class BgpPeerFactory extends Factory
'bgpPeerRemoteAddr' => $this->faker->ipv4,
'bgpPeerRemoteAs' => $this->faker->numberBetween(1, 65535),
'bgpPeerState' => $this->faker->randomElement(['established', 'idle']),
'astext' => $this->faker->sentence(),
'astext' => $this->faker->sentence,
'bgpPeerAdminStatus' => $this->faker->randomElement(['start', 'stop']),
'bgpPeerInUpdates' => $this->faker->randomDigit,
'bgpPeerOutUpdates' => $this->faker->randomDigit,
'bgpPeerInTotalMessages' => $this->faker->randomDigit,
'bgpPeerOutTotalMessages' => $this->faker->randomDigit,
'bgpPeerInUpdates' => $this->faker->randomDigit(),
'bgpPeerOutUpdates' => $this->faker->randomDigit(),
'bgpPeerInTotalMessages' => $this->faker->randomDigit(),
'bgpPeerOutTotalMessages' => $this->faker->randomDigit(),
'bgpPeerFsmEstablishedTime' => $this->faker->unixTime,
'bgpPeerInUpdateElapsedTime' => $this->faker->unixTime,
];

View File

@@ -22,7 +22,7 @@ class ComponentFactory extends Factory
public function definition()
{
return [
'device_id' => $this->faker->randomDigit,
'device_id' => $this->faker->randomDigit(),
'type' => $this->faker->regexify('[A-Za-z0-9]{4,20}'),
];
}

View File

@@ -3,6 +3,8 @@
namespace Database\Factories;
use App\Models\Ipv4Address;
use App\Models\Ipv4Network;
use App\Models\Port;
use Illuminate\Database\Eloquent\Factories\Factory;
use LibreNMS\Util\IPv4;
@@ -29,10 +31,14 @@ class Ipv4AddressFactory extends Factory
'ipv4_address' => $ip->uncompressed(),
'ipv4_prefixlen' => $prefix,
'port_id' => function () {
return \App\Models\Port::factory()->create()->port_id;
$port = Port::factory()->create(); /** @var Port $port */
return $port->port_id;
},
'ipv4_network_id' => function () use ($ip) {
return \App\Models\Ipv4Network::factory()->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr])->ipv4_network_id;
$ipv4 = Ipv4Network::factory()->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr]); /** @var Ipv4Address $ipv4 */
return $ipv4->ipv4_network_id;
},
];
}

View File

@@ -22,13 +22,13 @@ class OspfNbrFactory extends Factory
public function definition()
{
return [
'id' => $this->faker->randomDigit,
'id' => $this->faker->randomDigit(),
'ospfNbrIpAddr' => $this->faker->ipv4,
'ospfNbrAddressLessIndex' => $this->faker->randomDigit,
'ospfNbrAddressLessIndex' => $this->faker->randomDigit(),
'ospfNbrRtrId' => $this->faker->ipv4,
'ospfNbrOptions' => 0,
'ospfNbrPriority' => 1,
'ospfNbrEvents' => $this->faker->randomDigit,
'ospfNbrEvents' => $this->faker->randomDigit(),
'ospfNbrLsRetransQLen' => 0,
'ospfNbmaNbrStatus' => 'active',
'ospfNbmaNbrPermanence' => 'dynamic',

View File

@@ -22,10 +22,10 @@ class OspfPortFactory extends Factory
public function definition()
{
return [
'id' => $this->faker->randomDigit,
'ospf_port_id' => $this->faker->randomDigit,
'id' => $this->faker->randomDigit(),
'ospf_port_id' => $this->faker->randomDigit(),
'ospfIfIpAddress' => $this->faker->ipv4,
'ospfAddressLessIf' => $this->faker->randomDigit,
'ospfAddressLessIf' => $this->faker->randomDigit(),
'ospfIfAreaId' => '0.0.0.0',
];
}

View File

@@ -25,9 +25,9 @@ class SensorFactory extends Factory
$sensor_oid = '.1.3.6.1.4.1.4115.1.4.3.3.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10);
return [
'sensor_index' => $this->faker->randomDigit,
'sensor_index' => $this->faker->randomDigit(),
'sensor_class' => $this->faker->randomElement($sensor_class),
'sensor_current' => $this->faker->randomDigit,
'sensor_current' => $this->faker->randomDigit(),
'sensor_oid' => $sensor_oid,
];
}

View File

@@ -24,11 +24,11 @@ class VminfoFactory extends Factory
{
return [
'vm_type' => $this->faker->text(16),
'vmwVmVMID' => $this->faker->randomDigit,
'vmwVmVMID' => $this->faker->randomDigit(),
'vmwVmDisplayName' => $this->faker->domainWord . '.' . $this->faker->domainName,
'vmwVmGuestOS' => $this->faker->text(128),
'vmwVmMemSize' => $this->faker->randomDigit,
'vmwVmCpus' => $this->faker->randomDigit,
'vmwVmMemSize' => $this->faker->randomDigit(),
'vmwVmCpus' => $this->faker->randomDigit(),
'vmwVmState' => $this->faker->randomElement([PowerState::OFF, PowerState::ON, PowerState::SUSPENDED, PowerState::UNKNOWN]),
];
}