Skip to content

Commit

Permalink
[Psalm] Fix filter function refinment bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
whsv26 committed Feb 8, 2022
1 parent f0512e9 commit 4186d99
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.6'
services:
php:
container_name: php_functional
build:
context: ./docker/php
dockerfile: Dockerfile
tty: true
volumes:
- ./:/app
30 changes: 30 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.0-cli

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions

RUN apt-get update -y && apt-get install -y curl unzip

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin --filename=composer --quiet

RUN install-php-extensions xdebug

COPY ./ "$PHP_INI_DIR/conf.d"

ARG HOST_UID=1000
ARG HOST_GID=1000
ARG HOST_USER=docker-user
ARG HOST_GROUP=docker-group

RUN echo '%sudonopswd ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& groupadd -g $HOST_GID $HOST_GROUP \
&& groupadd sudonopswd \
&& useradd -m -l -g $HOST_GROUP -u $HOST_UID $HOST_USER \
&& usermod -aG sudo $HOST_USER \
&& usermod -aG sudonopswd $HOST_USER \
&& chown -R $HOST_USER:$HOST_GROUP /opt \
&& chmod 755 /opt

USER $HOST_USER

WORKDIR /app
4 changes: 2 additions & 2 deletions src/Fp/Psalm/Util/TypeRefinement/CollectionTypeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static function fromSeq(Atomic $atomic): Option
->filter(fn($a) => $a instanceof TGenericObject)
->filter(fn($a) => classOf($a->value, Seq::class) || classOf($a->value, NonEmptySeq::class))
->filter(fn($a) => 1 === count($a->type_params))
->map(fn($a) => new CollectionTypeParams(Type::getArrayKey(), $a->type_params[1]));
->map(fn($a) => new CollectionTypeParams(Type::getArrayKey(), $a->type_params[0]));
}

/**
Expand All @@ -95,7 +95,7 @@ private static function fromSet(Atomic $atomic): Option
->filter(fn($a) => $a instanceof TGenericObject)
->filter(fn($a) => classOf($a->value, Set::class) || classOf($a->value, NonEmptySet::class))
->filter(fn($a) => 1 === count($a->type_params))
->map(fn($a) => new CollectionTypeParams(Type::getArrayKey(), $a->type_params[1]));
->map(fn($a) => new CollectionTypeParams(Type::getArrayKey(), $a->type_params[0]));
}

/**
Expand Down

0 comments on commit 4186d99

Please sign in to comment.