使用 Phan 为你的 PHP 项目保驾护航 - 代码静态扫描
原文:我的个人博客https://mengkang.net/1356.html
很多时候,最大的优势在某些情况下就会变成最大的劣势。PHP 语法非常灵活,也不用编译。但是在项目比较复杂的时候,可能会导致一些意想不到的 bug。
背景分析
不知道你的项目是否有遇到过类似的线上故障呢?比如
继承类语法错误导致的故障
文件1
class Animal
{
public $hasLeg = false;
}
文件2
include "Animal.php";
class Dog extends Animal
{
protected $hasLeg = false;
}
$dog = new Dog();
php Dog.php
Fatal error: Access level to Dog::$hasLeg must be publ