Skip to content

Commit 416e340

Browse files
authored
Merge pull request #600 from mike42/development
Changes for release 2.0.2
2 parents 71e9910 + ed626c2 commit 416e340

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be
7171
- AURES ODP-333
7272
- AURES ODP-500
7373
- Bematech-4200-TH
74+
- Bematech LR2000E
7475
- Bixolon SRP-350III
7576
- Black Copper BC-85AC
7677
- Citizen CBM1000-II
7778
- Citizen CT-S310II
7879
- Dapper-Geyi Q583P
7980
- Daruma DR800
81+
- DR-MP200 (manufacturer unknown)
8082
- EPOS TEP 220M
8183
- Epson EU-T332C
8284
- Epson FX-890 (requires `feedForm()` to release paper).
@@ -108,6 +110,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be
108110
- Nyear NP100
109111
- Okipos 80 Plus III
110112
- Orient BTP-R580
113+
- Partner Tech RP320
111114
- P-822D
112115
- P85A-401 (make unknown)
113116
- Rongta RP326US
@@ -124,6 +127,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be
124127
- Star TUP-592
125128
- Venus V248T
126129
- Xprinter F-900
130+
- Xprinter XP-365B
127131
- Xprinter XP-58 Series
128132
- Xprinter XP-80C
129133
- Xprinter XP-90
@@ -133,6 +137,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be
133137
- Zjiang ZJ-5870
134138
- Zjiang ZJ-5890K
135139
- Zjiang ZJ-5890T (Marketed as POS 5890T)
140+
- Zjiang ZJ-8220
136141

137142
If you use any other printer with this code, please [let us know](https://github.com/mike42/escpos-php/issues/new) so that it can be added to the list.
138143

src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,20 @@ public function __destruct()
5050
*/
5151
public function finalize()
5252
{
53-
fclose($this -> fp);
54-
$this -> fp = false;
53+
if ($this -> fp !== false) {
54+
fclose($this -> fp);
55+
$this -> fp = false;
56+
}
5557
}
5658

5759
/* (non-PHPdoc)
5860
* @see PrintConnector::read()
5961
*/
6062
public function read($len)
6163
{
64+
if ($this -> fp === false) {
65+
throw new Exception("PrintConnector has been closed, cannot read input.");
66+
}
6267
return fread($this -> fp, $len);
6368
}
6469

@@ -69,6 +74,9 @@ public function read($len)
6974
*/
7075
public function write($data)
7176
{
77+
if ($this -> fp === false) {
78+
throw new Exception("PrintConnector has been closed, cannot send output.");
79+
}
7280
fwrite($this -> fp, $data);
7381
}
7482
}

src/Mike42/Escpos/Printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ protected static function validateInteger($test, $min, $max, $source, $argument
11421142
* Throw an exception if the argument given is not an integer within one of the specified ranges
11431143
*
11441144
* @param int $test the input to test
1145-
* @param arrray $ranges array of two-item min/max ranges.
1145+
* @param array $ranges array of two-item min/max ranges.
11461146
* @param string $source the name of the function calling this
11471147
* @param string $source the name of the function calling this
11481148
* @param string $argument the name of the invalid parameter
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
3+
4+
class FilePrintConnectorTest extends PHPUnit_Framework_TestCase
5+
{
6+
public function testTmpfile()
7+
{
8+
// Should attempt to send data to the local printer by writing to it
9+
$tmpfname = tempnam("/tmp", "php");
10+
$connector = new FilePrintConnector($tmpfname);
11+
$connector -> finalize();
12+
$connector -> finalize(); // Silently do nothing if printer already closed
13+
unlink($tmpfname);
14+
}
15+
16+
public function testReadAfterClose()
17+
{
18+
// Should attempt to send data to the local printer by writing to it
19+
$this -> setExpectedException('Exception');
20+
$tmpfname = tempnam("/tmp", "php");
21+
$connector = new FilePrintConnector($tmpfname);
22+
$connector -> finalize();
23+
$connector -> write("Test");
24+
unlink($tmpfname);
25+
}
26+
}

0 commit comments

Comments
 (0)