sbzhu / weworkapi_php

official lib of wework api
https://work.weixin.qq.com/api/doc
355 stars 286 forks source link

Message类中count()函数报错,还是null和array()的问题,希望能改一下~ #19

Closed xiaoyouxi01 closed 5 years ago

xiaoyouxi01 commented 6 years ago

之前修正过类似问题,php7.2中的count($args)函数,$args参数需为数组或者Countable对象,否则会报错。 https://github.com/sbzhu/weworkapi_php/issues/13

在weworkapi_php-master\api\datastructure\Message.class.php第9、10、11行:

    public $touser = null; // string array
    public $toparty = null; // uint array
    public $totag = null; // uint array 

这三个参数初始值建议改为array(),而不用null。 因为在第18、19、20行会对这三个参数使用count()函数

        if (count($this->touser) > 1000) throw new QyApiError("touser should be no more than 1000");
        if (count($this->toparty) > 100) throw new QyApiError("toparty should be no more than 100");
        if (count($this->totag) > 100) throw new QyApiError("toparty should be no more than 100");

在实例化Message类后,若这三个参数中的某个参数未赋值时,count(null)会导致报错。

同文件中第280、359行也有类似问题,可以一起改下。 public $articles = null;

xiaoyouxi01 commented 5 years ago

什么时候有空,能修改下这个问题吗?

sbzhu commented 5 years ago

已改,兼容高版本,感谢指出