Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Zend Framework 3 extensions for PHPStan

Notifications You must be signed in to change notification settings

Slamdunk/phpstan-zend-framework

 
 

Repository files navigation

Repository abandoned 2019-12-31

This repository has moved to Slamdunk/phpstan-laminas-framework.

PHPStan extension for Zend Framework

Build Status Scrutinizer Code Quality Packagist Total Downloads

This extension provides following features:

  1. Provide correct return types for \Zend\ServiceManager\ServiceLocatorInterface::get() using real service instances
  2. Handle controller plugins that are called using magic __call() in subclasses of \Zend\Mvc\Controller\AbstractController
  3. getApplication(), getRenderer(), getRequest() and getResponse() methods on Controllers, MvcEvents, View, ViewEvent and Application returns the real instance instead of type-hinted interfaces
  4. getView() method on \Zend\View\Helper\AbstractHelper returns the real Renderer instance instead of type-hinted interface
  5. \Zend\Stdlib\ArrayObject is configured as a Universal object crate
  6. Handle \Zend\Stdlib\AbstractOptions magic properties

Installation

To use this extension, require it in Composer:

composer require --dev slam/phpstan-zend-framework

If you also install phpstan/extension-installer then you're all set!

Manual installation

If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:

includes:
    - vendor/slam/phpstan-zend-framework/extension.neon

Configuration

This library already recognize built-in services and plugins.

You can opt in for more advanced analysis by providing the service manager from your own application:

parameters:
    zendframework:
       serviceManagerLoader: tests/service-manager.php

For example, tests/service-manager.php would look something like this:

$app = \Zend\Mvc\Application::init($config);
return $app->getServiceManager();

About

Zend Framework 3 extensions for PHPStan

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%