Skip to content

Commit 24e96f8

Browse files
committed
Support reflected attributes of string type
Change-Id: Ibedeeedabf948c86ab71e8bb0655dc839c61195e
1 parent 092d36c commit 24e96f8

File tree

108 files changed

+3158
-2578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3158
-2578
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Support "unnamed" getter/setters/deleters/stringifiers.
44
* Return return types for cast() helper methods, in order to accommodate
55
the weak covariant return type checks in PHP 7.2.
6+
* Generate helper functions for attributes with the [Reflect] extended
7+
attribute (which reflect an HTML element attribute).
68

79
# IDLeDOM 0.3.0 (2021-04-12)
810
* Use interface (instead of class) for enumerations. This allows

src/Helper/HTMLAnchorElement.php

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Wikimedia\IDLeDOM\Helper;
77

8+
use Wikimedia\IDLeDOM\Element;
9+
810
trait HTMLAnchorElement {
911
/**
1012
* @param string $name
@@ -634,4 +636,164 @@ public function __unset( string $name ) : void {
634636
);
635637
}
636638

639+
/**
640+
* @return string
641+
*/
642+
public function getTarget() : string {
643+
'@phan-var Element $this'; /** @var Element $this */
644+
return $this->getAttribute( 'target' ) ?? '';
645+
}
646+
647+
/**
648+
* @param string $val
649+
*/
650+
public function setTarget( string $val ) : void {
651+
'@phan-var Element $this'; /** @var Element $this */
652+
$this->setAttribute( 'target', $val );
653+
}
654+
655+
/**
656+
* @return string
657+
*/
658+
public function getDownload() : string {
659+
'@phan-var Element $this'; /** @var Element $this */
660+
return $this->getAttribute( 'download' ) ?? '';
661+
}
662+
663+
/**
664+
* @param string $val
665+
*/
666+
public function setDownload( string $val ) : void {
667+
'@phan-var Element $this'; /** @var Element $this */
668+
$this->setAttribute( 'download', $val );
669+
}
670+
671+
/**
672+
* @return string
673+
*/
674+
public function getRel() : string {
675+
'@phan-var Element $this'; /** @var Element $this */
676+
return $this->getAttribute( 'rel' ) ?? '';
677+
}
678+
679+
/**
680+
* @param string $val
681+
*/
682+
public function setRel( string $val ) : void {
683+
'@phan-var Element $this'; /** @var Element $this */
684+
$this->setAttribute( 'rel', $val );
685+
}
686+
687+
/**
688+
* @return string
689+
*/
690+
public function getHreflang() : string {
691+
'@phan-var Element $this'; /** @var Element $this */
692+
return $this->getAttribute( 'hreflang' ) ?? '';
693+
}
694+
695+
/**
696+
* @param string $val
697+
*/
698+
public function setHreflang( string $val ) : void {
699+
'@phan-var Element $this'; /** @var Element $this */
700+
$this->setAttribute( 'hreflang', $val );
701+
}
702+
703+
/**
704+
* @return string
705+
*/
706+
public function getType() : string {
707+
'@phan-var Element $this'; /** @var Element $this */
708+
return $this->getAttribute( 'type' ) ?? '';
709+
}
710+
711+
/**
712+
* @param string $val
713+
*/
714+
public function setType( string $val ) : void {
715+
'@phan-var Element $this'; /** @var Element $this */
716+
$this->setAttribute( 'type', $val );
717+
}
718+
719+
/**
720+
* @return string
721+
*/
722+
public function getCoords() : string {
723+
'@phan-var Element $this'; /** @var Element $this */
724+
return $this->getAttribute( 'coords' ) ?? '';
725+
}
726+
727+
/**
728+
* @param string $val
729+
*/
730+
public function setCoords( string $val ) : void {
731+
'@phan-var Element $this'; /** @var Element $this */
732+
$this->setAttribute( 'coords', $val );
733+
}
734+
735+
/**
736+
* @return string
737+
*/
738+
public function getCharset() : string {
739+
'@phan-var Element $this'; /** @var Element $this */
740+
return $this->getAttribute( 'charset' ) ?? '';
741+
}
742+
743+
/**
744+
* @param string $val
745+
*/
746+
public function setCharset( string $val ) : void {
747+
'@phan-var Element $this'; /** @var Element $this */
748+
$this->setAttribute( 'charset', $val );
749+
}
750+
751+
/**
752+
* @return string
753+
*/
754+
public function getName() : string {
755+
'@phan-var Element $this'; /** @var Element $this */
756+
return $this->getAttribute( 'name' ) ?? '';
757+
}
758+
759+
/**
760+
* @param string $val
761+
*/
762+
public function setName( string $val ) : void {
763+
'@phan-var Element $this'; /** @var Element $this */
764+
$this->setAttribute( 'name', $val );
765+
}
766+
767+
/**
768+
* @return string
769+
*/
770+
public function getRev() : string {
771+
'@phan-var Element $this'; /** @var Element $this */
772+
return $this->getAttribute( 'rev' ) ?? '';
773+
}
774+
775+
/**
776+
* @param string $val
777+
*/
778+
public function setRev( string $val ) : void {
779+
'@phan-var Element $this'; /** @var Element $this */
780+
$this->setAttribute( 'rev', $val );
781+
}
782+
783+
/**
784+
* @return string
785+
*/
786+
public function getShape() : string {
787+
'@phan-var Element $this'; /** @var Element $this */
788+
return $this->getAttribute( 'shape' ) ?? '';
789+
}
790+
791+
/**
792+
* @param string $val
793+
*/
794+
public function setShape( string $val ) : void {
795+
'@phan-var Element $this'; /** @var Element $this */
796+
$this->setAttribute( 'shape', $val );
797+
}
798+
637799
}

