承接 reinfi/laminas-typed-params 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reinfi/laminas-typed-params

最新稳定版本:1.2.0

Composer 安装命令:

composer require reinfi/laminas-typed-params

包简介

A Laminas Framework module for typed params plugin to solve static code analysis.

README 文档

README

Laminas controller plugin for params to solve static code analysis.

=======

  1. Installation
  2. Configuration
  3. Differences

Installation

  1. Install with Composer: composer require reinfi/laminas-typed-params.
  2. Enable the module via config in appliation.config.php under modules key:
    return [
        'modules' => [
            'Reinfi\TypedParams',
            // other modules
        ],
    ];

Configuration

To enable static code analysis to find your controller plugin you need to add it to your controller class.

use Laminas\Mvc\Controller\AbstractActionController;
use Reinfi\TypedParams\Plugin\TypedParams;

/**
 * @method TypedParams typedParams() 
 */
class MyController extends AbstractActionController {

    public function indexAction()
    {
        $id = $this->typedParams()->fromRoute('id')->asNonEmptyString();
    }
}

In this example static code analysis will now know that id is always a non empty string.

Differences

As of now you can not have conditional return types in the @method Annotation, i.e.

/**
 * @method ($param is string ? TypedValue : TypedParams) typedParams(string $param, $default = null)
 */

For that reason the invocation of the plugin always returns the plugin itself and you need to use the public methods.

In difference to the laminas mvc controller plugin params which returns route parameters if invoked with a parameter.

public function __invoke($param = null, $default = null)
{
    if ($param === null) {
        return $this;
    }
    return $this->fromRoute($param, $default);
}

统计信息

  • 总下载量: 12.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固