Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • S stateful
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • grifart libsgrifart libs
  • stateful
  • Merge requests
  • !23

wip: generic State<T>

  • Review changes

  • Download
  • Patches
  • Plain diff
Open Jiří Pudil requested to merge generic-state into master Dec 01, 2020
  • Overview 1
  • Commits 1
  • Pipelines 2
  • Changes 12

closes #8

Zkusil jsem naťuknout generický State, ale ještě to není úúúúplně ono 🤔

<?php

final class Foo implements \Grifart\Stateful\Stateful
{

	public function _getState(): \Grifart\Stateful\State
	{
		return \Grifart\Stateful\StateBuilder::from($this)
			->version(1)
			->build();
	}

	public static function _fromState(\Grifart\Stateful\State $state): static
	{
		$obj = $state->makeAnEmptyObject(static::class);
		return $obj;
	}
}

vyprodukuje

------ -----------------------------------------------------------------------
  Line   test.php
 ------ -----------------------------------------------------------------------
  6      Return type (Grifart\Stateful\State<static(Foo)>) of method
         Foo::_getState() should be compatible with return type
         (Grifart\Stateful\State<static(Grifart\Stateful\Stateful)>) of method
         Grifart\Stateful\Stateful::_getState()
  8      Method Foo::_getState() should return
         Grifart\Stateful\State<static(Foo)> but returns
         Grifart\Stateful\State<Foo>.
  16     Method Foo::_fromState() should return static(Foo) but returns
         Grifart\Stateful\Stateful.
 ------ -----------------------------------------------------------------------
Edited Dec 01, 2020 by Jiří Pudil
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: generic-state