src/Helper/HTMLAreaElement.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Wikimedia\IDLeDOM\Helper;
77

8+
use Wikimedia\IDLeDOM\Element;
9+
810
trait HTMLAreaElement {
911
/**
1012
* @param string $name
@@ -589,4 +591,84 @@ public function __unset( string $name ) : void {
589591
);
590592
}
591593

594+
/**
595+
* @return string
596+
*/
597+
public function getAlt() : string {
598+
'@phan-var Element $this'; /** @var Element $this */
599+
return $this->getAttribute( 'alt' ) ?? '';
600+
}
601+
602+
/**
603+
* @param string $val
604+
*/
605+
public function setAlt( string $val ) : void {
606+
'@phan-var Element $this'; /** @var Element $this */
607+
$this->setAttribute( 'alt', $val );
608+
}
609+
610+
/**
611+
* @return string
612+
*/
613+
public function getCoords() : string {
614+
'@phan-var Element $this'; /** @var Element $this */
615+
return $this->getAttribute( 'coords' ) ?? '';
616+
}
617+
618+
/**
619+
* @param string $val
620+
*/
621+
public function setCoords( string $val ) : void {
622+
'@phan-var Element $this'; /** @var Element $this */
623+
$this->setAttribute( 'coords', $val );
624+
}
625+
626+
/**
627+
* @return string
628+
*/
629+
public function getShape() : string {
630+
'@phan-var Element $this'; /** @var Element $this */
631+
return $this->getAttribute( 'shape' ) ?? '';
632+
}
633+
634+
/**
635+
* @param string $val
636+
*/
637+
public function setShape( string $val ) : void {
638+
'@phan-var Element $this'; /** @var Element $this */
639+
$this->setAttribute( 'shape', $val );
640+
}
641+
642+
/**
643+
* @return string
644+
*/
645+
public function getTarget() : string {
646+
'@phan-var Element $this'; /** @var Element $this */
647+
return $this->getAttribute( 'target' ) ?? '';
648+
}
649+
650+
/**
651+
* @param string $val
652+
*/
653+
public function setTarget( string $val ) : void {
654+
'@phan-var Element $this'; /** @var Element $this */
655+
$this->setAttribute( 'target', $val );
656+
}
657+
658+
/**
659+
* @return string
660+
*/
661+
public function getRel() : string {
662+
'@phan-var Element $this'; /** @var Element $this */
663+
return $this->getAttribute( 'rel' ) ?? '';
664+
}
665+
666+
/**
667+
* @param string $val
668+
*/
669+
public function setRel( string $val ) : void {
670+
'@phan-var Element $this'; /** @var Element $this */
671+
$this->setAttribute( 'rel', $val );
672+
}
673+
592674
}

src/Helper/HTMLBRElement.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Wikimedia\IDLeDOM\Helper;
77

8+
use Wikimedia\IDLeDOM\Element;
9+
810
trait HTMLBRElement {
911
/**
1012
* @param string $name
@@ -442,4 +444,20 @@ public function __unset( string $name ) : void {
442444
);
443445
}
444446

447+
/**
448+
* @return string
449+
*/
450+
public function getClear() : string {
451+
'@phan-var Element $this'; /** @var Element $this */
452+
return $this->getAttribute( 'clear' ) ?? '';
453+
}
454+
455+
/**
456+
* @param string $val
457+
*/
458+
public function setClear( string $val ) : void {
459+
'@phan-var Element $this'; /** @var Element $this */
460+
$this->setAttribute( 'clear', $val );
461+
}
462+
445463
}

src/Helper/HTMLBaseElement.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Wikimedia\IDLeDOM\Helper;
77

8+
use Wikimedia\IDLeDOM\Element;
9+
810
trait HTMLBaseElement {
911
/**
1012
* @param string $name
@@ -451,4 +453,20 @@ public function __unset( string $name ) : void {
451453
);
452454
}
453455

456+
/**
457+
* @return string
458+
*/
459+
public function getTarget() : string {
460+
'@phan-var Element $this'; /** @var Element $this */
461+
return $this->getAttribute( 'target' ) ?? '';
462+
}
463+
464+
/**
465+
* @param string $val
466+
*/
467+
public function setTarget( string $val ) : void {
468+
'@phan-var Element $this'; /** @var Element $this */
469+
$this->setAttribute( 'target', $val );
470+
}
471+
454472
}

0 commit comments

Comments
 (0)