내 PHP IDE (NuSphere PhpEd)에서 오른쪽에 입력 한 속성이 표시되지 않는 2D 배열 요소 (개체)의 속성을 검색하고 싶습니다. 내 IDE의 화살표.PHP 7 배열 - 2D 배열 요소의 속성 감지
PHP 7에서 자동으로 각 요소가 특정 속성을 가진 객체 인 다차원 배열 요소 속성 제안을 생성하는 방법이 있습니까? 당신이하는 PHPDoc 주석을 사용하는 것이 행복 경우
<?php
class Cell
{
private $color;
public function __construct()
{
$this->color = "red";
}
public function __get($propertyName)
{
if ($propertyName == 'color')
return $this->color;
}
public function __set($propertyName, $value)
{
if ($propertyName == 'color')
$this->color = $value;
}
}
class Matrix implements ArrayAccess
{
private $matrix = array();
public function __construct($maxX, $maxY)
{
$this->matrix = array_fill(1, $maxX, array_fill(1, $maxY, null));
}
public function &offsetGet($name)
{
return $this->matrix[$name];
}
public function offsetSet($name, $value)
{
$this->matrix[$name] = $value;
}
public function offsetExists($name)
{
return isset($this->matrix[$name]);
}
public function offsetUnset($name)
{
unset($this->matrix[$name]);
}
}
$matrix = new Matrix(3,3);
for ($xIdx = 1; $xIdx <= 3; $xIdx++)
for ($yIdx = 1; $yIdx <= 3; $yIdx++)
$matrix[$xIdx][$yIdx] = new Cell();
$matrix[2][2]->color = "green";
echo $matrix[2][2]->color;
?>
당신은 정보 유형을 프로비저닝 할 수있는 기술인 phpdoc의 영역으로 이동하고 있습니다. – Marty
답장을 보내 주셔서 감사합니다. 우연히 예를 들어 화살표를 입력 할 때 phpdoc에서 속성 목록을 제안한 것을 볼 수 있습니까? – Vahe
물론 끝났습니다. – Marty