Skip to content

Commit

Permalink
Fixing stuff reported by PHPStan.
Browse files Browse the repository at this point in the history
  • Loading branch information
smuuf committed Dec 1, 2022
1 parent 5d929a2 commit 6f738fc
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/Cli/Entrypoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ public function execute(): void {
Logger::enable();
}

// Enable stats gathering, if requested.
// If requested, print stats at the absolute end of runtime.
if ($cfg['print_runtime_stats']) {

Stats::enable();
// Try printing stats at the absolute end of runtime.
register_shutdown_function(fn() => Stats::print());

}

// Determine the source. Act as REPL if no source was specified.
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/TerminalIoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TerminalIoDriver implements StdIoDriverInterface {

private ?string $buffer = null;

private function bufferInput(?string $buffer) {
private function bufferInput(?string $buffer): void {
$this->buffer = (string) $buffer;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/TypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Smuuf\Primi\Extensions;

use \Smuuf\Primi\Values\AbstractValue;
use \Smuuf\Primi\Helpers\Types;
use \Smuuf\Primi\Values\FuncValue;
use \Smuuf\Primi\Helpers\ValueFriends;

abstract class TypeExtension extends ValueFriends {
Expand All @@ -15,8 +15,8 @@ final private function __construct() {
}

/**
* @return array<string, FuncValue> Dict array containing Primi functions
* which represent class methods.
* @return array<string, AbstractValue> Dict array containing Primi
* function/method object that represent type/class methods.
*/
public static function execute(): array {
return Types::prepareTypeMethods(
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/Kinds/IfStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function reduce(array &$node): void {
$elifs = [];
if (isset($node['elifCond'])) {

$node['elifCond'] = Func::ensure_indexed($node['elifCond'] ?? []);
$node['elifCond'] = Func::ensure_indexed($node['elifCond']);
$node['elifBlock'] = Func::ensure_indexed($node['elifBlock'] ?? []);

foreach ($node['elifCond'] as $i => $elifCond) {
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public static function is_subclass_of(
* from ordinary method to static method for the type system and object
* model to work correctly.
*
* @param array<AbstractValue>
* @return array<AbstractValue>
* @param array<string, AbstractValue> $methods
* @return array<string, AbstractValue>
*/
public static function prepareTypeMethods(
array $methods,
Expand Down
2 changes: 1 addition & 1 deletion src/Values/MethodValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MethodValue extends FuncValue {
public function __construct(
FnContainer $fn,
private bool $isStatic = false,
private ?AbstractValue $bind = \null,
?AbstractValue $bind = \null,
) {

if ($isStatic && $bind) {
Expand Down
4 changes: 3 additions & 1 deletion src/Values/TypeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class TypeValue extends AbstractBuiltinValue {

/**
* @param string $name Name of the type.
* @param ?TypeValue $parent Parent Primi type of this type.
* @param array<string, AbstractValue> $attrs
* @param bool $isFinal Final type/class cannot be used as a parent type.
* @param ?TypeValue Parent Primi type of this type.
* @param bool $isMutable IF true, it is possible to mutate type's attrs
* in userland.
*/
public function __construct(
protected string $name,
Expand Down

0 comments on commit 6f738fc

Please sign in to comment.