for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace MusicBrainz;
/**
* Represents a MusicBrainz tag object
* @package MusicBrainz
*/
class Tag
{
* @var string
public $name;
public $score;
* @var array
private $data;
* @param array $tag
* @param MusicBrainz $brainz
public function __construct(array $tag, MusicBrainz $brainz)
$this->data = $tag;
$this->brainz = $brainz;
brainz
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->name = isset($tag['name']) ? (string)$tag['name'] : '';
$this->score = isset($tag['score']) ? (string)$tag['score'] : '';
}
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: