Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Object reserved keyword #14

Open
fntlnz opened this issue Dec 17, 2015 · 14 comments
Open

Object reserved keyword #14

fntlnz opened this issue Dec 17, 2015 · 14 comments
Milestone

Comments

@fntlnz
Copy link

fntlnz commented Dec 17, 2015

The object keyword became reserved in PHP 7, this conflicts with the Zend\Barcode\Object;
namespace.

http://php.net/manual/en/reserved.other-reserved-words.php

@weierophinney
Copy link
Member

@fntlnz It doesn't. The reason is because the namespace is not Object, but Zend\Barcode\Object; our tests even pass currently on PHP 7.

Do you have a specific example demonstrating breakage?

@fntlnz
Copy link
Author

fntlnz commented Feb 18, 2016

@weierophinney The object keyword does not lead to an immediate breakage (like Int, Float and String) because is not marked as reserved in the current implementations of the PHP language (PHP, HHVM etc) but has been reserved for the future use as stated by these documentes:

  • PHP Documentation here

These words cannot be used to name a class, interface or a trait. These words are also prohibited from being used in namespaces. Some of the words are reserved to enable future PHP features without breaking backward compatibility. [...followed by a table containing reserved names including object]

  • PHP language specification here

The following names are reserved for future use and should not be used as the names of classes, interfaces, or traits: mixed, numeric, object, and resource.

@Maks3w
Copy link
Member

Maks3w commented Feb 18, 2016

Object is used as namespace not as class, interface or trait.

@fntlnz
Copy link
Author

fntlnz commented Feb 18, 2016

So, what's the point?

From: http://php.net/manual/en/reserved.other-reserved-words.php

These words are also prohibited from being used in namespaces

@Maks3w
Copy link
Member

Maks3w commented Feb 18, 2016

As @weierophinney point the namespace is the whole string. PHP does not distinguish namespace parts.

Probably namespace Object {} may fail due the restrictions you noticed but not Foo\<any restricted word>

Anyway if you found a better term for name the namespace we could consider start to use it in the next minor version (preserving the old namespace for BC)

@gianarb
Copy link

gianarb commented Feb 18, 2016

Hello @fntlnz :)

We can start to use a new name ( and mark this class as deprecated in order to remove it during 3.0 release

  • Zend\Barcode\BarcodeObject
  • Zend\Barcode\Barcode

@remicollet
Copy link
Contributor

Minimal fix in #36

@dbarn
Copy link

dbarn commented Nov 9, 2018

Hi, we are also seeing this issue in PHP 7.2

PHP Fatal error: Cannot use Zend\Barcode\Object as Object because 'Object' is a special class name in www/vhosts/api.content-manager/src/PhysicalLookbook/Service/PdfGenerator.php on line 26

Line 26:
use Zend\Barcode\Object;

Any help very welcome.

Thks

@froschdesign
Copy link
Member

@dbarn
Which version of zend-barcode do you use?

@froschdesign
Copy link
Member

froschdesign commented Nov 9, 2018

Fixed with #36 and released with version 2.6.1

@froschdesign
Copy link
Member

Related to #37

@dbarn
Copy link

dbarn commented Nov 9, 2018

Hi we are using 2.7
I have fixed by aliasing the object in our code:
Line 26:
use Zend\Barcode\Object as BarcodeObject

And then using
$barcode = new Object\Ean13();

This work ok.

@froschdesign
Copy link
Member

@dbarn
Thanks for your feedback!

I will reopen this issue, because the problem with Object in namespace was not fixed and must be done on version 3.0!

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-barcode; a new issue has been opened at laminas/laminas-barcode#1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants