-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version is mandatory at vCard 4.0 #128
version is mandatory at vCard 4.0 #128
Conversation
… after the Begin Property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a Version Property/Parameter.
Maby you can find a way:
to make it "required"?
to place it as the first property?
The vCard need to start with:
now the vCard begins with
Defined by the Specifications:
|
@helveticadomes, I do understand what the purpose is. I'm just not sure if we should go "your solution" or "need to use the already available" |
… after the Begin Property Use the Version Property instead of static
As Requested i update my pullrequest: |
merge pr to be uptodate
…failed Travis checks)
src/VCard.php
Outdated
} | ||
|
||
public function getParameters(string $filterByPropertyParameterClass = null): array | ||
{ | ||
if ($filterByPropertyParameterClass === null) { | ||
|
||
$array = $this->parameters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace your entire "additions" here by an array_map().
In that new function you could check "return ($class instanceof Version) ? -1 : +1".
Using such an easy way we move our "Version" to the frond of the array by using comparisons.
Another (but bigger) addition to this solution could be to add a $priority value to each and every Property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. with help of a similar addition i can solve #113 => https://github.com/helveticadomes/vcard/blob/feature-fix-name-property/src/VCard.php
Lines 167-190
Pullrequest not quite finished yet
src/Formatter/VcfFormatter.php
Outdated
@@ -12,6 +12,7 @@ | |||
public const CONTENT_TYPE = 'text/vcard'; | |||
public const FILE_EXTENSION = 'vcf'; | |||
public const VCARD_BEGIN = 'BEGIN:VCARD'; | |||
//public const VCARD_VERSION = 'VERSION:4.0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed
src/Formatter/VcfFormatter.php
Outdated
@@ -21,6 +22,7 @@ public function getContent(array $vCards): string | |||
/** @var VCard $vCard */ | |||
foreach ($vCards as $vCard) { | |||
$string .= self::VCARD_BEGIN . "\r\n"; | |||
//$string .= self::VCARD_VERSION . "\r\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed
src/VCard.php
Outdated
@@ -130,12 +132,24 @@ private function addPropertyParameter(PropertyParameterInterface $propertyParame | |||
|
|||
public function getKind(): Kind | |||
{ | |||
return $this->getParameters(Kind::class)[0]; | |||
$kind = $this->getParameters(Kind::class); | |||
return reset($kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No => that would lead to:
Notice: Only variables should be passed by reference in ..\vendor\jeroendesloovere\vcard\src\VCard.php on line 136
at least if it is done like that:
return reset($this->getParameters(Kind::class));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, probably return reset($kind = $this->getParameters(Kind::class));
will work then.
But I suggest you leave it like that. Just "add an empty rule above the return statement".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately your suggested code doesn't work either
why empty rule? because of $this->add($kind ?? Kind::individual());
inside constructor it could not be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good practice to add an empty line above a return statement like this:
$kind = $this->getParameters(Kind::class);
return reset($kind);
and not like this:
$kind = $this->getParameters(Kind::class);
return reset($kind);
Please, merge this. The version number is required in v4: I think helveticadomes did wonderful work. |
|
@jeroendesloovere Note: Since I'm validating the actual context. This merge should lead to a UT failures now. Which is good! Since I wrote a good unit testers that ACTUALLY checks the content as well 👍 Nevertheless, this does require some change in the UT to fix it again, see: Like this line: Likely needs to be extended with this version 4.0 :) |
@jeroendesloovere I will fix the failing test! However, I found another bug in the version parser (or lack of parsing of the version I would say). I will try to fix that as well. |
version is mandatory and at vCard 4.0 and it has to be on the line direct after the Begin Property