Skip to content

Commit 3a19c35

Browse files
committed
Change class names to respect the PSR-0 rules
1 parent 378df0a commit 3a19c35

22 files changed

+77
-75
lines changed

src/FontLib/Adobe_Font_Metrics.php renamed to src/FontLib/AdobeFontMetrics.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @package php-font-lib
1818
*/
19-
class Adobe_Font_Metrics {
19+
class AdobeFontMetrics {
2020
private $f;
2121

2222
/**
@@ -38,7 +38,7 @@ function write($file, $encoding = null) {
3838
throw new \Exception("Unkown encoding ($encoding)");
3939
}
4040

41-
$map = new Encoding_Map($map_file);
41+
$map = new EncodingMap($map_file);
4242
$map_data = $map->parse();
4343
}
4444

src/FontLib/Binary_Stream.php renamed to src/FontLib/BinaryStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @package php-font-lib
1515
*/
16-
class Binary_Stream {
16+
class BinaryStream {
1717
/**
1818
* @var resource The file pointer
1919
*/

src/FontLib/EOT/File.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ function parse() {
6161
// TODO Read font data ...
6262
}
6363

64-
/**
65-
* Little endian version of the read method
66-
*/
64+
/**
65+
* Little endian version of the read method
66+
*
67+
* @param int $n The number of bytes to read
68+
*
69+
* @return string
70+
*/
6771
public function read($n) {
6872
if ($n < 1) {
6973
return "";

src/FontLib/Encoding_Map.php renamed to src/FontLib/EncodingMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @package php-font-lib
1515
*/
16-
class Encoding_Map {
16+
class EncodingMap {
1717
private $f;
1818

1919
function __construct($file) {
@@ -24,7 +24,7 @@ function parse() {
2424
$map = array();
2525

2626
while ($line = fgets($this->f)) {
27-
if (preg_match("/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/", $line, $matches)) {
27+
if (preg_match('/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/', $line, $matches)) {
2828
$unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]);
2929
$map[hexdec($matches[1])] = array($unicode, $matches[4]);
3030
}

src/FontLib/Glyph/Outline.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
use FontLib\Table\Type\glyf;
1212
use FontLib\TrueType\File;
13-
use FontLib\Binary_Stream;
13+
use FontLib\BinaryStream;
1414

1515
/**
1616
* `glyf` font table.
1717
*
1818
* @package php-font-lib
1919
*/
20-
class Outline extends Binary_Stream {
20+
class Outline extends BinaryStream {
2121
/**
2222
* @var \FontLib\Table\Type\glyf
2323
*/
@@ -47,12 +47,12 @@ static function init(glyf $table, $offset, $size) {
4747
$font->seek($offset);
4848

4949
if ($font->readInt16() > -1) {
50-
/** @var Outline_Simple $glyph */
51-
$glyph = new Outline_Simple($table, $offset, $size);
50+
/** @var OutlineSimple $glyph */
51+
$glyph = new OutlineSimple($table, $offset, $size);
5252
}
5353
else {
54-
/** @var Outline_Composite $glyph */
55-
$glyph = new Outline_Composite($table, $offset, $size);
54+
/** @var OutlineComposite $glyph */
55+
$glyph = new OutlineComposite($table, $offset, $size);
5656
}
5757

5858
$glyph->parse();

src/FontLib/Glyph/Outline_Component.php renamed to src/FontLib/Glyph/OutlineComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @package php-font-lib
1515
*/
16-
class Outline_Component {
16+
class OutlineComponent {
1717
public $flags;
1818
public $glyphIndex;
1919
public $a, $b, $c, $d, $e, $f;

src/FontLib/Glyph/Outline_Composite.php renamed to src/FontLib/Glyph/OutlineComposite.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
namespace FontLib\Glyph;
1111

12-
use FontLib\Table\Type\glyf;
13-
1412
/**
1513
* Composite glyph outline
1614
*
1715
* @package php-font-lib
1816
*/
19-
class Outline_Composite extends Outline {
17+
class OutlineComposite extends Outline {
2018
const ARG_1_AND_2_ARE_WORDS = 0x0001;
2119
const ARGS_ARE_XY_VALUES = 0x0002;
2220
const ROUND_XY_TO_GRID = 0x0004;
@@ -29,7 +27,7 @@ class Outline_Composite extends Outline {
2927
const OVERLAP_COMPOUND = 0x0400;
3028

3129
/**
32-
* @var Outline_Component[]
30+
* @var OutlineComponent[]
3331
*/
3432
public $components = array();
3533

@@ -113,7 +111,7 @@ function parseData() {
113111
//
114112
//}
115113

116-
$component = new Outline_Component();
114+
$component = new OutlineComponent();
117115
$component->flags = $flags;
118116
$component->glyphIndex = $glyphIndex;
119117
$component->a = $a;
@@ -219,7 +217,7 @@ function encode() {
219217
public function getSVGContours() {
220218
$contours = array();
221219

222-
/** @var \FontLib\Table\\FontLib\Table\Type\glyf $glyph_data */
220+
/** @var \FontLib\Table\Type\glyf $glyph_data */
223221
$glyph_data = $this->getFont()->getTableObject("glyf");
224222

225223
/** @var Outline[] $glyphs */

src/FontLib/Glyph/Outline_Simple.php renamed to src/FontLib/Glyph/OutlineSimple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @package php-font-lib
1616
*/
17-
class Outline_Simple extends Outline {
17+
class OutlineSimple extends Outline {
1818
const ON_CURVE = 0x01;
1919
const X_SHORT_VECTOR = 0x02;
2020
const Y_SHORT_VECTOR = 0x04;

src/FontLib/Header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @package php-font-lib
1616
*/
17-
abstract class Header extends Binary_Stream {
17+
abstract class Header extends BinaryStream {
1818
/**
1919
* @var File
2020
*/

src/FontLib/OpenType/Table_Directory_Entry.php renamed to src/FontLib/OpenType/TableDirectoryEntry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
*
1414
* @package php-font-lib
1515
*/
16-
class Table_Directory_Entry extends \FontLib\TrueType\Table_Directory_Entry {
16+
class TableDirectoryEntry extends \FontLib\TrueType\TableDirectoryEntry {
1717

1818
}

src/FontLib/Table/Directory_Entry.php renamed to src/FontLib/Table/DirectoryEntry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
use FontLib\TrueType\File;
1111
use FontLib\Font;
12-
use FontLib\Binary_Stream;
12+
use FontLib\BinaryStream;
1313

1414
/**
1515
* Generic Font table directory entry.
1616
*
1717
* @package php-font-lib
1818
*/
19-
class Directory_Entry extends Binary_Stream {
19+
class DirectoryEntry extends BinaryStream {
2020
/**
2121
* @var File
2222
*/

src/FontLib/Table/Table.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
use FontLib\TrueType\File;
1111
use FontLib\Font;
12-
use FontLib\Binary_Stream;
12+
use FontLib\BinaryStream;
1313

1414
/**
1515
* Generic font table.
1616
*
1717
* @package php-font-lib
1818
*/
19-
class Table extends Binary_Stream {
19+
class Table extends BinaryStream {
2020
/**
21-
* @var Directory_Entry
21+
* @var DirectoryEntry
2222
*/
2323
protected $entry;
2424
protected $def = array();
2525

2626
public $data;
2727

28-
final public function __construct(Directory_Entry $entry) {
28+
final public function __construct(DirectoryEntry $entry) {
2929
$this->entry = $entry;
3030
$entry->setTable($this);
3131
}

src/FontLib/Table/Type/glyf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use FontLib\Table\Table;
1212
use FontLib\Glyph\Outline;
13-
use FontLib\Glyph\Outline_Simple;
13+
use FontLib\Glyph\OutlineSimple;
1414

1515
/**
1616
* `glyf` font table.
@@ -106,7 +106,7 @@ public function toHTML() {
106106
);
107107
$shape_json = json_encode($shape);
108108

109-
$type = ($glyph instanceof Outline_Simple ? "simple" : "composite");
109+
$type = ($glyph instanceof OutlineSimple ? "simple" : "composite");
110110
$char = isset($glyphIndexArray[$g]) ? $glyphIndexArray[$g] : 0;
111111
$name = isset($names[$g]) ? $names[$g] : sprintf("uni%04x", $char);
112112
$char = $char ? "&#{$glyphIndexArray[$g]};" : "";

src/FontLib/Table/Type/name.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ protected function _parse() {
143143

144144
$records = array();
145145
for ($i = 0; $i < $data["count"]; $i++) {
146-
$record = new name_Record();
147-
$record_data = $font->unpack(name_Record::$format);
146+
$record = new nameRecord();
147+
$record_data = $font->unpack(nameRecord::$format);
148148
$record->map($record_data);
149149

150150
$records[] = $record;
@@ -166,7 +166,7 @@ protected function _parse() {
166166
protected function _encode() {
167167
$font = $this->getFont();
168168

169-
/** @var name_Record[] $records */
169+
/** @var nameRecord[] $records */
170170
$records = $this->data["records"];
171171
$count_records = count($records);
172172

@@ -180,7 +180,7 @@ protected function _encode() {
180180
$record->length = mb_strlen($record->getUTF16(), "8bit");
181181
$record->offset = $offset;
182182
$offset += $record->length;
183-
$length += $font->pack(name_Record::$format, (array)$record);
183+
$length += $font->pack(nameRecord::$format, (array)$record);
184184
}
185185

186186
foreach ($records as $record) {

src/FontLib/Table/Type/name_Record.php renamed to src/FontLib/Table/Type/nameRecord.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
namespace FontLib\Table\Type;
99

1010
use FontLib\Font;
11-
use FontLib\Binary_Stream;
11+
use FontLib\BinaryStream;
1212

1313
/**
1414
* Font table name record.
1515
*
1616
* @package php-font-lib
1717
*/
18-
class name_Record extends Binary_Stream {
18+
class nameRecord extends BinaryStream {
1919
public $platformID;
2020
public $platformSpecificID;
2121
public $languageID;

src/FontLib/TrueType/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace FontLib\TrueType;
1010

1111
use Countable;
12-
use FontLib\Binary_Stream;
12+
use FontLib\BinaryStream;
1313
use Iterator;
1414
use OutOfBoundsException;
1515

@@ -18,7 +18,7 @@
1818
*
1919
* @package php-font-lib
2020
*/
21-
class Collection extends Binary_Stream implements Iterator, Countable {
21+
class Collection extends BinaryStream implements Iterator, Countable {
2222
/**
2323
* Current iterator position.
2424
*

src/FontLib/TrueType/File.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88

99
namespace FontLib\TrueType;
1010

11-
use FontLib\Adobe_Font_Metrics;
11+
use FontLib\AdobeFontMetrics;
1212
use FontLib\Font;
13-
use FontLib\Binary_Stream;
13+
use FontLib\BinaryStream;
1414
use FontLib\Table\Table;
15-
use FontLib\Table\Directory_Entry;
15+
use FontLib\Table\DirectoryEntry;
1616
use FontLib\Table\Type\glyf;
1717
use FontLib\Table\Type\name;
18-
use FontLib\Table\Type\name_Record;
18+
use FontLib\Table\Type\nameRecord;
1919

2020
/**
2121
* TrueType font file.
2222
*
2323
* @package php-font-lib
2424
*/
25-
class File extends Binary_Stream {
25+
class File extends BinaryStream {
2626
/**
2727
* @var Header
2828
*/
@@ -228,7 +228,7 @@ function encode($tags = array()) {
228228

229229
Font::d("Tables : " . implode(", ", $tags));
230230

231-
/** @var Directory_Entry[] $entries */
231+
/** @var DirectoryEntry[] $entries */
232232
$entries = array();
233233
foreach ($tags as $tag) {
234234
if (!isset($this->directory[$tag])) {
@@ -282,10 +282,10 @@ function parseTableEntries() {
282282

283283

284284
$type = $this->getFontType();
285-
$class = "FontLib\\$type\\Table_Directory_Entry";
285+
$class = "FontLib\\$type\\TableDirectoryEntry";
286286

287287
for ($i = 0; $i < $this->header->data["numTables"]; $i++) {
288-
/** @var Table_Directory_Entry $entry */
288+
/** @var TableDirectoryEntry $entry */
289289
$entry = new $class($this);
290290
$entry->parse();
291291

@@ -352,12 +352,12 @@ public function getData($name, $key = null) {
352352
}
353353
}
354354

355-
function addDirectoryEntry(Directory_Entry $entry) {
355+
function addDirectoryEntry(DirectoryEntry $entry) {
356356
$this->directory[$entry->tag] = $entry;
357357
}
358358

359359
function saveAdobeFontMetrics($file, $encoding = null) {
360-
$afm = new Adobe_Font_Metrics($this);
360+
$afm = new AdobeFontMetrics($this);
361361
$afm->write($file, $encoding);
362362
}
363363

@@ -369,7 +369,7 @@ function saveAdobeFontMetrics($file, $encoding = null) {
369369
* @return string|null
370370
*/
371371
function getNameTableString($nameID) {
372-
/** @var name_Record[] $records */
372+
/** @var nameRecord[] $records */
373373
$records = $this->getData("name", "records");
374374

375375
if (!isset($records[$nameID])) {

src/FontLib/TrueType/Table_Directory_Entry.php renamed to src/FontLib/TrueType/TableDirectoryEntry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
namespace FontLib\TrueType;
1010

11-
use FontLib\Table\Directory_Entry;
11+
use FontLib\Table\DirectoryEntry;
1212

1313
/**
1414
* TrueType table directory entry.
1515
*
1616
* @package php-font-lib
1717
*/
18-
class Table_Directory_Entry extends Directory_Entry {
18+
class TableDirectoryEntry extends DirectoryEntry {
1919
function __construct(File $font) {
2020
parent::__construct($font);
2121
}

0 commit comments

Comments
 (0)