diff --git a/docs/Built-In-Output/QREps.md b/docs/Built-In-Output/QREps.md
index 74ceec275..1d2d900cc 100644
--- a/docs/Built-In-Output/QREps.md
+++ b/docs/Built-In-Output/QREps.md
@@ -36,7 +36,7 @@ Render and save to file:
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
$file = __DIR__.'/qrcode.eps';
-(new QRCode($options))->render($data, $file);
+new QRCode($options)->render($data, $file);
```
@@ -46,7 +46,7 @@ Push as file download in a browser:
header('Content-type: application/postscript');
header('Content-Disposition: filename="qrcode.eps"');
-echo (new QRCode($options))->render($data);
+echo new QRCode($options)->render($data);
exit;
```
diff --git a/docs/Built-In-Output/QRFpdf.md b/docs/Built-In-Output/QRFpdf.md
index c9d6ca0e3..05645a4b6 100644
--- a/docs/Built-In-Output/QRFpdf.md
+++ b/docs/Built-In-Output/QRFpdf.md
@@ -34,7 +34,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> data:application/pdf;base64,...
+$out = new QRCode($options)->render($data); // -> data:application/pdf;base64,...
echo $out;
```
@@ -46,7 +46,7 @@ Return the `FPDF` instance (will ignore other output options):
$options->returnResource = true;
/** @var \FPDF $fpdf */
-$fpdf = (new QRCode($options))->render($data);
+$fpdf = new QRCode($options)->render($data);
// do stuff with the FPDF instance...
diff --git a/docs/Built-In-Output/QRGdImage.md b/docs/Built-In-Output/QRGdImage.md
index a4853f4fa..ed1d9214c 100644
--- a/docs/Built-In-Output/QRGdImage.md
+++ b/docs/Built-In-Output/QRGdImage.md
@@ -46,7 +46,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> data:image/webp;base64,...
+$out = new QRCode($options)->render($data); // -> data:image/webp;base64,...
printf('
', $alt, $out);
```
@@ -58,7 +58,7 @@ Return the `GdImage` instance (will ignore other output options):
$options->returnResource = true;
/** @var \GdImage $gdImage */
-$gdImage = (new QRCode($options))->render($data);
+$gdImage = new QRCode($options)->render($data);
// do stuff with the GdImage instance...
$size = imagesx($gdImage);
diff --git a/docs/Built-In-Output/QRImagick.md b/docs/Built-In-Output/QRImagick.md
index 433362c65..701e78118 100644
--- a/docs/Built-In-Output/QRImagick.md
+++ b/docs/Built-In-Output/QRImagick.md
@@ -49,7 +49,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> data:image/webp;base64,...
+$out = new QRCode($options)->render($data); // -> data:image/webp;base64,...
printf('
', $alt, $out);
```
@@ -61,7 +61,7 @@ Return the `Imagick` instance (will ignore other output options):
$options->returnResource = true;
/** @var \Imagick $imagick */
-$imagick = (new QRCode($options))->render($data);
+$imagick = new QRCode($options)->render($data);
// do stuff with the Imagick instance...
$imagick->scaleImage(150, 150, true);
diff --git a/docs/Built-In-Output/QRInterventionImage.md b/docs/Built-In-Output/QRInterventionImage.md
index a7f06cd2d..26ae361f8 100644
--- a/docs/Built-In-Output/QRInterventionImage.md
+++ b/docs/Built-In-Output/QRInterventionImage.md
@@ -44,7 +44,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> data:image/png;base64,...
+$out = new QRCode($options)->render($data); // -> data:image/png;base64,...
printf('
', $alt, $out);
```
@@ -56,7 +56,7 @@ Return the `ImageInterface` instance (will ignore other output options):
$options->returnResource = true;
/** @var \Intervention\Image\Interfaces\ImageInterface $image */
-$image = (new QRCode($options))->render($data);
+$image = new QRCode($options)->render($data);
// do stuff with the ImageInterface instance...
diff --git a/docs/Built-In-Output/QRMarkupHTML.md b/docs/Built-In-Output/QRMarkupHTML.md
index 0f3106885..f0521a7c5 100644
--- a/docs/Built-In-Output/QRMarkupHTML.md
+++ b/docs/Built-In-Output/QRMarkupHTML.md
@@ -34,7 +34,7 @@ Output in a HTML document (via PHP):
render($data);
+$out = new QRCode($options)->render($data);
header('Content-type: text/html');
diff --git a/docs/Built-In-Output/QRMarkupSVG.md b/docs/Built-In-Output/QRMarkupSVG.md
index 082bf5feb..c85fff3fa 100644
--- a/docs/Built-In-Output/QRMarkupSVG.md
+++ b/docs/Built-In-Output/QRMarkupSVG.md
@@ -53,7 +53,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> data:image/svg+xml;base64,PD94bWwgdmVyc2...
+$out = new QRCode($options)->render($data); // -> data:image/svg+xml;base64,PD94bWwgdmVyc2...
printf('
', $alt, $out);
```
diff --git a/docs/Built-In-Output/QRMarkupXML.md b/docs/Built-In-Output/QRMarkupXML.md
index 8ba20da77..8ae477f2e 100644
--- a/docs/Built-In-Output/QRMarkupXML.md
+++ b/docs/Built-In-Output/QRMarkupXML.md
@@ -78,7 +78,7 @@ Render the output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$out = (new QRCode($options))->render($data); // -> XML, rendered as SVG
+$out = new QRCode($options)->render($data); // -> XML, rendered as SVG
header('Content-type: application/xml');
diff --git a/docs/Built-In-Output/QRStringJSON.md b/docs/Built-In-Output/QRStringJSON.md
index 2dbeca522..ae36c2bc4 100644
--- a/docs/Built-In-Output/QRStringJSON.md
+++ b/docs/Built-In-Output/QRStringJSON.md
@@ -16,7 +16,7 @@ header('Content-type: application/json');
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-echo (new QRCode($options))->render($data); // -> JSON string
+echo new QRCode($options)->render($data); // -> JSON string
```
The associated [JSON schema](https://json-schema.org/specification) can be found over at GitHub: [`qrcode.schema.json`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/qrcode.schema.json)
@@ -28,7 +28,7 @@ The previous versions of `php-qrcode` (v5 and earlier) just dumped an array repr
which is equivalent to the following:
```php
-$matrix = (new QRCode($options))->getQRMatrix(); // -> QRMatrix instance
+$matrix = new QRCode($options)->getQRMatrix(); // -> QRMatrix instance
// retrieve the internal matrix as an array of booleans
$json = json_encode($matrix->getMatrix(true), $jsonFlags);
diff --git a/docs/Built-In-Output/QRStringText.md b/docs/Built-In-Output/QRStringText.md
index 3a9691ddb..8e96470aa 100644
--- a/docs/Built-In-Output/QRStringText.md
+++ b/docs/Built-In-Output/QRStringText.md
@@ -34,7 +34,7 @@ Output:
```php
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
-$qrcode = (new QRCode($options))->render($data);
+$qrcode = new QRCode($options)->render($data);
echo "\n\n$qrcode\n\n";
```
diff --git a/docs/Usage/Advanced-usage.md b/docs/Usage/Advanced-usage.md
index c3c29eb4f..5ef00931c 100644
--- a/docs/Usage/Advanced-usage.md
+++ b/docs/Usage/Advanced-usage.md
@@ -56,7 +56,7 @@ $json = json_encode($options, JSON_THROW_ON_ERROR);
// via __toString()
$json = (string)$options;
-$options = (new QROptions)->fromJSON($json);
+$options = new QROptions()->fromJSON($json);
// on an existing instance - properties will be overwriten
$options->fromJSON($json);
```
diff --git a/docs/Usage/Installation.md b/docs/Usage/Installation.md
index 767617c72..5930d0eac 100644
--- a/docs/Usage/Installation.md
+++ b/docs/Usage/Installation.md
@@ -24,7 +24,7 @@ In case you want to keep using `dev-main`, specify the hash of a commit to avoid
#### Version switch
-If your application supports older PHP versions and uses the basic `QRCode` syntax `(new QRCode)->render($data)`, then you can add a version switch to your `composer.json` to allow installing a `php-qrcode` version that suits the platform it runs on:
+If your application supports older PHP versions and uses the basic `QRCode` syntax `new QRCode()->render($data)`, then you can add a version switch to your `composer.json` to allow installing a `php-qrcode` version that suits the platform it runs on:
```json
{
diff --git a/docs/Usage/Quickstart.md b/docs/Usage/Quickstart.md
index fb7b67f3f..7c8b8503f 100644
--- a/docs/Usage/Quickstart.md
+++ b/docs/Usage/Quickstart.md
@@ -15,7 +15,7 @@ require_once __DIR__.'/../vendor/autoload.php';
We want to encode this URI for a mobile authenticator into a QRcode image:
```php
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
-$qrcode = (new QRCode)->render($data);
+$qrcode = new QRCode()->render($data);
// default output is a base64 encoded data URI
printf('
', $qrcode);
@@ -33,7 +33,7 @@ $options->outputBase64 = false; // output raw image instead of base64 data URI
header('Content-type: image/svg+xml'); // the image type is SVG by default
-echo (new QRCode($options))->render($data);
+echo new QRCode($options)->render($data);
```
See [Advanced usage](../Usage/Advanced-usage.md) for a more in-depth usage guide
diff --git a/docs/Usage/Reading-QRCodes.md b/docs/Usage/Reading-QRCodes.md
index 3cac2333b..3d8ba4d9b 100644
--- a/docs/Usage/Reading-QRCodes.md
+++ b/docs/Usage/Reading-QRCodes.md
@@ -52,7 +52,7 @@ $source = new GDLuminanceSource($gdimage, $options);
The `Decoder` takes a `QROptions` instance as parameter, which currently has no use - it is only handed over for possible future uses.
```php
-$result = (new Decoder($options))->decode($source);
+$result = new Decoder($options)->decode($source);
```
That is all! The decoder will either return a `DecoderResult` instance or throw an exception.
@@ -85,7 +85,7 @@ $matrix = $result->getQRMatrix();
// ...matrix modification...
-$output = (new QRCode($options))->renderMatrix($matrix);
+$output = new QRCode($options)->renderMatrix($matrix);
// ...dump output
```
diff --git a/examples/custom_output.php b/examples/custom_output.php
index 798658a07..27f450cb5 100644
--- a/examples/custom_output.php
+++ b/examples/custom_output.php
@@ -80,6 +80,6 @@ var_dump($qrOutputInterface->dump());
// or just via the options
$options->outputInterface = MyCustomOutput::class;
-var_dump((new QRCode($options))->render($data));
+var_dump(new QRCode($options)->render($data));
exit;
diff --git a/examples/eps.php b/examples/eps.php
index 422d86f78..c1949603f 100644
--- a/examples/eps.php
+++ b/examples/eps.php
@@ -54,7 +54,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ', __DIR__.'/qrcode.eps');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ', __DIR__.'/qrcode.eps');
if(PHP_SAPI !== 'cli'){
// if viewed in the browser, we should push it as file download as EPS isn't usually supported
diff --git a/examples/fpdf.php b/examples/fpdf.php
index cb40d4e22..dee53ac26 100644
--- a/examples/fpdf.php
+++ b/examples/fpdf.php
@@ -52,7 +52,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
header('Content-type: application/pdf');
diff --git a/examples/html.php b/examples/html.php
index 4d5d95b07..628c76c0f 100644
--- a/examples/html.php
+++ b/examples/html.php
@@ -31,7 +31,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-Type: text/html; charset=utf-8');
diff --git a/examples/image.php b/examples/image.php
index 662aeee32..0c193ef85 100644
--- a/examples/image.php
+++ b/examples/image.php
@@ -63,7 +63,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-type: image/png');
diff --git a/examples/imageWithRoundedShapes.php b/examples/imageWithRoundedShapes.php
index 4742ed2e4..5f81bf420 100644
--- a/examples/imageWithRoundedShapes.php
+++ b/examples/imageWithRoundedShapes.php
@@ -150,7 +150,7 @@ $options = new QROptions([
]);
-$img = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$img = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-type: image/png');
diff --git a/examples/imagick.php b/examples/imagick.php
index 65d31a1f5..6e434d8d8 100644
--- a/examples/imagick.php
+++ b/examples/imagick.php
@@ -63,7 +63,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-type: image/webp');
diff --git a/examples/imagickConvertSVGtoPNG.php b/examples/imagickConvertSVGtoPNG.php
index 0b3f04698..b6f4ebdb7 100644
--- a/examples/imagickConvertSVGtoPNG.php
+++ b/examples/imagickConvertSVGtoPNG.php
@@ -71,7 +71,7 @@ class SVGConvert extends QRMarkupSVG{
if($base64){
// use finfo to guess the mime type
- $mime = (new finfo(FILEINFO_MIME_TYPE))->buffer($imageData);
+ $mime = new finfo(FILEINFO_MIME_TYPE)->buffer($imageData);
if($mime === false){
throw new QRCodeOutputException('unable to detect mime type');
@@ -121,7 +121,7 @@ $options->svgDefs = '
// render the SVG and convert to the desired ImageMagick format
-$image = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$image = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-type: image/png');
diff --git a/examples/imagickImageAsBackground.php b/examples/imagickImageAsBackground.php
index c49915e62..8d008e9b8 100644
--- a/examples/imagickImageAsBackground.php
+++ b/examples/imagickImageAsBackground.php
@@ -96,7 +96,7 @@ $options->quietzoneSize = 1;
// dump the output, with an additional logo
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
header('Content-type: image/png');
diff --git a/examples/imagickWithLogo.php b/examples/imagickWithLogo.php
index de6bed1eb..4521049d7 100644
--- a/examples/imagickWithLogo.php
+++ b/examples/imagickWithLogo.php
@@ -123,7 +123,7 @@ $options->keepAsSquare = [
// dump the output, with an additional logo
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
header('Content-type: image/png');
diff --git a/examples/multimode.php b/examples/multimode.php
index cda9eda06..df5a0ac0c 100644
--- a/examples/multimode.php
+++ b/examples/multimode.php
@@ -22,7 +22,7 @@ $options = new QROptions;
$options->outputBase64 = false;
$options->connectPaths = true;
-$qrcode = (new QRCode($options))
+$qrcode = new QRCode($options)
->addNumericSegment('1312')
->addByteSegment("\n")
->addAlphaNumSegment('ACAB')
diff --git a/examples/qrcode-interactive.php b/examples/qrcode-interactive.php
index 42147b4e4..4e477e104 100644
--- a/examples/qrcode-interactive.php
+++ b/examples/qrcode-interactive.php
@@ -80,7 +80,7 @@ try{
'imageTransparent' => false,
]);
- $qrcode = (new QRCode($options))->render($_POST['inputstring']);
+ $qrcode = new QRCode($options)->render($_POST['inputstring']);
if(in_array($_POST['output_type'], ['png', 'jpg', 'gif', 'svg'], true)){
$qrcode = '
';
diff --git a/examples/reader.php b/examples/reader.php
index 4ec6c1560..d1502b239 100644
--- a/examples/reader.php
+++ b/examples/reader.php
@@ -20,7 +20,7 @@ $options->readerGrayscale = true;
$options->readerIncreaseContrast = true;
try{
- $result = (new QRCode($options))->readFromFile(__DIR__.'/../.github/images/example_image.png');
+ $result = new QRCode($options)->readFromFile(__DIR__.'/../.github/images/example_image.png');
var_dump($result);
}
diff --git a/examples/reflectance.php b/examples/reflectance.php
index c581013a6..caee62562 100644
--- a/examples/reflectance.php
+++ b/examples/reflectance.php
@@ -63,7 +63,7 @@ $options->moduleValues = [
];
-$qrcode = (new QRCode($options))->addByteSegment('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$qrcode = new QRCode($options)->addByteSegment('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
$matrix = $qrcode->getQRMatrix();
$out_normal = $qrcode->renderMatrix($matrix);
diff --git a/examples/svg.php b/examples/svg.php
index 0c65fd7ca..72febaa69 100644
--- a/examples/svg.php
+++ b/examples/svg.php
@@ -53,7 +53,7 @@ $options->svgDefs = '
try{
- $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+ $out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
}
catch(Throwable $e){
// handle the exception in whatever way you need
diff --git a/examples/svgConvertViaCanvas.php b/examples/svgConvertViaCanvas.php
index 4155a0dcb..e1e326f24 100644
--- a/examples/svgConvertViaCanvas.php
+++ b/examples/svgConvertViaCanvas.php
@@ -47,7 +47,7 @@ $options->svgDefs = '
]]>';
-$qrcode = (new QRCode($options))->addByteSegment('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$qrcode = new QRCode($options)->addByteSegment('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
// render the SVG
$svg_raw = $qrcode->render();
diff --git a/examples/svgMeltedModules.php b/examples/svgMeltedModules.php
index 218e163d8..fb660d27c 100644
--- a/examples/svgMeltedModules.php
+++ b/examples/svgMeltedModules.php
@@ -282,7 +282,7 @@ $options->svgDefs = '
]]>';
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/svgModuleGroupShape.php b/examples/svgModuleGroupShape.php
index 438753cb0..07470a6dc 100644
--- a/examples/svgModuleGroupShape.php
+++ b/examples/svgModuleGroupShape.php
@@ -246,7 +246,7 @@ $options->svgDefs = '
]]>';
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/svgModuleJitter.php b/examples/svgModuleJitter.php
index cdb4020f2..af122e815 100644
--- a/examples/svgModuleJitter.php
+++ b/examples/svgModuleJitter.php
@@ -148,7 +148,7 @@ $options->svgDefs = '
]]>';
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/svgRandomColoredDots.php b/examples/svgRandomColoredDots.php
index 054825444..d6f74ba42 100644
--- a/examples/svgRandomColoredDots.php
+++ b/examples/svgRandomColoredDots.php
@@ -154,7 +154,7 @@ $options->keepAsSquare = [
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
// dump the output
diff --git a/examples/svgRoundQuietzone.php b/examples/svgRoundQuietzone.php
index 839c5f568..00922da3d 100644
--- a/examples/svgRoundQuietzone.php
+++ b/examples/svgRoundQuietzone.php
@@ -334,7 +334,7 @@ $options->keepAsSquare = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/svgWithLogo.php b/examples/svgWithLogo.php
index 82bba4a19..a7c4790ff 100644
--- a/examples/svgWithLogo.php
+++ b/examples/svgWithLogo.php
@@ -138,7 +138,7 @@ $options->svgDefs = '
]]>';
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/svgWithLogoAndCustomShapes.php b/examples/svgWithLogoAndCustomShapes.php
index 34487b3f3..a25fb9b45 100644
--- a/examples/svgWithLogoAndCustomShapes.php
+++ b/examples/svgWithLogoAndCustomShapes.php
@@ -191,7 +191,7 @@ $options->svgDefs = '
]]>';
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(PHP_SAPI !== 'cli'){
diff --git a/examples/text.php b/examples/text.php
index 7645a2c8b..ae21d6917 100644
--- a/examples/text.php
+++ b/examples/text.php
@@ -42,7 +42,7 @@ $options->moduleValues = [
];
-$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+$out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
printf("\n\n\n%s\n\n\n", $out);
diff --git a/examples/xml.php b/examples/xml.php
index e8afcd74c..040297ad2 100644
--- a/examples/xml.php
+++ b/examples/xml.php
@@ -55,7 +55,7 @@ $options->moduleValues = [
try{
- $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
+ $out = new QRCode($options)->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
}
catch(Throwable $e){
// handle the exception in whatever way you need
diff --git a/src/Common/GenericGFPoly.php b/src/Common/GenericGFPoly.php
index 5c0b63b87..dc9928fb2 100644
--- a/src/Common/GenericGFPoly.php
+++ b/src/Common/GenericGFPoly.php
@@ -213,7 +213,7 @@ final class GenericGFPoly{
$this->coefficients[$i] ^= GF256::exp(GF256::log($c) + $ratio);
}
- return (new self($this->coefficients))->mod($other);
+ return new self($this->coefficients)->mod($other);
}
public function addOrSubtract(GenericGFPoly $other):self{
diff --git a/src/Data/QRData.php b/src/Data/QRData.php
index 85c327deb..064e437dd 100644
--- a/src/Data/QRData.php
+++ b/src/Data/QRData.php
@@ -123,7 +123,7 @@ final class QRData{
* returns a fresh matrix object with the data written and masked with the given $maskPattern
*/
public function writeMatrix():QRMatrix{
- return (new QRMatrix($this->version, $this->eccLevel))
+ return new QRMatrix($this->version, $this->eccLevel)
->initFunctionalPatterns()
->writeCodewords($this->bitBuffer)
;
diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php
index 160e8af08..c2e598d43 100755
--- a/src/Data/QRMatrix.php
+++ b/src/Data/QRMatrix.php
@@ -676,7 +676,7 @@ class QRMatrix{
* Maps the interleaved binary $data on the matrix
*/
public function writeCodewords(BitBuffer $bitBuffer):static{
- $data = (new ReedSolomonEncoder($this->version, $this->eccLevel))->interleaveEcBytes($bitBuffer);
+ $data = new ReedSolomonEncoder($this->version, $this->eccLevel)->interleaveEcBytes($bitBuffer);
$byteCount = count($data);
$iByte = 0;
$iBit = 7;
diff --git a/src/Data/ReedSolomonEncoder.php b/src/Data/ReedSolomonEncoder.php
index bf7fc687d..4fca1fe6c 100644
--- a/src/Data/ReedSolomonEncoder.php
+++ b/src/Data/ReedSolomonEncoder.php
@@ -94,7 +94,7 @@ final class ReedSolomonEncoder{
$rsPolyDegree = $rsPoly->getDegree();
- $modCoefficients = (new GenericGFPoly($dataBytes, $rsPolyDegree))
+ $modCoefficients = new GenericGFPoly($dataBytes, $rsPolyDegree)
->mod($rsPoly)
->getCoefficients()
;
diff --git a/src/Decoder/BitMatrix.php b/src/Decoder/BitMatrix.php
index b262bbbf4..51dd1af4a 100644
--- a/src/Decoder/BitMatrix.php
+++ b/src/Decoder/BitMatrix.php
@@ -118,7 +118,7 @@ final class BitMatrix extends QRMatrix{
;
// invoke a fresh matrix with only the function & format patterns to compare against
- $matrix = (new QRMatrix($this->version, $this->eccLevel))
+ $matrix = new QRMatrix($this->version, $this->eccLevel)
->initFunctionalPatterns()
->setFormatInfo($this->maskPattern)
;
diff --git a/src/Decoder/Decoder.php b/src/Decoder/Decoder.php
index 92b2e2094..5fd6427e9 100644
--- a/src/Decoder/Decoder.php
+++ b/src/Decoder/Decoder.php
@@ -95,7 +95,7 @@ final class Decoder{
throw new QRCodeDecoderException('unable to read version or format info'); // @codeCoverageIgnore
}
- $resultBytes = (new ReedSolomonDecoder($this->version, $this->eccLevel))->decode($rawCodewords);
+ $resultBytes = new ReedSolomonDecoder($this->version, $this->eccLevel)->decode($rawCodewords);
return $this->decodeBitStream($resultBytes);
}
@@ -122,16 +122,16 @@ final class Decoder{
break;
}
elseif($datamode === Mode::NUMBER){
- $result .= (new Number)->decodeSegment($this->bitBuffer, $versionNumber);
+ $result .= new Number()->decodeSegment($this->bitBuffer, $versionNumber);
}
elseif($datamode === Mode::ALPHANUM){
$result .= $this->decodeAlphanumSegment($versionNumber, $fc1InEffect);
}
elseif($datamode === Mode::BYTE){
- $result .= (new Byte)->decodeSegment($this->bitBuffer, $versionNumber);
+ $result .= new Byte()->decodeSegment($this->bitBuffer, $versionNumber);
}
elseif($datamode === Mode::KANJI){
- $result .= (new Kanji)->decodeSegment($this->bitBuffer, $versionNumber);
+ $result .= new Kanji()->decodeSegment($this->bitBuffer, $versionNumber);
}
elseif($datamode === Mode::STRCTURED_APPEND){
@@ -148,10 +148,10 @@ final class Decoder{
$fc1InEffect = true;
}
elseif($datamode === Mode::ECI){
- $result .= (new ECI)->decodeSegment($this->bitBuffer, $versionNumber);
+ $result .= new ECI()->decodeSegment($this->bitBuffer, $versionNumber);
}
elseif($datamode === Mode::HANZI){
- $result .= (new Hanzi)->decodeSegment($this->bitBuffer, $versionNumber);
+ $result .= new Hanzi()->decodeSegment($this->bitBuffer, $versionNumber);
}
else{
throw new QRCodeDecoderException('invalid data mode');
@@ -172,7 +172,7 @@ final class Decoder{
}
private function decodeAlphanumSegment(int $versionNumber, bool $fc1InEffect):string{
- $str = (new AlphaNum)->decodeSegment($this->bitBuffer, $versionNumber);
+ $str = new AlphaNum()->decodeSegment($this->bitBuffer, $versionNumber);
// See section 6.4.8.1, 6.4.8.2
if($fc1InEffect){ // ???
diff --git a/src/Decoder/DecoderResult.php b/src/Decoder/DecoderResult.php
index a46a178bd..1a4f83a45 100644
--- a/src/Decoder/DecoderResult.php
+++ b/src/Decoder/DecoderResult.php
@@ -85,7 +85,7 @@ final class DecoderResult{
* Returns a QRMatrix instance with the settings and data of the reader result
*/
public function getQRMatrix():QRMatrix{
- return (new QRMatrix($this->version, $this->eccLevel))
+ return new QRMatrix($this->version, $this->eccLevel)
->initFunctionalPatterns()
->writeCodewords($this->rawBytes)
->setFormatInfo($this->maskPattern)
diff --git a/src/Detector/Detector.php b/src/Detector/Detector.php
index e66fe398c..9cabc5553 100644
--- a/src/Detector/Detector.php
+++ b/src/Detector/Detector.php
@@ -33,7 +33,7 @@ final class Detector{
* Detector constructor.
*/
public function __construct(LuminanceSourceInterface $source){
- $this->matrix = (new Binarizer($source))->getBlackMatrix();
+ $this->matrix = new Binarizer($source)->getBlackMatrix();
}
/**
@@ -47,7 +47,7 @@ final class Detector{
* Detects a QR Code in an image.
*/
public function detect():BitMatrix{
- $this->finderPatterns = (new FinderPatternFinder($this->matrix))->find();
+ $this->finderPatterns = new FinderPatternFinder($this->matrix)->find();
[$bottomLeft, $topLeft, $topRight] = $this->finderPatterns;
@@ -81,7 +81,7 @@ final class Detector{
$transform = $this->createTransform($topLeft, $topRight, $bottomLeft, $dimension, $alignmentPattern);
- return (new GridSampler)->sampleGrid($this->matrix, $dimension, $transform);
+ return new GridSampler()->sampleGrid($this->matrix, $dimension, $transform);
}
/**
@@ -305,7 +305,7 @@ final class Detector{
return null;
}
- return (new AlignmentPatternFinder($this->matrix, $overallEstModuleSize))->find(
+ return new AlignmentPatternFinder($this->matrix, $overallEstModuleSize)->find(
$alignmentAreaLeftX,
$alignmentAreaTopY,
($alignmentAreaRightX - $alignmentAreaLeftX),
@@ -336,7 +336,7 @@ final class Detector{
$sourceBottomRightY = $dimMinusThree;
}
- return (new PerspectiveTransform)->quadrilateralToQuadrilateral(
+ return new PerspectiveTransform()->quadrilateralToQuadrilateral(
3.5,
3.5,
$dimMinusThree,
diff --git a/src/Detector/PerspectiveTransform.php b/src/Detector/PerspectiveTransform.php
index 07040115f..2d69b6c0b 100644
--- a/src/Detector/PerspectiveTransform.php
+++ b/src/Detector/PerspectiveTransform.php
@@ -55,7 +55,7 @@ final class PerspectiveTransform{
float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3,
float $x0p, float $y0p, float $x1p, float $y1p, float $x2p, float $y2p, float $x3p, float $y3p,
):self{
- return (new self)
+ return new self()
->squareToQuadrilateral($x0p, $y0p, $x1p, $y1p, $x2p, $y2p, $x3p, $y3p)
->times($this->quadrilateralToSquare($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3));
}
diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php
index 7770bce50..ce09bc2dd 100644
--- a/src/Output/QROutputAbstract.php
+++ b/src/Output/QROutputAbstract.php
@@ -224,7 +224,7 @@ abstract class QROutputAbstract implements QROutputInterface{
throw new QRCodeOutputException('ext-fileinfo not loaded, cannot guess mime type');
}
- $mime = (new finfo(FILEINFO_MIME_TYPE))->buffer($imageData);
+ $mime = new finfo(FILEINFO_MIME_TYPE)->buffer($imageData);
if($mime === false){
throw new QRCodeOutputException('unable to detect mime type');
diff --git a/src/QRCode.php b/src/QRCode.php
index f256c316b..aa1808015 100755
--- a/src/QRCode.php
+++ b/src/QRCode.php
@@ -108,7 +108,7 @@ class QRCode{
* Returns a QRMatrix object for the given $data and current QROptions
*/
public function getQRMatrix():QRMatrix{
- $matrix = (new QRData($this->options, $this->dataSegments))->writeMatrix();
+ $matrix = new QRData($this->options, $this->dataSegments)->writeMatrix();
$maskPattern = $this->options->maskPattern === MaskPattern::AUTO
? MaskPattern::getBestPattern($matrix)
@@ -297,7 +297,7 @@ class QRCode{
* Reads a QR Code from the given luminance source
*/
public function readFromSource(LuminanceSourceInterface $source):DecoderResult{
- return (new Decoder($this->options))->decode($source);
+ return new Decoder($this->options)->decode($source);
}
}
diff --git a/tests/Common/VersionTest.php b/tests/Common/VersionTest.php
index 00a2df063..09fac2e89 100644
--- a/tests/Common/VersionTest.php
+++ b/tests/Common/VersionTest.php
@@ -46,7 +46,7 @@ final class VersionTest extends TestCase{
public function getVersionPattern():void{
$this::assertSame(0b000111110010010100, $this->version->getVersionPattern());
// no pattern for version < 7
- $this::assertNull((new Version(6))->getVersionPattern());
+ $this::assertNull(new Version(6)->getVersionPattern());
}
#[Test]
diff --git a/tests/Data/ECITest.php b/tests/Data/ECITest.php
index 366508b65..957cf0c30 100644
--- a/tests/Data/ECITest.php
+++ b/tests/Data/ECITest.php
@@ -67,7 +67,7 @@ final class ECITest extends TestCase{
// read the first 4 bits
$this::assertSame($segments[0]::DATAMODE, $bitBuffer->read(4));
// decode the data
- $this::assertSame(self::testData, (new ECI)->decodeSegment($bitBuffer, $options->version));
+ $this::assertSame(self::testData, new ECI()->decodeSegment($bitBuffer, $options->version));
}
#[Test]
@@ -108,7 +108,7 @@ final class ECITest extends TestCase{
#[DataProvider('eciCharsetIdProvider')]
public function readWrite(int $id, int $lengthInBits):void{
$bitBuffer = new BitBuffer;
- $eci = (new ECI($id))->write($bitBuffer, 1);
+ $eci = new ECI($id)->write($bitBuffer, 1);
$this::assertSame($lengthInBits, $eci->getLengthInBits());
$this::assertSame(Mode::ECI, $bitBuffer->read(4));
@@ -130,11 +130,11 @@ final class ECITest extends TestCase{
$segments = $this->getDataSegments();
// follow the ECI segment by a non-8bit-byte segment
$segments[1] = new Hanzi(self::testData);
- $bitBuffer = (new QRData($options, $segments))->getBitBuffer();
+ $bitBuffer = new QRData($options, $segments)->getBitBuffer();
// verify the ECI mode indicator
$this::assertSame(Mode::ECI, $bitBuffer->read(4));
// throw
- (new ECI)->decodeSegment($bitBuffer, $options->version);
+ new ECI()->decodeSegment($bitBuffer, $options->version);
}
/**
@@ -157,9 +157,9 @@ final class ECITest extends TestCase{
$options->version = 5;
$segments = [new ECI($id), new Byte($data)];
- $bitBuffer = (new QRData($options, $segments))->getBitBuffer();
+ $bitBuffer = new QRData($options, $segments)->getBitBuffer();
$this::assertSame(Mode::ECI, $bitBuffer->read(4));
- $this::assertSame($data,(new ECI)->decodeSegment($bitBuffer, $options->version));
+ $this::assertSame($data, new ECI()->decodeSegment($bitBuffer, $options->version));
}
}
diff --git a/tests/Data/QRDataTest.php b/tests/Data/QRDataTest.php
index 986002d14..42c9efd0d 100644
--- a/tests/Data/QRDataTest.php
+++ b/tests/Data/QRDataTest.php
@@ -42,7 +42,7 @@ final class QRDataTest extends TestCase{
$options = new QROptions(['version' => 3]);
$bitBuffer = new BitBuffer($rawBytes);
- $matrix = (new QRData($options))->setBitBuffer($bitBuffer)->writeMatrix();
+ $matrix = new QRData($options)->setBitBuffer($bitBuffer)->writeMatrix();
$maskPattern = MaskPattern::getBestPattern($matrix);
$matrix->setFormatInfo($maskPattern)->mask($maskPattern);
@@ -54,7 +54,7 @@ final class QRDataTest extends TestCase{
$options->readerUseImagickIfAvailable = false;
$output = new QRGdImagePNG($options, $matrix);
- $decodeResult = (new QRCode($options))->readFromBlob($output->dump());
+ $decodeResult = new QRCode($options)->readFromBlob($output->dump());
$this->debugMatrix($matrix);
diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php
index 09c81d577..f6d836d3f 100755
--- a/tests/Data/QRMatrixTest.php
+++ b/tests/Data/QRMatrixTest.php
@@ -68,7 +68,7 @@ final class QRMatrixTest extends TestCase{
#[Test]
public function getMaskPattern():void{
// set via matrix evaluation
- $matrix = (new QRCode)->addByteSegment('testdata')->getQRMatrix();
+ $matrix = new QRCode()->addByteSegment('testdata')->getQRMatrix();
$this::assertInstanceOf(MaskPattern::class, $matrix->getMaskPattern());
$this::assertSame(MaskPattern::PATTERN_100, $matrix->getMaskPattern()->getPattern());
@@ -344,7 +344,7 @@ final class QRMatrixTest extends TestCase{
$o->addLogoSpace = true;
$o->logoSpaceHeight = 5;
- $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
+ $matrix = new QRCode($o)->addByteSegment('testdata')->getQRMatrix();
$this->debugMatrix($matrix);
@@ -365,7 +365,7 @@ final class QRMatrixTest extends TestCase{
$o->eccLevel = EccLevel::H;
$o->addQuietzone = false;
- $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
+ $matrix = new QRCode($o)->addByteSegment('testdata')->getQRMatrix();
// also testing size adjustment to uneven numbers
$matrix->setLogoSpace(20, 14);
@@ -391,7 +391,7 @@ final class QRMatrixTest extends TestCase{
$o->addQuietzone = true;
$o->quietzoneSize = 10;
- $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
+ $matrix = new QRCode($o)->addByteSegment('testdata')->getQRMatrix();
$matrix->setLogoSpace(21, 21, -10, -10);
$this->debugMatrix($matrix);
@@ -417,7 +417,7 @@ final class QRMatrixTest extends TestCase{
$this->expectException(QRCodeDataException::class);
$this->expectExceptionMessage('ECC level "H" required to add logo space');
- (new QRCode)->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(50, 50);
+ new QRCode()->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(50, 50);
}
/**
@@ -432,7 +432,7 @@ final class QRMatrixTest extends TestCase{
$o->version = 5;
$o->eccLevel = EccLevel::H;
- (new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(69, 1);
+ new QRCode($o)->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(69, 1);
}
/**
@@ -447,7 +447,7 @@ final class QRMatrixTest extends TestCase{
$o->version = 5;
$o->eccLevel = EccLevel::H;
- (new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(37, 37);
+ new QRCode($o)->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(37, 37);
}
/**
diff --git a/tests/Output/QROutputTestAbstract.php b/tests/Output/QROutputTestAbstract.php
index f326afb88..5e3b2a6c3 100644
--- a/tests/Output/QROutputTestAbstract.php
+++ b/tests/Output/QROutputTestAbstract.php
@@ -40,7 +40,7 @@ abstract class QROutputTestAbstract extends TestCase{
$this->createBuildDir($this::buildDir);
$this->options = new QROptions;
- $this->matrix = (new QRCode($this->options))->addByteSegment('testdata')->getQRMatrix();
+ $this->matrix = new QRCode($this->options)->addByteSegment('testdata')->getQRMatrix();
$this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
}
@@ -89,7 +89,7 @@ abstract class QROutputTestAbstract extends TestCase{
$this->options->outputBase64 = false;
$this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
// create the cache file
- $name = (new ReflectionObject($this->outputInterface))->getShortName();
+ $name = new ReflectionObject($this->outputInterface)->getShortName();
$fileSubPath = $this::buildDir.'/test.output.'.$name;
$data = $this->outputInterface->dump($this->getBuildPath($fileSubPath));
diff --git a/tests/QRCodeReaderImagickTest.php b/tests/QRCodeReaderImagickTest.php
index 33c75ecb2..f1ac7848c 100644
--- a/tests/QRCodeReaderImagickTest.php
+++ b/tests/QRCodeReaderImagickTest.php
@@ -60,7 +60,7 @@ final class QRCodeReaderImagickTest extends QRCodeReaderTestAbstract{
$luminanceSource = $this->getLuminanceSourceFromFile($this::samplesDir.$img, $this->options);
- $this::assertSame($expected, (string)(new Decoder)->decode($luminanceSource));
+ $this::assertSame($expected, (string)new Decoder()->decode($luminanceSource));
}
}
diff --git a/tests/QRCodeReaderTestAbstract.php b/tests/QRCodeReaderTestAbstract.php
index bd299a2b4..1f4892bb3 100644
--- a/tests/QRCodeReaderTestAbstract.php
+++ b/tests/QRCodeReaderTestAbstract.php
@@ -101,7 +101,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
}
$luminanceSource = $this->getLuminanceSourceFromFile($file, $this->options);
- $result = (new Decoder)->decode($luminanceSource);
+ $result = new Decoder()->decode($luminanceSource);
$this->debugMatrix($result->getQRMatrix());
@@ -119,7 +119,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
$hanzi = '无可奈何燃花作香';
$byte = 'https://smiley.codes/qrcode/';
- $qrcode = (new QRCode($this->options))
+ $qrcode = new QRCode($this->options)
->addNumericSegment($numeric)
->addAlphaNumSegment($alphanum)
->addKanjiSegment($kanji)
diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php
index 67ba9de42..3a606314e 100755
--- a/tests/QRCodeTest.php
+++ b/tests/QRCodeTest.php
@@ -101,10 +101,10 @@ final class QRCodeTest extends TestCase{
public function addEciSegment():void{
$expected = '无可奈何燃花作香';
- $qrCode = (new QRCode([
+ $qrCode = new QRCode([
'outputBase64' => false,
'outputInterface' => QRGdImagePNG::class,
- ]));
+ ]);
$qrCode->addEciSegment(ECICharset::GB18030, $expected);
@@ -118,7 +118,7 @@ final class QRCodeTest extends TestCase{
$this->expectException(QRCodeException::class);
$this->expectExceptionMessage('unable to add ECI segment');
- (new QRCode)->addEciSegment(666, 'nope');
+ new QRCode()->addEciSegment(666, 'nope');
}
}
diff --git a/tests/Traits/QRMatrixDebugTrait.php b/tests/Traits/QRMatrixDebugTrait.php
index bad235ff8..d86155cc2 100644
--- a/tests/Traits/QRMatrixDebugTrait.php
+++ b/tests/Traits/QRMatrixDebugTrait.php
@@ -71,7 +71,7 @@ trait QRMatrixDebugTrait{
QRMatrix::M_NULL => QRStringText::ansi8('░░', 231),
];
- $out = (new QRStringText($options, $matrix))->dump();
+ $out = new QRStringText($options, $matrix)->dump();
printf("\n\n%s\n\n", $out);
}