diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a99bf0cf2bdecc85ce1f18150e93d584097265cf..ff115a384cb5029fd83f1724560a9b0d1589ba12 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,17 +1,40 @@
 stages:
+- build
 - tests
 
+dependencies.install:
+  stage: build
+  tags: ["grifart/php7.1-with-gulp-and-all-php-modules"]
+  image: grifart/php7.1-with-gulp-and-all-php-modules
+
+  script:
+    - composer install --ansi --no-interaction
+  artifacts:
+    expire_in: 30 minutes
+    paths:
+      - vendor
+
 tests-php7.1:
   stage: tests
   tags: ["grifart/php7.1-with-gulp-and-all-php-modules"]
   image: grifart/php7.1-with-gulp-and-all-php-modules
-  
-  before_script:
-    - composer install --ansi --no-interaction
+
   script:
     - vendor/bin/tester -c tests/php.ini tests
+
   artifacts:
     expire_in: 30 minutes
     paths:
       - tests
     when: on_failure
+
+phpstan:
+  stage: tests
+  tags: ["grifart/php7.1-with-gulp-and-all-php-modules"]
+  image: grifart/php7.1-with-gulp-and-all-php-modules
+
+  # Now in require-dev in composer.json
+  # before_script:
+  #   - composer require --dev phpstan/phpstan --ansi --no-interaction
+  script:
+    - vendor/bin/phpstan analyse src -l 5 --ansi --no-progress --no-interaction
diff --git a/composer.json b/composer.json
index 01c991a447acb704077d0302bab01d859ef01de0..a7f4d1f8693124f135a2a22b7c4d919f71e2bbdb 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,8 @@
 	},
 
 	"require-dev": {
-		"nette/tester": "~1.7.1"
+		"nette/tester": "~1.7.1",
+		"phpstan/phpstan": "^0.6.4"
 	},
 
 	"autoload": {